2018-11-04 18:56:39 -05:00
|
|
|
#!/bin/sh
|
2018-07-16 19:16:47 -04:00
|
|
|
|
2018-11-04 18:56:39 -05:00
|
|
|
# Give a battery name (e.g. BAT0) as an argument.
|
2018-08-07 12:49:22 -04:00
|
|
|
|
2018-11-04 18:56:39 -05:00
|
|
|
capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
|
|
|
|
status=$(cat /sys/class/power_supply/"$1"/status)
|
|
|
|
|
|
|
|
if [ "$capacity" -ge 80 ]; then
|
2018-07-16 19:16:47 -04:00
|
|
|
color="#00FF00"
|
2018-11-04 18:56:39 -05:00
|
|
|
elif [ "$capacity" -ge 60 ]; then
|
2018-07-17 14:45:12 -04:00
|
|
|
color="#FFFFFF"
|
2018-11-04 18:56:39 -05:00
|
|
|
elif [ "$capacity" -ge 40 ]; then
|
2018-07-16 19:16:47 -04:00
|
|
|
color="#FFF600"
|
2018-11-04 18:56:39 -05:00
|
|
|
elif [ "$capacity" -ge 20 ]; then
|
2018-07-16 19:16:47 -04:00
|
|
|
color="#FFAE00"
|
|
|
|
else
|
|
|
|
color="#FF0000"
|
|
|
|
fi
|
|
|
|
|
2018-11-04 18:56:39 -05:00
|
|
|
[ "$status" = "Charging" ] && color="#FFF"
|
2018-08-07 12:49:22 -04:00
|
|
|
|
2018-11-04 18:56:39 -05:00
|
|
|
printf "<span color='%s'>%s %s</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$(echo "$capacity" | sed -e 's/$/%/')"
|
2018-11-11 21:27:04 -05:00
|
|
|
|
|
|
|
case $BLOCK_BUTTON in
|
|
|
|
3) pgrep -x dunst >/dev/null && notify-send "<b>🔋 Battery module:</b>
|
|
|
|
🔋: discharging
|
|
|
|
♻: stagnant charge
|
|
|
|
🔌: charging
|
|
|
|
⚡: charged
|
|
|
|
- Text color reflects charge left" ;;
|
|
|
|
esac
|
|
|
|
|