mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
* Add omarchy CLI * Remove outdated or internal * Add bash completions for command * Add omarchy command documentation * Add missing docs * Correct to what's now right * Fix tests --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
28 lines
823 B
Bash
Executable File
28 lines
823 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Returns a formatted battery status string with percentage and power draw/charge.
|
|
|
|
battery_info=$(upower -i $(upower -e | grep BAT))
|
|
|
|
percentage=$(echo "$battery_info" | awk '/percentage/ {
|
|
print int($2)
|
|
exit
|
|
}')
|
|
|
|
power_rate=$(echo "$battery_info" | awk '/energy-rate/ {
|
|
rounded = sprintf("%.1f", $2)
|
|
sub(/\.0$/, "", rounded)
|
|
print rounded
|
|
exit
|
|
}')
|
|
|
|
state=$(echo "$battery_info" | awk '/state/ { print $2; exit }')
|
|
time_remaining=$(omarchy-battery-remaining-time)
|
|
capacity=$(omarchy-battery-capacity)
|
|
|
|
if [[ $state == "charging" ]]; then
|
|
echo " Battery ${percentage}% · ${time_remaining} to full · ${power_rate}W / ${capacity}Wh"
|
|
else
|
|
echo " Battery ${percentage}% · ${time_remaining} left · ${power_rate}W / ${capacity}Wh"
|
|
fi
|