mirror of
https://github.com/actuallymentor/battery.git
synced 2026-02-03 05:53:24 +00:00
🐛 Misc bugfixes and add AGENTS.me
This commit is contained in:
22
AGENTS.md
Normal file
22
AGENTS.md
Normal file
@@ -0,0 +1,22 @@
|
||||
This repository contains software that limits the battery charging level of apple silicon macbooks.
|
||||
|
||||
## Project structure
|
||||
|
||||
- `./battery.sh` is the main CLI binary used under the hood
|
||||
- `./setup.sh` is the setup script for the binary
|
||||
- `./update.sh` is the script used to update the binary
|
||||
- `./app/` contains an electron codebase for a GUI that wraps around the CLI
|
||||
- `./dist` contains precompiled binaries that are shipped with the CLI
|
||||
|
||||
## Development flow
|
||||
|
||||
- any changes made to `battery.sh` must also increment the version number at the top of `battery.sh` as this is what the update command relies on
|
||||
- any changes to `smc` commands must update the `visudoconfig` variable in `battery.sh` as this updates the visudo entry on the client device to make sure smc may run commands without sudo
|
||||
- any changes to the `visudoconfig` file must add a corresponding line to the `smc_commands` variable in `app/modules/battery.js` as this makes sure the GUI continues working when the visudo commands are changed
|
||||
|
||||
## Mantatory checks
|
||||
|
||||
Before finishing any task, make sure that you:
|
||||
|
||||
- do a sanity check for bugs
|
||||
- check that comments still reflect the changed code
|
||||
13
battery.sh
13
battery.sh
@@ -4,7 +4,7 @@
|
||||
## Update management
|
||||
## variables are used by this binary as well at the update script
|
||||
## ###############
|
||||
BATTERY_CLI_VERSION="v1.3.0"
|
||||
BATTERY_CLI_VERSION="v1.3.1"
|
||||
|
||||
# Path fixes for unexpected environments
|
||||
PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
|
||||
@@ -439,7 +439,7 @@ if [[ "$action" == "visudo" ]]; then
|
||||
|
||||
# Write the visudo file to a tempfile
|
||||
visudo_tmpfile="$configfolder/visudo.tmp"
|
||||
sudo rm visudo_tmpfile 2>/dev/null
|
||||
sudo rm $visudo_tmpfile 2>/dev/null
|
||||
echo -e "$visudoconfig" >$visudo_tmpfile
|
||||
|
||||
# If the visudo file is the same (no error, exit code 0), set the permissions just
|
||||
@@ -646,7 +646,7 @@ if [[ "$action" == "maintain_synchronous" ]]; then
|
||||
# Checking if the calibration process is running
|
||||
if test -f "$calibrate_pidfile"; then
|
||||
pid=$(cat "$calibrate_pidfile" 2>/dev/null)
|
||||
kill $calibrate_pidfile &>/dev/null
|
||||
kill $pid &>/dev/null
|
||||
log "🚨 Calibration process have been stopped"
|
||||
fi
|
||||
|
||||
@@ -801,7 +801,7 @@ if [[ "$action" == "maintain" ]]; then
|
||||
|
||||
if test -f "$calibrate_pidfile"; then
|
||||
pid=$(cat "$calibrate_pidfile" 2>/dev/null)
|
||||
kill $calibrate_pidfile &>/dev/null
|
||||
kill $pid &>/dev/null
|
||||
log "🚨 Calibration process have been stopped"
|
||||
fi
|
||||
|
||||
@@ -829,7 +829,7 @@ if [[ "$action" == "maintain" ]]; then
|
||||
log "Error: ${setting}V is not a valid setting. Please use a value between ${voltage_min}V and ${voltage_max}V"
|
||||
exit 1
|
||||
fi
|
||||
if (($(echo "$subsetting < $voltage_hyst_min" | bc -l) || $(echo "$subsetting > $voltage_max" | bc -l))); then
|
||||
if (($(echo "$subsetting < $voltage_hyst_min" | bc -l) || $(echo "$subsetting > $voltage_hyst_max" | bc -l))); then
|
||||
log "Error: ${subsetting}V is not a valid setting. Please use a value between ${voltage_hyst_min}V and ${voltage_hyst_max}V"
|
||||
exit 1
|
||||
fi
|
||||
@@ -935,7 +935,8 @@ if [[ "$action" == "calibrate" ]]; then
|
||||
|
||||
if [[ "$setting" == "stop" ]]; then
|
||||
log "Killing running calibration daemon"
|
||||
kill $calibrate_pidfile &>/dev/null
|
||||
pid=$(cat "$calibrate_pidfile" 2>/dev/null)
|
||||
kill $pid &>/dev/null
|
||||
rm $calibrate_pidfile 2>/dev/null
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user