Simplified battery percentage retrieval command (#2922)

* Simplified battery percentage retrieval command

Simplified the battery percentage extraction command.

* Used int instead of adding 0, put exit back in

Changed to use int.
Put exit back in to only return first battery in case of systems with multiple batteries.
This commit is contained in:
Michael D Lambert
2026-02-20 18:29:45 +01:00
committed by GitHub
parent 694eb8c698
commit e99afc98f8
+3 -6
View File
@@ -3,10 +3,7 @@
# Returns the battery percentage remaining as an integer.
# Used by the battery monitor and the Ctrl + Shift + Super + B hotkey.
upower -i $(upower -e | grep BAT) \
| awk -F: '/percentage/ {
gsub(/[%[:space:]]/, "", $2);
val=$2;
printf("%d\n", (val+0.5))
upower -i $(upower -e | grep BAT) | awk '/percentage/ {
print int($2)
exit
}'
}'