Battery:Apple Silicon MacBook 设备的电池充电限制器
工具简介
Battery 是一个适用于 Apple Silicon MacBook 设备的免费且开源的电池充电限制器。通过该工具,我们可以限制 MacBook 在插入电源时的充电行为,使得电池始终保持在 80% 电量,从而延长电池的使用寿命。
地址: https://github.com/actuallymentor/battery
安装方法
- 通过 Homebrew 安装
- 下载最新的应用程序 dmg 版本。
- 仅命令行安装(详情请见下文)
第一次打开该应用程序时,它会询问您的管理员密码,以便安装所需的组件。请注意,该应用程序:
- 即使已插入电源,也会将电池放电直至电量达到 80%
- 当电池电量高于 80% 时禁用充电
- 当电池电量低于 80% 时启用充电
- 即使重新启动后仍保持限制
- 即使关闭托盘应用程序后仍保持限制
- 还会自动安装
battery
命令行工具。如果您想要自定义收费百分比,CLI 是唯一的方法。
使用说明
Battery 可以通过命令行工具或者 GUI 应用程序进行使用。命令行工具提供了多种功能,例如设置充电百分比、手动启用/禁用充电、查看电池状态等。
安装dmg包版本
https://github.com/actuallymentor/battery/releases
安装命令行版本
通过以下命令进行安装:
curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash
brew命令行版本
brew install battery
使用示例
- 启用充电维持功能,限制电池充电至 80%:
battery maintain 80
- 手动启用充电:
battery charging on
- 查看电池状态:
battery status
battery
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
```