Only show the int value of the battery percentage by default, rather than including the decimals.

This commit is contained in:
2025-11-10 21:12:53 -07:00
parent b0762c7baf
commit e6947d4a30

View File

@@ -2,7 +2,17 @@
# 2025-11-10 Hyperling # 2025-11-10 Hyperling
function battery-display { function battery-display {
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9.%]*" detailed="N"
if [[ -n $1 ]]; then
detailed="Y"
fi
if [[ "$detailed" == "Y" ]]; then
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9.%]*"
else
int="`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | grep -o "[0-9]*" | head -n 1`"
echo "${int}%"
fi
} }
alias show-battery="battery-display" alias show-battery="battery-display"
alias battery="battery-display" alias battery="battery-display"