Fuller battery stats

This commit is contained in:
David Heinemeier Hansson
2026-03-02 14:02:42 +01:00
parent d9e3993d0c
commit 758e9d442f
3 changed files with 44 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Returns the battery time remaining (to empty or full) in a compact format.
battery_info=$(upower -i $(upower -e | grep BAT))
echo "$battery_info" | awk '/time to (empty|full)/ {
value = $4
unit = $5
gsub(/hours/, "h", unit)
gsub(/minutes/, "m", unit)
# Remove .0 from whole numbers
gsub(/\.0/, "", value)
print value unit
exit
}'