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:
@@ -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
|
||||
}'
|
||||
}'
|
||||
|
||||
Reference in New Issue
Block a user