aboutsummaryrefslogtreecommitdiff
path: root/pw-battery
diff options
context:
space:
mode:
Diffstat (limited to 'pw-battery')
-rwxr-xr-xpw-battery60
1 files changed, 29 insertions, 31 deletions
diff --git a/pw-battery b/pw-battery
index 3f3dea7..bce03cc 100755
--- a/pw-battery
+++ b/pw-battery
@@ -1,28 +1,11 @@
-#!/bin/sh
+#!/usr/bin/env bash
+
# Display the current battery status.
# requires joypixels font in dwm config.def.h
-notify() {
- dunstify \
- -i battery-good-symbolic \
- -t 10000 \
- -h string:x-canonical-private-synchronous:battery \
- "Battery" "$1"
-}
-
-
-case "$BLOCK_BUTTON" in
- # ugly must do better
- 1)
- INF=$(inxi -B --extra 3 -c 0 -y 1)
- REM=$(acpi | cut -d , -f 3)
- DAT=$(echo "$INF$REM" | sed -e 's/^[ \t]*//')
- notify "$DAT"
- ;;
- 3)
- notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')"
- ;;
-esac
+# This is updated by signal 2, so 2 + 34 =
+# kill -36 $(pidof dwmblocks) or
+# pkill -RTMIN+2 dwmblocks
# Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT?*; do
@@ -43,18 +26,33 @@ for battery in /sys/class/power_supply/BAT?*; do
fi
case "$(cat "$battery/status" 2>&1)" in
- Full) status="⚡ " ;;
- Discharging)
+
+ "Full")
+ status="⚡"
+ ;;
+
+ "Discharging")
if [ "$capacity" -le 20 ]; then
status="$status"
- color=1
fi
- ;;
- Charging) status="🔌$status" ;;
- "Not charging") status="♻️" ;;
- Unknown) status="? $status" ;;
- *) exit 1 ;;
+ ;;
+
+ "Charging")
+ status="🔌$status"
+ ;;
+
+ "Not charging")
+ status="♻️"
+ ;;
+
+ "Unknown")
+ status="? $status"
+ ;;
+
+ *)
+ exit 1
+ ;;
esac
- echo "┊ $status $capacity%"
+ echo -e "┊ $status $capacity%"
done