Files
arthur-os/bin/omarchy-battery-remaining-time
T

17 lines
379 B
Bash
Executable File

#!/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
}'