Fix battery update on UI app startup (#377) and disabled charging (410)#413
Conversation
…ch is supposedly never written by battery.sh
| // Apple introduced the following two in 2025. | ||
| // It seems to apply to all Apple Silicon MacBooks, regardless of macOS version. | ||
| '-k CHTE -r', | ||
| '-k CH0J -w 01' |
There was a problem hiding this comment.
This line is a reason for the issue #410 (battery is not charging).
| chmod u+x $binfolder/battery | ||
|
|
||
| echo "[ 3 ] Updating visudo declarations" | ||
| $binfolder/battery visudo |
There was a problem hiding this comment.
This line is a reason for issue #377 (Error installing battery limiter: undefined)
This PR moves this line to /usr/local/bin/battery, which forces Terminal-only users to execute battery visudo automatically after each battery update.
Note, that if we leave this line as is, any change to /etc/sudoers.d/battery content, even a changed comment or newline, may lead to "Error installing battery limiter: undefined" error.
I would recommend to execute battery visudo every time the battery script is updated and drop "visudo_complete" related logic in battery.js. battery visudo compares old and new /etc/sudoers.d/battery contents byte by byte and overwrites /etc/sudoers.d/battery only if the script requires newer version.
| # Check if the user requested that the battery maintenance first discharge to the desired level | ||
| if [[ "$subsetting" == "--force-discharge" ]]; then | ||
| # Before we start maintaining the battery level, first discharge to the target level | ||
| local discharge_target="$lower_bound" |
There was a problem hiding this comment.
This line breaks "--force-discharge" functionality. 'local' outside a function is treated as an error, so discharge_target variable remains unassigned after this line.
|
@actuallymentor Sorry for tagging, I have no Twitter account. |
|
Ah I noticed that issue too and thought it was something I did. Thanks for fixing. Will merge within a few hours, am out of the house |
|
@base47 Thanks for jumping on this so quickly and for the clear comments and explanations about the changes. |
Fix battery update on UI app startup (actuallymentor#377) and disabled charging (410)
This also fixes