• Stars
    star
    3,384
  • Rank 13,217 (Top 0.3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLI/GUI for managing the battery charging status for Apple silicon (M1, M32, M3) Macs

Battery charge limiter for Apple Silicon Macbook devices

This tool makes it possible to keep a chronically plugged in Apple Silicon Macbook at 80% battery, since that will prolong the longevity of the battery. It is free and open-source and will remain that way.

Want to know if this tool does anything or is just a placebo? Read this excellent article. TL;DR: keep your battery cool, keep it at 80% when plugged in, and discharge it as shallowly as feasible.

Requirements

This is an app for Apple Silicon Macs. It will not work on Intel macs. Do you have an older Mac? Consider the free version of the Al Dente software package. It is a good alternative and has a premium version with many more features.

Installation

The first time you open the app, it will ask for your administator password so it can install the needed components. Please note that the app:

  • Discharges your battery until it reaches 80%, even when plugged in
  • Disables charging when your battery is above 80% charged
  • Enabled charging when your battery is under 80% charged
  • Keeps the limit engaged even after rebooting
  • Keeps the limit engaged even after closing the tray app
  • Also automatically installs the battery command line tool. If you want a custom charging percentage, the CLI is the only way to do that.

Do you have questions, comments, or feature requests? Open an issue here or Tweet at me.


πŸ–₯ Command-line version

If you don't know what a "command line" is, ignore this section. You don't need it.

The GUI app uses a command line tool under the hood. Installing the GUI automatically installs the CLI as well. You can also separately install the CLI.

The CLI is used for managing the battery charging status for Apple Silicon Macbooks. Can be used to enable/disable the Macbook from charging the battery when plugged into power.

Installation

One-line installation:

curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash

This will:

  1. Download the precompiled smc tool in this repo (built from the hholtmann/smcFanControl repository)
  2. Install smc to /usr/local/bin
  3. Install battery to /usr/local/bin

Usage

Example usage:

# This will enable charging when your battery dips under 80, and disable it when it exceeds 80
battery maintain 80

After running a command like battery charging off you can verify the change visually by looking at the battery icon:

Battery not charging

After running battery charging on you will see it change to this:

Battery charging

For help, run battery without parameters:

Battery CLI utility v1.0.1

Usage:

  battery status
    output battery SMC status, % and time remaining

  battery maintain LEVEL[1-100,stop]
    reboot-persistent battery level maintenance: turn off charging above, and on below a certain value
    eg: battery maintain 80
    eg: battery maintain stop

  battery charging SETTING[on/off]
    manually set the battery to (not) charge
    eg: battery charging on

  battery adapter SETTING[on/off]
    manually set the adapter to (not) charge even when plugged in
    eg: battery adapter off

  battery charge LEVEL[1-100]
    charge the battery to a certain percentage, and disable charging when that percentage is reached
    eg: battery charge 90

  battery discharge LEVEL[1-100]
    block power input from the adapter until battery falls to this level
    eg: battery discharge 90

  battery visudo
    ensure you don't need to call battery with sudo
    This is already used in the setup script, so you should't need it.

  battery update
    update the battery utility to the latest version

  battery reinstall
    reinstall the battery utility to the latest version (reruns the installation script)

  battery uninstall
    enable charging, remove the smc tool, and the battery script

FAQ & Troubleshooting

Why does this exist?

I was looking at the Al Dente software package for battery limiting, but I found the license too limiting for a poweruser like myself.

I would actually have preferred using Al Dente, but decided to create a command-line utility to replace it as a side-project on holiday. A colleague mentioned they would like a GUI, so I spend a few evenings setting up an Electron app. And voila, here we are.

"It's not working"

If you used one of the earlier versions of the battery utility, you may run into path/permission issues. This is not your fault but mine. To fix it:

sudo rm -rf ~/.battery
binfolder=/usr/local/bin
sudo rm -v "$binfolder/smc" "$binfolder/battery"

Then reopen the app and things should work. If not, open an issue and I'll try to help you fix it.

A note to Little Snitch users

This tool calls a number of urls, blocking all of them will only break auto-updates.

  1. unidentifiedanalytics.web.app is a self-made app that tracks app installations, I use it to see if enough people use the app to justify spending time on it. It tracks only how many unique ip addresses open the app.
  2. icanhazip.com is used to see if there is an internet connection
  3. github.com is used both as a liveness check and as the source of updates for the underlying command-line utility
  4. electronjs.org hosts the update server for the GUI

All urls are called over https and so not leak data. Unidentified Analytics keeps track of unique ip addresses that open the app, but nothing else.

How do I support this project?

Do you know how to code? Open a pull-request for a feature with the label help wanted (PR welcome).

Do you have an awesome feature idea? Add a feature request

Do you just want to keep me motivated to update the app? Tweet at me

More Repositories

1

wintertime-mac-background-freezer

Freeze apps running in the background (as in: not explicitly foreground) to save battery.
JavaScript
114
star
2

MailChimp-API-v3.0-PHP-cURL-example

This is a Mailchimp API 3 example using PHP and cURL. I made this for a client, took a while because their documentation is horrible, though maybe they improved it by the time you read this.
PHP
52
star
3

adblock

Blocks ad & malware URLs system wide in all applications, not just in the browser. Loads known advertising and malware hosts to the Mac OS X /etc/hosts file. This results in an incapacity to load these hosts, blocking ads in all programs system wide.
JavaScript
16
star
4

signer

A web based signing utility for crypto and blockchain wallets.
JavaScript
13
star
5

marvin

Marvin is a search engine powered by OpenAI's GPT
JavaScript
8
star
6

bluetack-ip-blacklist-generator

Get blocklist ip list and add those to the routing table of linux systems.
Shell
5
star
7

openvpn-bash-setup-script

Setting up OpenVPN on Debian based systems like ubuntu
Shell
5
star
8

blockchains-are-mostly-useless

Understanding the limited uses of blockchains
JavaScript
5
star
9

check-broken-links

NPM module that crawls a list of urls, and then checks those crawled links for viability. Intended use case: mocha tests.
JavaScript
4
star
10

beaconpulse

A daily push notification with the ETH winnings of your Ethereum Beaconchain validator.
JavaScript
4
star
11

Setup-Script-Nginx-Pagespeed-PHP7-Mariadb

Powerful server setup script for nginx with PHP7, MariaDB and Google's NginX Pagespeed Module
Shell
4
star
12

setup-script-LEMH-stack

Powerful server setup with Nginx (compiled with mod_pagespeed), MariaDB, HHVM and a PHP5-FPM fallback.
Shell
4
star
13

bidding-snipe-script

Chrome extension that automatically bids on auctions
JavaScript
3
star
14

ethereum-windows-mining-script

Attempting to make a one-run script
Batchfile
3
star
15

chia-plotting-automation

Shell
3
star
16

onion-poap

3
star
17

rocketeer

JavaScript
3
star
18

sendy-docker-compose

A docker-compose stack that runs the latest version of sendy
Shell
3
star
19

poap-codes

POAP code manager hosted at https://poap.codes
JavaScript
2
star
20

rocketpool-management

Shell
1
star
21

ssh-zsh-config

Setting up my SSH connections the way I like them
Shell
1
star
22

vps-setup-ssh-zsh-pretty

Setup script to set up VPS servers the way I like them
Shell
1
star
23

novi-firebase-workshop-june-2021

Will be deleted in august
JavaScript
1
star
24

vite-mentorified-biolerplate

Create-react-app modified for Mentor's liking.
JavaScript
1
star
25

react-node-boilerplate

A boilerplate for applications. Backend: [ Node, Express, Sequelize, Passport ] and Frontend: [ React, Babel, Webpack, Browsersync ]
JavaScript
1
star
26

sorry-cypress-server-provisioning

Set up a sorry-cypress docker-compose server that exposes an authenticated reverse proxy
Shell
1
star
27

vagrant-smus

Super mega ukulele server. Linux, Nginx with Mod_Pagespeed, MariaDB and HHVM.
Shell
1
star
28

react-frontend-boilerplate

A frontend boilerplate made with React, Webpack & Browsersync. Available as an NPM package with a command line scaffold generator.
JavaScript
1
star
29

intermittent-faster

The basic science of intermittent fasting.
1
star
30

hi-pew

An extremely performanc webpage/frontend boilerplate using webpack.
JavaScript
1
star
31

static-markdown-blog

A blog system (node, mocha, webpack) that compiles markdown to html pages through pug templates and optimises image resources.
JavaScript
1
star
32

endoweth

Endowment smart contract that distributes the expected yield of tokens to an endowee.
JavaScript
1
star
33

unidentified-analytics

JavaScript
1
star