mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
17 lines
379 B
Bash
Executable File
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
|
|
}'
|