zackelia / bclm Goto Github PK
View Code? Open in Web Editor NEWmacOS command-line utility to limit max battery charge
License: MIT License
macOS command-line utility to limit max battery charge
License: MIT License
it raises KeyNotFound(code: "BCLM") error on the new MacBook Pro with M1 chip running Big Sur v11.1
Hi, I don't quite understand how it extend battery lifespan.
It says 40-80 is best range for charging and using, but didn't say if battery always stay on 80 with charger all day will be good.
I also found the new battery health management of macOS, will discharge battery to 90, then charge it to full, then discharge, then charge... I think it try to keep battery in a flow state, and prevent battery be always full. So, will BCLM will do the same thing, or just keep battery on 80?
I've set bclm at 80 and set persist.
BCLM read is at 80.
Charging goes to 100%. Tested 2 times.
Is it a bug for 10.14.6 ?
FYI, doesn't seem to work on my 2008 aluminum unibody Macbook (with patched OS 10.12.6 High Sierra):
bclm read
gives
keyNotFound(code: "BCLM")
bclm read --version
gives
[0.0.4]
Meanwhile, I also tried OSX Battery Charge Limit and it returned the error
ERROR: SMC out parse failed
valid " BCLM [ui8 ] 60 (bytes 3c)"
current " BCLM [ ] no data"
On older MacBooks that use the MagSafe charger, the LED turns green if it has finished charging. Just changing the BCLM value does not influence the MagSafe LED color.
There is a value in the SMC called BFCL
(Battery Final Charge Level) that holds the value for when the LED color should change to green. By default, for the machines that have this value, the value is 5 less than the BCLM
. So for example, if you were to set the BCLM
to 65%, then you would set the BFCL
to 60%. This follows what Apple does because its default value is 5f
, or 95%.
Please add this option for changing this value as well.
PS I've added this ability in https://github.com/godly-devotion/charge-limiter as well for reference.
New machine here... nothing in /usr/local
. So when I ran through the instructions, I end up with
/usr/loca/bin
...where bin
is in fact bclm
.
A simple oversight, with an easy fix; make sure the parent directory exists.
Downloaded and installed from release as outlined by readme.md
$sudo bclm write 80
keyNotFound(code: "BCLM")
Happy to share more info. Thanks for this releasing this tool. Perhaps the SMC keys have changed around..
My apple watch is not charging above 80%. It would seem that this utility is causing the apple watch to be limited to the same battery as my MacBook air m1
Hi, I realize this isn't an issue for this app, but I've looked online and couldn't find this answer
How can I write the BCLM value to the SMC without using any 3rd party apps? Are there a set of terminal commands that will achieve the same thing? (And also allow reading the value, and reading/writing BFCL)
Thanks
I've "installed" via the sudo cp bclm /usr/local/bin
method.
I've set the charge level: sudo bclm write 80
I've confirmed the charge level: bclm read
==> 80
I've set persistence: sudo bclm persist
I've confirmed (using LaunchControl
) that the com.zackelia.bclm.plist
is loaded & running: /usr/local/bin/bclm write 80
I disabled Apple's native "Optimized Battery Charging" before installing bclm
(REF #32 )
Earlier tonight, I had to remove my Mac from the charger for a while in the lab. The charge level had declined to 77%
during that time. When I plugged the charger in again, I expected it to charge up to 80%
- but it did not do this. Instead, hours later, it is still sitting at 77%
.
Is this the expected behavior? What should I do to return the "persistence" to the set value of 80%
??
UPDATE/FWIW: I've discovered that following a Restart, the bclm
-controlled battery charging to the 80% level is resumed.
You're missing something here, dude.
Looks like updating to Monterey Beta broke bclm. In terminal it's reading that its set but battery is charging to 100%.
Hi zackelia,
I am using Hackintosh on my T460s with v0.0.4, but I got the KeyNotFound(code: "BCLM") error.
Could you please tell me some details about how to check the SMC status from .kext files.
Thanks.
Hi,
The utility works as expected, but doesn't persist on launch.
I've set the value at 80, but when I run bclm read after a reboot, I get 100.
This is on a mid 2012 MacBook Pro running Catalina.
I checked for the launch status code of the plist file and got this:
sudo launchctl list | grep com.zackelia.bclm.plist
Is this a SIGKILL? I did get a popup at boot, asking since BCLM was downloaded from the internet, should I allow it to run? I clicked Allow. And if it hadn't run, I wouldn't expect to get an entry in launchctrl list anyway... confusing, eh?
Tried it several times, same result.
I'm using a MacBook Air (Retina, 13-inch, 2018) which is running macOS Sonoma 14.3.1.
Persisting on my MacBook doesn't work. After restarting or waking up my MacBook from sleeping, the charging limit will change back to 100 even though I've persisted it using the command sudo balm persist
before shutting down or sleeping. I can make sure that the command works properly because there is no error printed on the terminal while running this command. Also, when I try to run this command twice, I will get an output Already persisting!
. Plus, I can see a notification of adding login item after running this command. So it seems that the command is running properly but the persisting doesn't work.
Could anyone please give some advice on the solution of issue?
Big Sur will only charge my computer to 80% until it feels necessary.
What happens when setting BCLM to 60?
Hey there,
I use your extension on both of my other MacBooks and just want to say great job. Simple and easy to use.
I just got an M1 MBA and would love to use it as well but am having some trouble..
So far, I've:
/opt/homebrew
brew tap zackelia/formulae
sudo bclm write 72
i get the error:
sudo: unable to execute /opt/homebrew/bin/bclm: Bad CPU type in executable
Any pointers in the right direction? Happy to help get M1 support running with your package in any way :)
There is a buzzing sound when the MacBook stops charging, but there is no sound when it is charging.
MacBook Pro M1 Max, 14.2.1
Although it was not known before, there is now a way to support Apple Silicon based MacBooks due to the hard work over at another similar project.
Code: AppHouseKitchen/AlDente-Charge-Limiter@77119a1#diff-49a0a057547a2cf2e243b33525c55136dd7c41fc9fb133bed10746e349bda1ff
Discussion: AppHouseKitchen/AlDente-Charge-Limiter#52
Hopefully, it can eventually be implemented in bclm
as well.
Homebrew Services is a way to manage background services (using launchctl
) for homebrew formulas. Using it to manage persist
feature might be a good choice.
Hi,
I believe my /usr/local/bin directory was non-existent because my laptop is new.
After running sudo make install
, the /usr/local/bin IS the bclm binary and not a directory anymore.
I can run /usr/local/bin, literally. So I think this should be checked, and the directory should be created if it does not exist
kudos to you for making a very nice clean bit of code to do something super useful!!!
I am just experimenting with it for the first time and it does seem to work well on my m1 macbook air.
what happens if my battery is currently at 100% and i enter "sudo bclm write 80" in terminal? will the macbook just switch to battery power if it is currently plugged in? I suppose that is the behavior to expect but my idea is to just say that is what will happen somewhere in readme or in the terminal when you type "bclm"
Hi, thanks so much for putting up this project. So relevant nowadays it's hard to believe a tool like this didn't exist for older OS X versions.
I'm trying to run the binary on Mavericks (10.9.5) and I'm getting the following error:
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /usr/local/bin/bclm
Reason: image not found
Trace/BPT trap: 5
Do you know what's happening?
During my use of blcm, I have been very confused about how to make my battery level drop from 100 to 80. It seems to only pause charging. I really need a way to disconnect the power supply from the battery adapter on an Intel MacBook Pro. Do you have any solutions? I would be very grateful.
any thoughts?
bclm read
keyNotFound(code: "BCLM")
sudo bclm persist
keyNotFound(code: "BCLM")
MacBook Pro
14-inch, 2021
Distro: OS X 13.5.1
CPU: Apple M1 Pro
Memory: 32 GB
Hey there,
Just wondering if this is possible. I didn't see anything in the README mentioning it, so I thought it couldn't hurt to ask
Cheers!
On MacBook Pro with M3 Max, the charge indicator light will remain orange even if the battery is already charged to the set percentage.
Unable to set limit with bclm on MacBook Pro 16" M1 due to:
➜ ~ bclm read
keyNotFound(code: "BCLM")
➜ ~ sudo bclm write 67
Password:
keyNotFound(code: "BCLM")
If I # bclm write 100
, will the system feature continues to work?
When running bclm v.0.0.3 there is an following error output:
sudo bclm write 75
keyNotFound(code: "BFCL")
Running on USB-C Macbook Air 2019. It seems that Macbooks with USB-C charging doesn't have BFCL in SMC.
BTW: Thank you for this great and dead simple tool.
keyNotFound(code: "BCLM")
Please update BCLM to Mac M1 version, thanks so much.
Hello :)
Been using this on my old MacBook Air which runs Yosemite. Works flawlessly.
Yesterday, I installed High Sierra on my macbookpro13,1 from 2013. On this machine, I get this error when trying to use bclm:
> sudo Downloads/bclm --help
dyld: Symbol not found: _$s17StringLiteralTypes013ExpressibleByaB0PTl
Referenced from: /Users/daniel/Downloads/bclm
Expected in: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in /Users/daniel/Downloads/bclm
[1] 31538 abort A=`alias` sudo env Downloads/bclm --help
I do have the file in question (Xcode 10.1):
> stat /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
File: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
Size: 6544080 Blocks: 4832 IO Block: 4096 regular file
Device: 1,4 Inode: 3177401 Links: 3
Access: (0755/-rwxr-xr-x) Uid: ( 501/ daniel) Gid: ( 20/ staff)
Access: 2023-01-05 10:40:13.000000000 +0100
Modify: 2018-10-20 03:23:30.000000000 +0200
Change: 2023-01-04 15:27:38.000000000 +0100
Birth: 2018-10-20 03:23:30.000000000 +0200
A little odd that it works on Yosemite, but not High Sierra? (I'm getting used to pretty much nothing working anymore on Yosemite XD)
Even after setting the bclm
utility to launch at login, it doesn't seem to be restoring the BFCL property correctly. The MagSafe charger light is orange and it requires re running the utility to update it again. The BCLM property seems to be fine but that could be because it doesn't reset that value at reboot as easily, which could mean that its not running the command correctly at login.
macOS Mojave 10.14.6
MacBook Pro 13" Early 2015
Hello,
I have MacBook Pro 16 M2 Max. Everything was okay before I updated MacOS to Sonoma 14.4 (23E214).
Since then, bclm stopped working. I tried to upgrade it using brew, but, unfortunately, it didn't help.
macOS version: 10.14.6
MacBook Pro 13-inch, 2018
Hello! I am really interested in this project!
However, this error shows up when running the bclm
command in terminal after installing with brew
or from release.
I am running MacOS 10.13.6, so I can't build it from source.
dyld: Symbol not found: _$s17StringLiteralTypes013ExpressibleByaB0PTl
Referenced from: /usr/local/bin/bclm
Expected in: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in /usr/local/bin/bclm
[1] 6923 abort bclm
Can provide any additional info if necessary.
Thanks for the project.
But when I want to stop it and restore MAC's defaults, what should I do?
Just
sudo bclm write 100 ???
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.