actuallymentor / battery Goto Github PK
View Code? Open in Web Editor NEWCLI/GUI for managing the battery charging status for Apple silicon (M1, M32, M3) Macs
License: MIT License
CLI/GUI for managing the battery charging status for Apple silicon (M1, M32, M3) Macs
License: MIT License
Glad to see such a simple and useful tool.
There's am error log always shows up on my mac (MacBook Pro, 2019, Intel) when toggling the switch for charging:
$ battery charge 85
22:36:41 - Charging to 80% from 77%
22:36:41 - Enabling battery charging
Error: SMCWriteKey() = e00002bc
22:36:41 - Battery at 77%
22:37:41 - Battery at 78%
22:38:41 - Battery at 79%
22:39:41 - Battery at 80%
22:40:41 - Disabling battery charging
Error: SMCWriteKey() = e00002bc
22:40:41 - Charging completed at 80%
But it seems not a fatal one, after all it actually works fine to me.
Should I ignore this?
It worked well after installed. But while reboot and run "battery status"
10:16:40 - Battery at 98% (0:23 remaining), smc charging enabled
10:16:40 - Your battery is currently being maintained at 80%
MBP start charging after reboot eventhough 98% battery level.
Thanks.
Hi, great work here!
I have just one little additional problem. New monitor with type-C port have typically charging capability, which means you can use an external monitor while charging in a single type-C cable. But if mac's battery exceeds the limit, I can't have it reduce to a lower percentage. Aldente has a Discharge functionality which is exactly what I'm describing (but I'm a CLI guy sadly).
Can you please work on this?
I'm willing to code and just don't know how to achieve this.
Does this work for all Apple silicon Macs? Can I use it on Macbook Air M2?
Add battery percentage in de bar near the icon
when I uninstall, how to reset custom settings, recovery system setting?
What is the issue? (required)
My mac keeps asking for sudo password even after I uninstalled the app. I know it's asking the password because of Battery since I've opened Activity Monitor and I checked which files were open in the bash process that shows the sudo password prompt. It shows "/usr/local/bin/battery" but the file has been removed.
What exactly did you do to produce the issue? (required)
I uninstalled it through the command "battery uninstall". It didn't work so I tried reinstalling it and uninstalling it through brew. Didn't work either.
Hi, has anyone checked if this app works in Mac OS ventura?
What is the issue? (required)
The app fails to launch on my M2 Max MacBook Pro with the following error:
Error installing battery limiter: Command failed: ./applet/bin/sh: ./applet: Bad CPU type in executable
What exactly did you do to produce the issue? (required)
Steps to reproduce the behavior:
battery
via Homebrew: brew install battery
. Installation succeeds./Applications/Battery.app
.Expected behavior (required)
The application should launch without error.
Error logs (optional)
The log for ~/.battery/battery.log
does not exist. Here is the log for ~/.battery/gui.log
:
Starting tray app
Tray app boot complete
Triggering boot-time auto-update
Is installed?
false
Installing battery for tylermilner...
Update/install error:
Error: Command failed: ./applet
/bin/sh: ./applet: Bad CPU type in executable
Update process complete
Error getting battery status:
Error: Command failed: PATH=$PATH:/usr/local/bin/battery battery status
/bin/bash: battery: command not found
Additional context (optional)
Add any other context about the problem here.
Hi
first of all thanks for creating and sharing this.
I suspect my error might be related to the other open issue #16", but not sure.
I am using an Apple M1 Pro with Ventura 13.0.1.
I got these errors on installation via the DMG file, and some errors later when I tried the installation via command line:
- Error installing battery limiter: undefined
- Battery limiter error: Command failed: PATH=$PATH:/usr/local/bin/battery battery status
/bin/bash: battery: command not found
Then when I tried to click "Enable 80% battery limit:
- Command failed: PATH=$PATH:/usr/local/bin/battery battery maintain 80
/bin/bash: battery: command not found
Without uninstalling, I tried to install via the command line:
secret@machine ~ % curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash
####################################################################
# 👋 Welcome, this is the setup script for the battery CLI tool.
# Note: this script will ask for your password once or multiple times.
####################################################################
Password:
🔋 Starting battery installation
[ 1/9 ] Superuser permissions acquired.
[ 2/9 ] Cloning fan control version of smc
bash: line 30: cd: /Users/secret/.battery-tmp/smc/smc-command: No such file or directory
[ 3/9 ] Building smc from source
[ 4/9 ] Move smc to executable folder
mv: rename /Users/secret/.battery-tmp/smc/smc-command/smc to /usr/local/bin/smc: No such file or directory
chmod: /usr/local/bin/smc: No such file or directory
[ 5/9 ] Cloning battery repository
[ 6/9 ] Writing script to /usr/local/bin/battery for user secret
cp: /Users/secret/.battery-tmp/battery/battery.sh: No such file or directory
chown: /usr/local/bin/battery: No such file or directory
chmod: /usr/local/bin/battery: No such file or directory
chmod: /usr/local/bin/battery: No such file or directory
chown: /usr/local/bin/battery: No such file or directory
bash: /Users/secret/.battery-tmp/battery/battery.sh: No such file or directory
[ 7/9 ] Set up visudo declarations
[ 8/9 ] Removing temp folder /Users/secret/.battery-tmp
[ 9/9 ] Removed temporary build files
🎉 Battery tool installed. Type "battery help" for instructions.
secret@machine ~ % battery maintain 80
zsh: command not found: battery
I manually created these two folder with "sudo mkdir", but still got errors in the installation:
/usr/local/bin/smc
/usr/local/bin/battery:
secret@machine ~ % curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash
####################################################################
# 👋 Welcome, this is the setup script for the battery CLI tool.
# Note: this script will ask for your password once or multiple times.
####################################################################
🔋 Starting battery installation
[ 1/9 ] Superuser permissions acquired.
[ 2/9 ] Cloning fan control version of smc
bash: line 30: cd: /Users/secret/.battery-tmp/smc/smc-command: No such file or directory
[ 3/9 ] Building smc from source
[ 4/9 ] Move smc to executable folder
mv: /Users/secret/.battery-tmp/smc/smc-command/smc: No such file or directory
[ 5/9 ] Cloning battery repository
[ 6/9 ] Writing script to /usr/local/bin/battery for user secret
cp: /Users/secret/.battery-tmp/battery/battery.sh: No such file or directory
bash: /Users/secret/.battery-tmp/battery/battery.sh: No such file or directory
[ 7/9 ] Set up visudo declarations
[ 8/9 ] Removing temp folder /Users/secret/.battery-tmp
[ 9/9 ] Removed temporary build files
🎉 Battery tool installed. Type "battery help" for instructions.
Any help is appreciated.
Thanks,
Ruben
What is the issue? (required)
Low resolution menu bar icon being displayed.
What exactly did you do to produce the issue? (required)
Run battery 1.0.7
Expected behavior (required)
High resolution menu bar icon being displayed.
Additional context (optional)
M1 MBP 13"
macOS 13.2 (22D49)
battery 1.0.7
Edit
Seems to only affect the 100% indicator.
Edit 2
Icon missing completely under 20%
Edit 3
Only affects the 100% indicator when enabled and in dark mode.
What is the issue? (required)
Impossible to install the battery software using the option with the dmg file.
What exactly did you do to produce the issue? (required)
After copying the dmg to the application folder,
Launching the dmg for the installation leads to multiples errors :
Then the installation finished and the icon is on the top bar and on the application list, but it is impossible to launch it or setup it.
Expected behavior (required)
I expected has explained in the tutorial to be able to acces to the menu on the top bar and be able to launch the application.
Additional context (optional)
Thanks you a lot for your soft, the dmg file make it very more user friendly.
Respectfully,
Lucas
M1Macbook自启动就会提示出错
再自行到menubar 点击80%就提示OK按钮
After installing 1.0.6 and also upgraded to 1.0.7 the menu bar icon is now white—whereas it used to be black to match the rest of the icons.
What is the issue? (required)
If I reboot (or some other reset situation?) the battery status shows the level of the battery to be maintained has been preserved, but the charging is enabled even if the battery level is much higher until I run battery maintain.
What exactly did you do to produce the issue? (required)
Steps to reproduce the behavior:
Expected behavior (required)
If the battery level is above what the maintenance level is, charging should be disabled.
Hi,
I'm having some issues with both battery GUI and CLI.
On the GUI after installing and downloading the components, I get the following prompt, "Error installing battery limiter: undefined"
With the CLI, whenever I run a command, I get this error.
sudo: smc: command not found sudo: smc: command not found
/us/local/bin/battery: line 110: smc: command not found
It seems like the "maintain" command will cycle the charger in a pretty tight window. I wonder if it could easily enough be made configurable about when to turn the charging on to create a wider cycle. Is that even something that should happen?
if [[ "$battery_percentage" -gt "$setting" && "$is_charging" == "enabled" ]]; then
log "Charge above $setting"
disable_charging
elif [[ "$battery_percentage" -lt "$setting" && "$is_charging" == "disabled" ]]; then
log "Charge below $setting"
enable_charging
fi
I'm thinking something like if -gt $setting disable_charging
, but elif -lt $low_setting enable_charging
Is this something you'd consider? I was told it's good to let the battery drain down by an Apple tech, so occasionally I'd like to set it to go down to 5% then recharge to 80%.
Maybe make the second argument optional, like
battery maintain 80
does the original behavior, but battery maintain 80 10
does the new?
I ran the command battery charge off
and got as a response:
23:22:59 - Enabling battery charging
23:22:59 - Battery at 100% (0:00 remaining), smc charging enabled
23:22:59 - Charging to 80% from 100%
23:22:59 - Enabling battery charging
23:22:59 - Disabling battery charging
23:22:59 - Charging completed at 100%
But the icon of powering is still shown on the menu bar, is it working?
After installing, on first-time launch, I get 2 errors:
Error installing battery limiter: Command failed: ./applet
/bin/sh: ./applet: Bad CPU type in executable
Battery limiter error: Command failed: PATH=$PATH:/usr/local/bin/battery battery status
/bin/bash: battery: command not found
I'm on Ventura 13.0 beta, installed the dmg battery-1.0.3-arm64.dmg
As a user, I want to be able to hide/unhide the menubar icon from the preferences. Now app icon just sits there and takes space. I want to set it and forget it. And I should be able to restore the settings window when launching the app.
Hello, I installed Battery from the Brew repository, I followed all the instructions successfully, but when I try to turn off my laptop's battery charge autonomously it turns back on, and when I let it discharge almost completely when connecting it reloads to 100%. I'm using a MB Pro M1 with Big Sur 11.7.3
I figured out your script uses 'smc' under the hood. The two commands smc -k CH0B -w 02
and smc -k CH0C -w 02
should do the trick and stop the charging, if I understand battery.sh correctly. Running these two commands however don't seem to do anything :(
Can you explain why you think the exact above two commands should stop the charging? Any idea what can be wrong?
Thanks!
I installed Battery v1.0.3 using homebrew and then started the UI. After installing the command line component it shows a dialog saying Battery limiter error: undefined
and after relaunching the UI, it shows a dialog with the error message Error installing battery limiter: undefined
. Not sure what to try to fix this, let me know if you need any other information.
if i set"battery maintain 80", and then i set "battery charge 85", the real battery will not be charged, and the “terminal” get in stuck
After updating the app, when I run battery charging off
, I keep getting the following error,
touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Setting charging to off touch: /Users/xxx/.battery/battery.log: Permission denied touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Enabling battery charging touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Battery at 63% ((no remaining), smc charging enabled 15:47:15 - Disabling battery charging
I am unable to access the .battery folder. I have tried deleting the folder and reinstalling battery as well. Still get the same error.
I also ran sudo battery visudo. Still have the same error.
Thanks for this super handy tool!
Have you considered adding it to Homebrew?
Also, is there an uninstall script? Or at least the steps one would need to follow?
Is your feature request related to a problem? Please describe.
The GUI menu only shows a standard set of options:
Describe the solution you'd like
Let the Top bar menu show the setup done in the CLI.
For example the informations I get with the battery status
command
A nice set of information to be displayed in that menu is:
Describe alternatives you've considered
The alternative is to get those info inside the terminal. Not properly comfortable.
What is the issue? (required)
Homebrew installation doesn't find the new version (1.0.6)
What exactly did you do to produce the issue? (required)
With the battery update
command it keeps the 1.0.5 version
This will run curl -sS https://raw.githubusercontent.com/actuallymentor/battery/main/update.sh | bash
Press any key to continue
🔋 Starting battery update
[ 1/3 ] Cloning battery repository
[ 2/3 ] Writing script to /usr/local/bin/battery
[ 3/3 ] Removed temporary folder
🎉 Battery tool updated.
Battery continues to charge at 100%. Even in iTerm2 when i run battery charging off it says it is disabling battery charging but upon checking it does not say it is not charging anymore
I noticed that in addition to the battery script it is necessary to compile the smc tool (actually it mentioned on the cli installation section)
In Apple Silicon MacBooks only the pro versions have a fan, so what about the MBA?
What is the issue? (required)
I just installed the latest release, 1.0.7, which seems to have introduce a few bugs. When I open the app I get a pop up: "Error installing battery limiter: undefined". The only option is to click OK. Then the menubar icon says "updating." Clicking Disable from the dropdown gives a blank error box pop up, then another one that says "Battery limiter error: Cannot read properties of undefined (reading 'split')", then that same one again. Enabling it again doesn't cause any errors, but also doesn't seem to be working, though maybe I just need to wait a while longer.
I'm on a 2021 16" MBP with the M1 Max, running 12.6.1
Expected behavior (required)
A clear and concise description of what you expected to happen.
Screenshots (optional)
If applicable, add screenshots to help explain your problem. On a Mac you can click control
+command
+shift
+4
to create a screenshot that you can paste into this field with command
+4
.
Error logs
👾 Battery CLI logs:
02/08/23-16:22:06 - Battery at 100% (target 80%)
02/08/23-16:23:06 - Battery at 100% (target 80%)
02/08/23-16:24:06 - Battery at 100% (target 80%)
02/08/23-16:25:06 - Battery at 100% (target 80%)
02/08/23-16:26:06 - Battery at 100% (target 80%)
02/08/23-16:27:06 - Battery at 100% (target 80%)
02/08/23-16:28:06 - Battery at 100% (target 80%)
02/08/23-16:29:07 - Battery at 100% (target 80%)
02/08/23-16:30:07 - Battery at 100% (target 80%)
02/08/23-16:31:07 - Battery at 100% (target 80%)
02/08/23-16:32:07 - Battery at 100% (target 80%)
02/08/23-16:33:07 - Battery at 100% (target 80%)
02/08/23-16:34:07 - Battery at 100% (target 80%)
02/08/23-16:35:07 - Battery at 100% (target 80%)
02/08/23-16:36:07 - Battery at 100% (target 80%)
02/08/23-16:37:07 - Battery at 100% (target 80%)
02/08/23-16:38:08 - Battery at 100% (target 80%)
02/08/23-16:39:08 - Battery at 100% (target 80%)
02/08/23-16:40:08 - Battery at 100% (target 80%)
02/08/23-16:41:08 - Battery at 100% (target 80%)
02/08/23-16:42:08 - Battery at 100% (target 80%)
02/08/23-16:43:08 - Battery at 100% (target 80%)
02/08/23-16:44:08 - Battery at 100% (target 80%)
02/08/23-16:45:08 - Battery at 100% (target 80%)
02/08/23-16:46:08 - Battery at 100% (target 80%)
02/08/23-16:47:08 - Battery at 100% (target 80%)
02/08/23-16:48:09 - Battery at 100% (target 80%)
02/08/23-16:49:09 - Battery at 100% (target 80%)
02/08/23-16:50:09 - Battery at 100% (target 80%)
02/08/23-16:51:09 - Battery at 100% (target 80%)
02/08/23-16:52:09 - Battery at 100% (target 80%)
02/08/23-16:53:09 - Battery at 100% (target 80%)
02/08/23-16:54:09 - Battery at 100% (target 80%)
02/08/23-16:55:09 - Battery at 100% (target 80%)
02/08/23-16:56:09 - Battery at 100% (target 80%)
02/08/23-16:57:09 - Battery at 100% (target 80%)
02/08/23-16:58:10 - Battery at 100% (target 80%)
02/08/23-16:59:10 - Battery at 100% (target 80%)
02/08/23-17:00:10 - Battery at 100% (target 80%)
02/08/23-17:01:10 - Battery at 100% (target 80%)
02/08/23-17:02:10 - Battery at 100% (target 80%)
02/08/23-17:03:10 - Battery at 100% (target 80%)
02/08/23-17:04:10 - Battery at 100% (target 80%)
02/08/23-17:05:10 - Battery at 100% (target 80%)
02/08/23-17:06:10 - Battery at 100% (target 80%)
02/08/23-17:07:10 - Battery at 100% (target 80%)
02/08/23-17:08:10 - Battery at 100% (target 80%)
02/08/23-17:09:11 - Battery at 100% (target 80%)
02/08/23-17:10:11 - Battery at 100% (target 80%)
02/08/23-17:11:11 - Battery at 100% (target 80%)
02/08/23-17:12:11 - Battery at 100% (target 80%)
02/08/23-17:13:11 - Battery at 100% (target 80%)
02/08/23-17:14:11 - Battery at 100% (target 80%)
02/08/23-17:15:11 - Battery at 100% (target 80%)
02/08/23-17:16:12 - Battery at 100% (target 80%)
02/08/23-17:17:12 - Battery at 100% (target 80%)
02/08/23-17:18:12 - Battery at 100% (target 80%)
02/08/23-17:19:12 - Battery at 100% (target 80%)
02/08/23-17:20:12 - Battery at 100% (target 80%)
02/08/23-17:21:12 - Battery at 100% (target 80%)
02/08/23-17:22:12 - Battery at 100% (target 80%)
02/08/23-17:23:12 - Battery at 100% (target 80%)
02/08/23-17:24:13 - Battery at 100% (target 80%)
02/08/23-17:25:13 - Battery at 100% (target 80%)
02/08/23-17:26:13 - Battery at 100% (target 80%)
02/08/23-17:27:13 - Battery at 100% (target 80%)
02/08/23-17:27:17 - Triggering discharge to 80 before enabling charging limiter
02/08/23-17:27:17 - Discharging to 80% from 100%
02/08/23-17:27:17 - 🔽🪫 Enabling battery discharging
02/08/23-17:27:17 - Battery at 100% (target 80%)
02/08/23-17:28:13 - Battery at 100% (target 80%)
02/08/23-17:28:17 - Battery at 100% (target 80%)
02/08/23-17:28:53 - Triggering discharge to 80 before enabling charging limiter
02/08/23-17:28:53 - Discharging to 80% from 100%
02/08/23-17:28:53 - 🔽🪫 Enabling battery discharging
02/08/23-17:28:53 - Battery at 100% (target 80%)
02/08/23-17:29:13 - Battery at 100% (target 80%)
02/08/23-17:29:17 - Battery at 100% (target 80%)
02/08/23-17:29:53 - Battery at 100% (target 80%)
02/08/23-17:30:13 - Battery at 100% (target 80%)
02/08/23-17:30:17 - Battery at 100% (target 80%)
02/08/23-17:30:53 - Battery at 100% (target 80%)
02/08/23-17:31:13 - Battery at 100% (target 80%)
02/08/23-17:31:18 - Battery at 100% (target 80%)
02/08/23-17:31:32 - Triggering discharge to 80 before enabling charging limiter
02/08/23-17:31:32 - Discharging to 80% from 100%
02/08/23-17:31:32 - 🔽🪫 Enabling battery discharging
02/08/23-17:31:32 - Battery at 100% (target 80%)
02/08/23-17:31:54 - Battery at 100% (target 80%)
02/08/23-17:32:13 - Battery at 100% (target 80%)
02/08/23-17:32:18 - Battery at 100% (target 80%)
02/08/23-17:32:32 - Battery at 100% (target 80%)
02/08/23-17:32:46 - Triggering discharge to 80 before enabling charging limiter
02/08/23-17:32:46 - Discharging to 80% from 100%
02/08/23-17:32:46 - 🔽🪫 Enabling battery discharging
02/08/23-17:32:46 - Battery at 100% (target 80%)
02/08/23-17:32:54 - Battery at 100% (target 80%)
02/08/23-17:33:13 - Battery at 100% (target 80%)
02/08/23-17:33:18 - Battery at 100% (target 80%)
02/08/23-17:33:32 - Battery at 100% (target 80%)
🖥️ Battery GUI logs:
Refreshing tray icon...
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status
Limiter status message:
02/08/23-17:32:45 - Battery at 100% (0:00 remaining), smc charging enabled
Refreshing interface update timer
Generate app menu percentage: 100
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Display percentage 95 based on 100
Resetting interface timer speed
Get inactive logo for 100
Setting interface refresh speed to 10 minutes
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Refreshing tray icon...
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Limiter status message:
02/08/23-17:32:45 - Battery at 100% (0:00 remaining), smc charging enabled
Refreshing interface update timer
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Resetting interface timer speed
Get inactive logo for 100
Generate app menu percentage: 100
Display percentage 95 based on 100
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Setting interface refresh speed to 10 minutes
Enable limiter
Display percentage 80 based on 80
Get active logo for 80
Refresh logo for percentage 80, force active
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery maintain 80
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Refreshing tray icon...
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Generate app menu percentage: 100
Get active logo for 100
Resetting interface timer speed
Limiter status message:
02/08/23-17:32:46 - Battery at 100% (0:00 remaining), smc charging enabled
02/08/23-17:32:46 - Your battery is currently being maintained at 80%
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Refreshing interface update timer
Display percentage 95 based on 100
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Setting interface refresh speed to 10 minutes
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Refreshing tray icon...
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status
Generate app menu percentage: 100
Resetting interface timer speed
Limiter status message:
02/08/23-17:32:46 - Battery at 100% (0:00 remaining), smc charging enabled
02/08/23-17:32:46 - Your battery is currently being maintained at 80%
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Display percentage 95 based on 100
Get active logo for 100
Refreshing interface update timer
Setting interface refresh speed to 10 minutes
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
enable_battery_limiter exec complete
Interface enabled limiter, percentage remaining: 100
Refresh logo for percentage 100, force active
Get active logo for 100
Display percentage 95 based on 100
Refreshing tray icon...
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
Generate app menu percentage: 100
Get active logo for 100
Refreshing interface update timer
Executing PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew:/usr/bin/ battery status_csv
Display percentage 95 based on 100
Resetting interface timer speed
Limiter status message:
02/08/23-17:32:48 - Battery at 100% (0:00 remaining), smc charging enabled
02/08/23-17:32:48 - Your battery is currently being maintained at 80%
Setting interface refresh speed to 10 minutes
Battery status:
{"percentage":"100","remaining":"0:00","charging":true,"discharging":false,"maintain_percentage":"80","battery_state":"100% (0:00 remaining)","daemon_state":"smc charging enabled"}
📁 Config folder details:
total 152
drwxr-xr-x 6 alexander staff 192B Feb 8 17:32 .
drwxr-x---+ 39 alexander staff 1.2K Feb 8 17:33 ..
-rwxr-xr-x 1 alexander staff 25K Feb 8 17:33 battery.log
-rw-r--r-- 1 alexander staff 6B Feb 8 17:32 battery.pid
-rw-r--r-- 1 alexander staff 37K Feb 8 17:32 gui.log
-rw-r--r-- 1 alexander staff 3B Feb 8 17:32 maintain.percentage
⚙️ Battery data:
02/08/23-17:33:38 - Battery at 100% (0:00 remaining), smc charging enabled
02/08/23-17:33:38 - Your battery is currently being maintained at 80%
Battery CLI utility v1.0.1
Additional context (optional)
Add any other context about the problem here.
Hi, I wonder if it would be possible to have an ability to top-up (charge to 100%), but still keep the original maintenance setting. Currently, if I set battery maintain 80
and before business trip I do battery charge 100
, it removes the 80% maintenance level. It'd be ideal if that maintenance level is kept, so that I don't forget about it.
Thanks for your scripts!
But after I run battery charging off
the battery icon does not have any changes...😢
sudo
is required to run most battery commands. Currently the output without sudo is:
12:14:12 - Starting battery maintenance at 75%
/usr/local/bin/battery: line 305: /Users/tok/.battery/battery.pid: Permission denied
/usr/local/bin/battery: line 307: /Users/tok/.battery/maintain.percentage: Permission denied
12:14:12 - Maintaining battery at 75%
It is ambiguous wether the command succeeded. I'm assuming superuser permissions are required, otherwise less permissions would be less secure. Code to check for the UID 0 bit should be added, and a help message should be printed.
I may be happy to open a PR when I have time.
Thanks for your work.
I am keeping on the macOS "Optimized battery charging" now. But everyday at 14:30 the battery is charging, no matter the battery level was.
Some people like to use their MacBooks as desktops, and for those types of people an option to further decrease the limit to 50-60% might not be a bad idea. Others frequently keep it plugged in but also travel a lot with it, so for those types a 70% limit may make more sense. Thoughts on implementing the aforementioned functionality? (As it stands, battery can only set the limit to 80%)
I looked hard and couldn't find anything anywhere that explains what happens when using this program when you sleep your Mac. Also, I don't see any mention of what Apple's settings should be set to when using this app.
Hello :) I added this code to the beginning of the charging routine in order to prevent the program to run if the Mac is not plugged into power:
power_plugged_in=pmset -g batt | tail -n1 | awk {print $4}
if [[ "$power_plugged_in" == "discharging;" ]]; then
exit 0
fi
If I run it from the terminal, it works perfectly fine (it just stops if not plugged into power). However, I am struggling to add it as a log in item using automator. I tried usr/local/bin/battery charge 80
and I used "as arguments" and added it as a log in item. However, after the startup it keeps charging, even though testing in automator shows the correct result. Any ideas on that? Thanks a lot in advance!!
I saw battery visudo in the Usage, but I don't know what is the use of this function, can you tell me what it does?
battery visudo
instructions on how to make which utility exempt from sudo, highly recommended
MacOS Ventura, I need to keep the lid open for it work correctly.
I tried installing it from the source [the standard installation (brew and DMG) is broken, doesn't install SMC (typo in install command line), and permission problems in battery.log file]
disabled charging (battery charging off) - Nothing happens even though the logs say it worked.
This question might seem a bit silly, but hear me out. So I read the code and when battery maintain
is called in turn
nohup battery maintain_synchronous $setting >> $logfile &
is called.
Now this spawns a process which writes to the log file. So far so good. Now what happens when I reboot? Then the LaunchAgent gets executed which calls
/usr/local/bin/battery maintain_synchronous recover
spawning a process, which is NOT piped to the logfile. (Edit: but it seems easy to do, cf. ServerFault Answer) But now the strangest things happen. There is stuff written to the logfile on reboot anyway. I rebooted and got
18:17:57 - Charging to and maintaining at 79% from 91%
00:41:35 - Charge below 79
00:41:35 - Enabling battery charging
sudo: you do not exist in the passwd database
sudo: you do not exist in the passwd database
I am totally confused for three reasons:
battery status
it behaves correctly:❯ battery status
00:45:13 - Battery at 87% (11:33 remaining), smc charging disabled
00:45:13 - Your battery is currently being maintained at 79%
sudo: you do not exist in the passwd database
come from?So all in all it does seem to behave correctly in maintaining the charge limit, but the logging is odd (and I cannot fathom how they even happen), the logs are false and there is a sudo error in them.
thanks in advance, I will provide you all further info you need :)
Further info: I did the command-line only installation and have an M1 Pro machine from 2021.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.