参考链接:
从 Linux 终端查看笔记本电池状态和等级的 5 个方法
关于upower
,本人了解也不是很深刻,下面只是做个记录,为方便以后查看。
查看upower
命令的帮助:
[adams@~]$ upower --help
用法:
upower [选项…] UPower tool
帮助选项:
-h, --help 显示帮助选项
应用程序选项:
-e, --enumerate Enumerate objects paths for devices
-d, --dump Dump all parameters for all objects
-w, --wakeups Get the wakeup data
-m, --monitor Monitor activity from the power daemon
--monitor-detail Monitor with detail
-i, --show-info Show information about object path
-v, --version Print version of client and daemon
[adams@~]$
使用 upower -e
:
[adams@~]$ upower -e
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/battery_BAT1
/org/freedesktop/UPower/devices/DisplayDevice
[adams@~]$
使用 upower -i
加对应电池信息:
[adams@~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: BAT0
vendor: SMP
model: 01AV459
serial: 3572
power supply: yes
updated: 2019年11月13日 星期三 10时37分41秒 (23 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: fully-charged
warning-level: none
energy: 24.89 Wh
energy-empty: 0 Wh
energy-full: 24.9 Wh
energy-full-design: 24 Wh
energy-rate: 0 W
voltage: 12.916 V
percentage: 100%
capacity: 100%
technology: lithium-polymer
icon-name: 'battery-full-charged-symbolic'
[adams@~]$
如果是查看AC
:
[adams@~]$ upower -i /org/freedesktop/UPower/devices/line_power_AC
native-path: AC
power supply: yes
updated: 2019年11月13日 星期三 09时10分37秒 (5290 seconds ago)
has history: no
has statistics: no
line-power
warning-level: none
online: yes
icon-name: 'ac-adapter-symbolic'
[adams@~]$
upower的配置文件为:/etc/UPower/UPower.conf
,其内容为:
# Only the system vendor should modify this file, ordinary users
# should not have to change anything.
[UPower]
# Enable the Watts Up Pro device.
#
# The Watts Up Pro contains a generic FTDI USB device without a specific
# vendor and product ID. When we probe for WUP devices, we can cause
# the user to get a perplexing "Device or resource busy" error when
# attempting to use their non-WUP device.
#
# The generic FTDI device is known to also be used on:
#
# - Sparkfun FT232 breakout board
# - Parallax Propeller
#
# default=false
EnableWattsUpPro=false
# Don't poll the kernel for battery level changes.
#
# Some hardware will send us battery level changes through
# events, rather than us having to poll for it. This option
# allows disabling polling for hardware that sends out events.
#
# default=false
NoPollBatteries=false
# Do we ignore the lid state
#
# Some laptops are broken. The lid state is either inverted, or stuck
# on or off. We can't do much to fix these problems, but this is a way
# for users to make the laptop panel vanish, a state that might be used
# by a couple of user-space daemons. On Linux systems, see also
# logind.conf(5).
#
# default=false
IgnoreLid=false
# Policy for warnings and action based on battery levels
#
# Whether battery percentage based policy should be used. The default
# is to use the time left, change to true to use the percentage, which
# should work around broken firmwares. It is also more reliable than
# the time left (frantically saving all your files is going to use more
# battery than letting it rest for example).
# default=true
UsePercentageForPolicy=true
# When UsePercentageForPolicy is true, the levels at which UPower will
# consider the battery low, critical, or take action for the critical
# battery level.
#
# This will also be used for batteries which don't have time information
# such as that of peripherals.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# PercentageLow=10
# PercentageCritical=3
# PercentageAction=2
PercentageLow=10
PercentageCritical=3
PercentageAction=2
# When UsePercentageForPolicy is false, the time remaining at which UPower
# will consider the battery low, critical, or take action for the critical
# battery level.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# TimeLow=1200
# TimeCritical=300
# TimeAction=120
TimeLow=1200
TimeCritical=300
TimeAction=120
# The action to take when "TimeAction" or "PercentageAction" above has been
# reached for the batteries (UPS or laptop batteries) supplying the computer
#
# Possible values are:
# PowerOff
# Hibernate
# HybridSleep
#
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=HybridSleep