summaryrefslogtreecommitdiff
path: root/i3blocks-battery.sh
diff options
context:
space:
mode:
Diffstat (limited to 'i3blocks-battery.sh')
-rwxr-xr-xi3blocks-battery.sh39
1 files changed, 11 insertions, 28 deletions
diff --git a/i3blocks-battery.sh b/i3blocks-battery.sh
index 33e6a74..af2d37f 100755
--- a/i3blocks-battery.sh
+++ b/i3blocks-battery.sh
@@ -1,32 +1,15 @@
#!/bin/sh
-base="/sys/class/power_supply/BAT0/"
-low=25
-med=50
-high=75
-icon_charging_high=󱊦
-icon_charging_low=󱊤
-icon_charging_med=󱊥
-icon_charging_dry=󰢟
-icon_high=󱊣
-icon_low=󱊡
-icon_med=󱊢
-icon_dry=󰂎
+icon_high=󰁹
+icon_low=󰁾
+icon_crit=󱃍
+icon_charging=󰂄
-full=$(< $base/energy_full_design)
-now=$(< $base/energy_now)
-stat=$(< $base/status)
-percent=$(echo "result = $now / $full * 100; scale=0; result / 1" | bc -l)
+status=$(apm -b)
+level=$(apm -l)
-if [ "$stat" = "Discharging" ]; then
- [ $percent -lt $low ] && printf $icon_dry
- [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_low
- [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_med
- [ $percent -ge $high ] && printf $icon_high
-else
- [ $percent -lt $low ] && printf $icon_charging_dry
- [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_charging_low
- [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_charging_med
- [ $percent -ge $high ] && printf $icon_charging_high
-fi
+[ $status -eq 0 ] && printf "%s" $icon_high
+[ $status -eq 1 ] && printf "%s" $icon_low
+[ $status -eq 2 ] && printf "%s" $icon_crit
+[ $status -eq 3 ] && printf "%s" $icon_charging
-printf " %s%%\n" $percent
+printf " %s%%\n" $level