暗无天日

=============>随便,谢谢

使用tlp优化电池消耗

TLP是一款linux上的基于文本界面的高级电源管理工具。TLP默认提供了一套针对电池使用进行优化的配置,使用这套配置能够显著降低对电池的消耗。 此外TLP也具有很高的可配置性,能够让你充分的配置以满足特殊需求。

安装TLP

在archlinux上通过下面命令来安装:

sudo pacman -S tlp tlp-rdw --noconfirm
resolving dependencies...
looking for conflicting packages...

Packages (2) tlp-1.1-1  tlp-rdw-1.1-1

Total Installed Size:  0.32 MiB

:: Proceed with installation? [Y/n] 
(0/2) checking keys in keyring                     [----------------------]   0%
(1/2) checking keys in keyring                     [###########-----------]  50%
(2/2) checking keys in keyring                     [######################] 100%
(0/2) checking package integrity                   [----------------------]   0%
(1/2) checking package integrity                   [###################---]  90%
(2/2) checking package integrity                   [######################] 100%
(0/2) loading package files                        [----------------------]   0%
(1/2) loading package files                        [###################---]  90%
(2/2) loading package files                        [######################] 100%
(0/2) checking for file conflicts                  [----------------------]   0%
(1/2) checking for file conflicts                  [###########-----------]  50%
(2/2) checking for file conflicts                  [######################] 100%
(0/2) checking available disk space                [----------------------]   0%
(1/2) checking available disk space                [###########-----------]  50%
(2/2) checking available disk space                [######################] 100%
:: Processing package changes...
(1/2) installing tlp                               [----------------------]   0%
(1/2) installing tlp                               [######################] 100%
Optional dependencies for tlp
    acpi_call: ThinkPad battery functions, Sandy Bridge and newer
    bash-completion: Bash completion [installed]
    ethtool: Disable Wake On Lan
    lsb-release: Display LSB release version in tlp-stat
    smartmontools: Display S.M.A.R.T. data in tlp-stat
    tp_smapi: ThinkPad battery functions
    x86_energy_perf_policy: Set energy versus performance policy on x86
    processors
(2/2) installing tlp-rdw                           [----------------------]   0%
(2/2) installing tlp-rdw                           [######################] 100%
:: Running post-transaction hooks...
(1/3) Reloading system manager configuration...
(2/3) Reloading device manager configuration...
(3/3) Arming ConditionNeedsUpdate...

如果你用的是 Thikpad 的笔记本则还可以安装

sudo pacman -S tp_smapi acpi_call --noconfirm
resolving dependencies...
looking for conflicting packages...

Packages (2) acpi_call-1.1.0-123  tp_smapi-0.43-17

Total Download Size:   0.03 MiB
Total Installed Size:  0.04 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64    0.0   B  0.00B/s 00:00 [----------------------]   0%
 tp_smapi-0.43-17-x86_64   23.7 KiB   592K/s 00:00 [######################] 100%
 acpi_call-1.1.0-123...     0.0   B  0.00B/s 00:00 [----------------------]   0%
 acpi_call-1.1.0-123...     0.0   B  0.00B/s 00:00 [----------------------]   0%
 acpi_call-1.1.0-123...     0.0   B  0.00B/s 00:00 [----------------------]   0%
 acpi_call-1.1.0-123...     0.0   B  0.00B/s 00:00 [----------------------]   0%
 acpi_call-1.1.0-123...     0.0   B  0.00B/s 00:00 [----------------------]   0%
 acpi_call-1.1.0-123...    11.7 KiB  2.85M/s 00:00 [######################] 100%
(0/2) checking keys in keyring                     [----------------------]   0%
(1/2) checking keys in keyring                     [###########-----------]  50%
(2/2) checking keys in keyring                     [######################] 100%
(0/2) checking package integrity                   [----------------------]   0%
(1/2) checking package integrity                   [##############--------]  67%
(2/2) checking package integrity                   [######################] 100%
(0/2) loading package files                        [----------------------]   0%
(1/2) loading package files                        [##############--------]  67%
(2/2) loading package files                        [######################] 100%
(0/2) checking for file conflicts                  [----------------------]   0%
(1/2) checking for file conflicts                  [###########-----------]  50%
(2/2) checking for file conflicts                  [######################] 100%
(0/2) checking available disk space                [----------------------]   0%
(1/2) checking available disk space                [###########-----------]  50%
(2/2) checking available disk space                [######################] 100%
:: Processing package changes...
(1/2) installing tp_smapi                          [----------------------]   0%
(1/2) installing tp_smapi                          [######################] 100%
(2/2) installing acpi_call                         [----------------------]   0%
(2/2) installing acpi_call                         [######################] 100%
:: Running post-transaction hooks...
(1/2) Updating linux module dependencies...
(2/2) Arming ConditionNeedsUpdate...

启动TLP服务

TLP默认会启动 NetworkManager.service,然而我使用的是 netctl 来管理网络,因此还需要修改一下 tlp.service

sudo cp /usr/lib/systemd/system/tlp.service /etc/systemd/system/
sudo sed -i '/Wants/ s/NetworkManager.service//' /etc/systemd/system/tlp.service

我们希望由TLP来管理无线设备,因此还需要mask systemd-rfkill.servicesystemd-rfkill.socket

sudo systemctl mask systemd-rfkill.service
sudo systemctl mask systemd-rfkill.socket

启动TLP服务

sudo systemctl start tlp.service
sudo systemctl enable tlp.service
sudo systemctl start tlp-sleep.service
sudo systemctl enable tlp-sleep.service

我们可以通过 tlp-stat 来检查TLP是否已经启动

sudo tlp-stat -s
--- TLP 1.1 --------------------------------------------

+++ System Info
System         = LENOVO ThinkPad X61 7673A98
BIOS           = 7NET29WW (1.10 )
Kernel         = 4.16.3-1-ARCH #1 SMP PREEMPT Thu Apr 19 09:17:56 UTC 2018 x86_64
/proc/cmdline  = BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=8011a945-7d06-4735-9eb1-7c7d9f10febf rw quiet
Init system    = systemd 
Boot mode      = BIOS (CSM, Legacy)

+++ TLP Status
State          = enabled
Last run       = 11:08:28 PM,    441 sec(s) ago
Mode           = AC
Power source   = AC

如果TLP没有启动的话,可以执行手工启动TLP

sudo tlp start
TLP started in AC mode.

使用TLP

TLP中最常用的命令有这么几个:

tlp: 应用笔记本的节能设置。

sudo tlp start
根据实际情况是使用交流电还是电池,来应用对应的节能设置
sudo tlp ac
强制切换到交流电对应的节能设置
sudo tlp bat
强制切换到电池的节能设置

tlp-stat: 显示当前的节能设置

sudo tlp-stat -b
显示电池的相关信息
tlp-stat -c
显示tlp当前的配置信息
sudo tlp-stat -d
显示磁盘的信息
sudo tlp-stat -e
显示PCIE信息
sudo tlp-stat -g
显示显卡的相关信息
tlp-stat -r
显示无线设备的相关信息
tlp-stat -s
显示系统相关信息
tlp-stat -t
显示温度和磁盘转速
tlp
显示上面的所有信息

wifi: 手动启动/关闭wifi

sudo wifi on
手动启动wifi
sudo wifi off
手动关闭wifi
sudo wifi toggle
手动切换wifi状态

bluetooth: 手动启动/关闭蓝牙

sudo bluetooth on
手动启动蓝牙
sudo bluetooth off
手动关闭蓝牙
sudo bluetooth toggle
手动切换蓝牙状态

wwan: 手动启动/关闭wwan(3G/4G)设备

sudo wwan on
手动启动wwlan设备
sudo wwan off
手动关闭wwlan设备
sudo wwan toggle
手动切换wwlan设备状态

配置TLP

TLP的配置文件放在 /etc/default/tlp 中,详细的配置方法请参见官网上的说明

TLPUI

TLP本身并不自带图形化用户界面,但是有一个第三方的GTK GUI界面可以使用,名叫 TLPUI

archlinux的aur仓库中就有这个应用,可以通过下面这个命令来安装

aurman -S tlpui-git

安装后直接运行 tlpui 就能打开应用 TPLUI-01.png