Skip to content

Fix battery update on UI app startup (#377) and disabled charging (410)#413

Merged
actuallymentor merged 3 commits intoactuallymentor:mainfrom
base47:fix-issues-377and410
Nov 20, 2025
Merged

Fix battery update on UI app startup (#377) and disabled charging (410)#413
actuallymentor merged 3 commits intoactuallymentor:mainfrom
base47:fix-issues-377and410

Conversation

@base47
Copy link
Copy Markdown

@base47 base47 commented Nov 20, 2025

This also fixes

// 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'
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Author

@base47 base47 Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line breaks "--force-discharge" functionality. 'local' outside a function is treated as an error, so discharge_target variable remains unassigned after this line.

@base47
Copy link
Copy Markdown
Author

base47 commented Nov 20, 2025

@actuallymentor Sorry for tagging, I have no Twitter account.
This PR fixes the issues in the yesterday's release v1.3.1.
I tested it and everything seems to work.

@actuallymentor
Copy link
Copy Markdown
Owner

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

@almostthere831
Copy link
Copy Markdown

@base47 Thanks for jumping on this so quickly and for the clear comments and explanations about the changes.

@actuallymentor actuallymentor merged commit 4861a09 into actuallymentor:main Nov 20, 2025
@base47 base47 deleted the fix-issues-377and410 branch November 20, 2025 16:47
panoskava pushed a commit to panoskava/battery that referenced this pull request Mar 17, 2026
Fix battery update on UI app startup (actuallymentor#377) and disabled charging (410)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants