13 lines
355 B
Bash
13 lines
355 B
Bash
# 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
|
|
}
|