Even better

This commit is contained in:
David Heinemeier Hansson committed 2026-03-02 14:15:46 +01:00
1 parent 758e9d442f
commit 5e516be544
3 files changed
+21 -9

No files matched your search

+7 -7
View File
@@ -5,12 +5,12 @@
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
hours = int($4)
minutes = int(($4 - hours) * 60)
if (minutes > 0) {
printf "%dh %dm", hours, minutes
} else {
printf "%dh", hours
}
exit
}'