sudo apt-get install tp-smapi-dkms
sudo modprobe tp_smapi
echo 40 | sudo tee /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 | sudo tee /sys/devices/platform/smapi/BAT0/stop_charge_thresh
现在有一个更加友好的应用程序可供Ubuntu(和其他发行版)使用:
TLP为Linux带来了先进的电源管理功能,无需了解每个技术细节。TLP已经预先配置为优化电池寿命,所以您只需安装并忘记它。然而,TLP也可以根据您的特定要求进行高度自定义。
它控制的参数之一是保持电池充电限制。正如评论中@tanius所指出的(请点赞!),尽管TLP过去只能在Thinkpad上运行,但最新版本已经支持多个厂商的设备,而且考虑到该项目的性质——如果其他设备的适当驱动程序可用,很可能会集成到该项目中。因此,如果您在几年后阅读本评论,请查看文档,也许您的设备现在已被支持。
Ubuntu软件包可以在官方仓库中找到。
tlp
是否也支持 Thinkpad X1 Carbon
吗? - Kasun Siyambalapitiyatlp
只是两个工具的前端,用于实现此功能:Tp smapi和tpacpi-bat。只要您的型号至少被其中一个支持,它应该可以正常工作(或者您可以提交一个错误报告)。根据它们的支持硬件页面,您的型号似乎没有列出,但是快速搜索显示后者可能适用。 - liorigit clone https://github.com/teleshoes/tpacpi-bat.git
cd tpacpi-bat/
./install.pl
sudo ./tpacpi-bat -s ST 1 15 # load internal battery when below 15%
sudo ./tpacpi-bat -s SP 1 95 # stop charging at 95%
sudo ./tpacpi-bat -g ST 2 # when is external battery loaded?
./install.pl
步骤会失败并显示modprobe: ERROR: could not insert 'acpi_call': Operation not permitted
。一个解决方法是禁用安全启动或手动签名模块;参考例如https://askubuntu.com/questions/1114867。 - Fred Schoensudo add-apt-repository ppa:linrunner/tlp
sudo apt update
sudo apt install tlp
# 检查电池所需的软件包:
sudo tlp-stat -b
# 如果推荐使用acpi_call
sudo apt install acpi-call-dkms
# 如果推荐使用smapi
sudo apt install tp-smapi-dkms
sudo gedit /etc/tlp.conf
START_CHARGE_THRESH_BAT0=75
STOP_CHARGE_THRESH_BAT0=80
sudo tlp start
sudo tlp-stat -b
START_CHARGE_THRESH_BAT0=60
STOP_CHARGE_THRESH_BAT0=81
当我插上充电器时,电池电量达到80%就停止充电。一切都符合预期。但是下限范围是如何工作的呢?插上充电器后,电量始终保持在80%不变。 - Jeksonsystemctl enable tlp.service
- Ron Michael我有一台华硕笔记本电脑,我从互联网上找到的方法如下。这种方法可能已经是上述某些应用程序的一部分,但这里提供它作为信息。
创建一个名为battery_charge_threshold.service的服务文件,内容如下:[Unit]
Description=设置电池充电阈值
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
[Install]
WantedBy=multi-user.target
sudo chmod 644 /etc/systemd/system/battery-charge-threshold.service
sudo systemctl daemon-reload
sudo systemctl enable battery-charge-threshold.service
start_charge_threshold
和stop_charge_threshold
?这样我们就可以控制充电的开始和结束。 - Hosein RahnamaASUS-N580V
上使用了这种方法,但是这导致电池异常发热,而当我在Windows上使用ASUS Battery Health Charging
时并非如此。 - Hosein Rahnamasudo smbios-battery-ctl --set-custom-charge-interval 75 80
sudo smbios-battery-ctl --set-charging-mode=custom
sudo smbios-battery-ctl --set-charging-mode=adaptive
File "/usr/lib/python3/dist-packages/libsmbios_c/smbios_token.py", line 145, in __getitem__ raise IndexError(_("SMBIOS Token ID 0x%04x not found") % id ) IndexError: SMBIOS Token ID 0x0349 not found
。 - Gabriel Staples$ ./bat --help
在所在目录的终端中运行,应该会显示帮助文档。
如果出现错误,可能与权限有关。以下命令可能会解决问题。
chmod +x ./bat
$ ./bat --threshold
./bat --threshold 60
sudo ./bat --persist
/usr/local/bin/
这样的目录中,该目录位于$PATH
中,这将使您能够从任何地方运行它,而不仅仅是在应用程序所在的目录中。然后上述命令变为:bat --help
bat --threshold 60
bat --persist
分别。
bat
版本0.8.4:命令:./bat --threshold
响应:"这个程序很可能与您的系统不兼容。请参阅https://github.com/tshakalekholoane/bat#disclaimer了解详情。" - Gabriel Staples
sudo apt-get install tp-smapi-dkms
命令进行安装。安装成功后,我尝试执行echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
命令,但系统提示bash: /sys/devices/platform/smapi/BAT0/start_charge_thresh: No such file or directory
。为什么会这样呢? - Alex Malextp_smapi
时遇到困难,或者加载后/sys/devices/platform/smapi
仍然不存在,我建议你就此问题开一个新的提问。 - ændrükalex@ubuntu:~$ sudo modprobe tp_smapi FATAL: Error inserting tp_smapi (/lib/modules/3.5.0-17-generic/updates/dkms/tp_smapi.ko): No such device
。我错过了什么吗?如果我得不到答案,我将打开一个新的问题。 - Alex Malex$ sudo modprobe hdaps_ec modprobe: 致命错误:找不到hdaps_ec模块。
$ sudo insmod /lib/modules/3.13.0-83-generic/updates/dkms/tp_smapi.ko insmod: 错误:无法插入模块/lib/modules/3.13.0-83-generic/updates/dkms/tp_smapi.ko:模块中有未知符号。
- antivirtelacpi-call-dkms
软件包,具体请参考http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html#installation - zroodatp_smapi
不再起作用了,但是自从4.18版本开始,有一个内核模块thinkpad_acpi
可以完成这个任务。 - karlsebal/sys/class/power_supply/BAT0
路径下找到了以下文件名的设置:charge_control_end_threshold charge_control_start_threshold charge_start_threshold charge_stop_threshold
。我只需将我想要的阈值使用echo
命令写入这些文件名中即可。它们会在重启后保持不变,所以可能是我在xubuntu中设置了某些东西来保持它们的持久性。 - NeilG