2018-11-04 23:56:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Give a battery name (e.g. BAT0) as an argument.
|
2018-08-07 16:49:22 +00:00
|
|
|
|
2018-11-12 02:32:51 +00:00
|
|
|
case $BLOCK_BUTTON in
|
2019-04-02 23:20:26 +00:00
|
|
|
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
|
2019-02-09 23:07:41 +00:00
|
|
|
🛑: not charging
|
2018-11-12 02:32:51 +00:00
|
|
|
♻: stagnant charge
|
|
|
|
🔌: charging
|
|
|
|
⚡: charged
|
2018-11-27 18:56:32 +00:00
|
|
|
❗: battery very low!
|
2018-11-12 02:32:51 +00:00
|
|
|
- Text color reflects charge left" ;;
|
|
|
|
esac
|
|
|
|
|
2018-11-04 23:56:39 +00:00
|
|
|
capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
|
|
|
|
status=$(cat /sys/class/power_supply/"$1"/status)
|
|
|
|
|
2018-12-16 21:50:42 +00:00
|
|
|
if [ "$capacity" -ge 75 ]; then
|
2019-02-20 20:28:15 +00:00
|
|
|
color="#00ff00"
|
2018-12-16 21:50:42 +00:00
|
|
|
elif [ "$capacity" -ge 50 ]; then
|
2019-02-20 20:28:15 +00:00
|
|
|
color="#ffffff"
|
2018-12-16 21:50:42 +00:00
|
|
|
elif [ "$capacity" -ge 25 ]; then
|
2019-02-20 20:28:15 +00:00
|
|
|
color="#ffff00"
|
2018-07-16 23:16:47 +00:00
|
|
|
else
|
2019-02-20 20:28:15 +00:00
|
|
|
color="#ff0000"
|
2018-11-27 18:56:32 +00:00
|
|
|
warn="❗"
|
2018-07-16 23:16:47 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-27 18:56:32 +00:00
|
|
|
[ -z $warn ] && warn=" "
|
|
|
|
|
2019-02-20 20:28:15 +00:00
|
|
|
[ "$status" = "Charging" ] && color="#ffffff"
|
2018-08-07 16:49:22 +00:00
|
|
|
|
2019-02-09 23:07:41 +00:00
|
|
|
printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
|