Battery : Add battery life fuction.

This commit is contained in:
Dmitry Voronin 2024-02-12 23:00:16 +03:00
parent 0f0108c589
commit a806cb17f0
2 changed files with 13 additions and 4 deletions

View file

@ -1,4 +1,12 @@
# Print current battery level. # Print current battery charge in percents.
function battery_level() { function battery_charge() {
cat /sys/class/power_supply/BAT*/capacity 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
} }

View file

@ -34,7 +34,8 @@ Command|Description
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. ## Bootstrap.