Git Product home page Git Product logo

osx_battery_charge_limit's Introduction

Intel only Macbook (OSX) limit maximum battery charge.

Li-ion and polymer batteries (like the one in your MacBook) last the longest when operating between 30 and 80 percent. Keeping your battery at 100% at all times can shorten the lifespan of your notebook significantly. More information can be found here: https://batteryuniversity.com/learn/article/how_to_charge_when_to_charge_table

Script info

This is script for changing maximum battery charge value on macbook by setting SMC's value. It uses smc-command binary from smcFanControl project for SMC keys access smcFanControl.

Script changes SMC key "BCLM" (Battery control level maximum). Script sets maximum battery charge percent value from 20% to 100%.

You can check real battery charge level with coconutbattery. MacOS shows charge approximately 3-5% greater than real value.

You can reset macbook's SMC for rollback script changes in case of some problems.

Tests

Tested on:

  • Macbook Pro 13 (mid 2020, 2 ports), OSX Catalina (10.15.5)
  • Macbook Pro 13 (mid 2019, 4 ports), OSX Catalina (10.15.5, 10.15.6)
  • Macbook Air 13 (mid 2011), OSX High Sierra

Requirements

All commands must be written in Terminal application step-by-step

# 1. Install command-line tools
xcode-select --install

# 2. Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# 3. Install Python3
brew install python3

Usage examples

Highly recomended turn off OSX Catalina 10.15.5 system battery care function before set limit value! Reboot is recommended after changing value. System update can reset SMC, and you will need to start script to set limit again.

All commands must be called in osx_battery_charge_limit folder. Change folder example:

cd ~/Downloads/osx_battery_charge_limit/

Usage:

# Get current charge limit
python3 main.py
python3 main.py -c

# Set maximum charge level at 65%
sudo python3 main.py -s 65

# Reset maximum charge level to 100%
sudo python3 main.py -r

Sometimes homebrew's folders owner need to be fixed in case of some freezing on reboot.

sudo chown -R "$USER":admin /usr/local/*

Warning!

I do not take any responsibility for any sort of damage in result of using this tool! Alltough this had no negative side effects for me, scripts still taps in some very low level system functions that are not ment to be tampered with. Use it at your own risk!

Alternatives with GUI:

Alternatives without GUI:

Other references:

osx_battery_charge_limit's People

Contributors

devnulpavel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

osx_battery_charge_limit's Issues

App

Can you put this in a downloadable app? Because I don't use x-code and my space is small in my MBA 2011.

Hackintosh support

Hello!
Thanks for great tool!
Is there a way to support hackintosh based systems that uses VirtualSMC?

For now I receive an error

python3 main.py
ERROR: SMC out parse failed
valid "  BCLM  [ui8 ]  60 (bytes 3c)"
current "  BLCM  [     ]  no data"

Apple M1 support

Any chance your tool may work (now or in the future) for the new M1 MacBook Air?
thank you
Lukas

No BCLM entry on MBP 13 2020, Big Sur 11.2.2?

Hello,

Thank you for your work on this tool, it is exactly what I am looking for.
However, I tried to run your script with sudo python3 main.py -s 65 but errors are produced.

ERROR: SMC out parse failed
valid "  BCLM  [ui8 ]  60 (bytes 3c)"
current "  BCLM  [    ]  no data"

I am using a 13-inch MBP, 2020 with M1 chip and Big Sur 11.2.2 and python 3.8.6.
The repo is cloned to ~/osx_battery_charge_limit and the commands were ran from that directory.

sudo ./smc-command_from_fan_control/smc -l | grep "BCLM" returns no output was well, my complete output of smc -l is here: https://pastebin.com/ehGgH95J
Am I using the script wrong? Has the BCLM key been removed?

Working on El Capitan?

Hi Pavel,

since AlDente is not working on older macOS-Versions, I tried your script on my old MacBook Pro running El Capitan.
But I receive an error message every time I try to run the script:

ERROR: SMC out parse failed
valid " BCLM [ui8 ] 60 (bytes 3c)"
current " BCLM [ ] no data"

Am I doing something wrong?

getting error current " BCLM [ ] no data" retina 2012

I get

ERROR: SMC out parse failed
valid " BCLM [ui8 ] 60 (bytes 3c)"
current " BCLM [ ] no data"

and can't set it, give same error as above
in efi I can see the value, but it does not show data also
76: key 'BCLM' size 1, type 'ui8 ', attrib 0xD0

macbookpro10,1 2012 retina
any ideas thx

Does it work on Linux?

Hi guys, I have an old MacBook Pro 7.1 running Ubuntu and I care to my battery lifespan. This project works on Linux? Do you guys know some that works?

System:
  Kernel: 5.15.0-46-generic x86_64 bits: 64 Desktop: MATE 1.26.0
    Distro: Ubuntu 22.04.1 LTS (Jammy Jellyfish)
Machine:
  Type: Laptop System: Apple product: MacBookPro7,1 v: 1.0
    serial: <superuser required>
  Mobo: Apple model: Mac-F222BEC8 serial: <superuser required> UEFI: Apple
    v: 68.0.0.0.0 date: 06/13/2019
Battery:
  ID-1: BAT0 charge: 28.1 Wh (74.7%) condition: 37.6/62.9 Wh (59.7%)
CPU:
  Info: dual core model: Intel Core2 Duo P8600 bits: 64 type: MCP cache:
    L2: 3 MiB
  Speed (MHz): avg: 797 min/max: 798/2394 cores: 1: 796 2: 799
Graphics:
  Device-1: NVIDIA MCP89 [GeForce 320M] driver: nvidia v: 340.108
  Device-2: Apple Built-in iSight type: USB driver: uvcvideo
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: nvidia
    gpu: nvidia resolution: 1280x800~60Hz
  OpenGL: renderer: GeForce 320M/integrated/SSE2 v: 3.3.0 NVIDIA 340.108
Audio:
  Device-1: NVIDIA MCP89 High Definition Audio driver: snd_hda_intel
  Sound Server-1: ALSA v: k5.15.0-46-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: yes
  Sound Server-3: PipeWire v: 0.3.48 running: yes
Network:
  Device-1: Broadcom BCM4322 802.11a/b/g/n Wireless LAN driver: wl
  IF: wlp2s0 state: up mac: <filter>
  Device-2: Broadcom NetXtreme BCM5764M Gigabit Ethernet PCIe driver: tg3
  IF: enp3s0 state: down mac: <filter>
  IF-ID-1: docker0 state: down mac: <filter>
Bluetooth:
  Device-1: Apple Bluetooth Host Controller type: USB driver: btusb
  Report: hciconfig ID: hci0 state: up address: <filter> bt-v: 1.2
Drives:
  Local Storage: total: 111.79 GiB used: 26.66 GiB (23.8%)
  ID-1: /dev/sda vendor: Gigabyte model: GP-GSTFS31120GNTD size: 111.79 GiB
Partition:
  ID-1: / size: 108.98 GiB used: 26.65 GiB (24.5%) fs: ext4 dev: /dev/sda2
  ID-2: /boot/efi size: 511 MiB used: 5.3 MiB (1.0%) fs: vfat
    dev: /dev/sda1
Swap:
  ID-1: swap-1 type: file size: 4.07 GiB used: 1.26 GiB (30.9%)
    file: /swapfile
Sensors:
  Missing: Required tool sensors not installed. Check --recommends
Info:
  Processes: 245 Uptime: 14h 4m Memory: 3.58 GiB used: 2.83 GiB (79.1%)
  Shell: Bash inxi: 3.3.13

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.