Battery : Add battery life fuction.
This commit is contained in:
parent
0f0108c589
commit
a806cb17f0
|
@ -1,4 +1,12 @@
|
|||
# Print current battery level.
|
||||
function battery_level() {
|
||||
cat /sys/class/power_supply/BAT*/capacity
|
||||
# Print current battery charge in percents.
|
||||
function battery_charge() {
|
||||
head -c -1 /sys/class/power_supply/BAT*/capacity
|
||||
echo '%'
|
||||
}
|
||||
|
||||
# Get battery's remaining max capacity in percents.
|
||||
function battery_capacity() {
|
||||
local IFS=$'\n'
|
||||
local battery=("$(upower --enumerate | grep battery_BAT)")
|
||||
upower -i "${battery[0]}" | grep capacity | cut -d\ -f17
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ Command|Description
|
|||
|
||||
Command|Description
|
||||
---|---
|
||||
`battery_level`| Print current battery level.
|
||||
`battery_charge`| Print current battery charge in percents.
|
||||
`battery_capacity`| Get battery's remaining max capacity in percents.
|
||||
|
||||
## Bootstrap.
|
||||
|
||||
|
|
Reference in a new issue