Even better
This commit is contained in:
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Returns the battery full capacity in Wh (rounded to whole number).
|
||||||
|
# Used by omarchy-battery-status for displaying battery capacity.
|
||||||
|
|
||||||
|
battery_info=$(upower -i $(upower -e | grep BAT))
|
||||||
|
|
||||||
|
echo "$battery_info" | awk '/energy-full:/ {
|
||||||
|
printf "%d", $2
|
||||||
|
exit
|
||||||
|
}'
|
||||||
@@ -5,12 +5,12 @@
|
|||||||
battery_info=$(upower -i $(upower -e | grep BAT))
|
battery_info=$(upower -i $(upower -e | grep BAT))
|
||||||
|
|
||||||
echo "$battery_info" | awk '/time to (empty|full)/ {
|
echo "$battery_info" | awk '/time to (empty|full)/ {
|
||||||
value = $4
|
hours = int($4)
|
||||||
unit = $5
|
minutes = int(($4 - hours) * 60)
|
||||||
gsub(/hours/, "h", unit)
|
if (minutes > 0) {
|
||||||
gsub(/minutes/, "m", unit)
|
printf "%dh %dm", hours, minutes
|
||||||
# Remove .0 from whole numbers
|
} else {
|
||||||
gsub(/\.0/, "", value)
|
printf "%dh", hours
|
||||||
print value unit
|
}
|
||||||
exit
|
exit
|
||||||
}'
|
}'
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ power_rate=$(echo "$battery_info" | awk '/energy-rate/ {
|
|||||||
|
|
||||||
state=$(echo "$battery_info" | awk '/state/ { print $2; exit }')
|
state=$(echo "$battery_info" | awk '/state/ { print $2; exit }')
|
||||||
time_remaining=$(omarchy-battery-remaining-time)
|
time_remaining=$(omarchy-battery-remaining-time)
|
||||||
|
capacity=$(omarchy-battery-capacity)
|
||||||
|
|
||||||
if [[ $state == "charging" ]]; then
|
if [[ $state == "charging" ]]; then
|
||||||
echo " Battery at ${percentage}% with ${time_remaining} left to full gaining ${power_rate}W"
|
echo " Battery ${percentage}% · ${time_remaining} to full · ${power_rate}W / ${capacity}Wh"
|
||||||
else
|
else
|
||||||
echo " Battery at ${percentage}% with ${time_remaining} left using ${power_rate}W"
|
echo " Battery ${percentage}% · ${time_remaining} left · ${power_rate}W / ${capacity}Wh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user