#!/bin/sh set -e readonly TS_FILE="$XDG_DATA_HOME/battery-notification.timestamp" [ -f "$TS_FILE" ] || touch "$TS_FILE" cd /sys/class/power_supply/BAT1 read cap 60)) -eq 1 ]) then notify-send -a 'battery' -u critical 'Battery Low' \ 'The current battery level is below 20%. Plug the device into a charger ASAP.' echo $now >"$TS_FILE" fi fi { printf 'percentage=%s\nicon=' $cap if [ $status = Charging ]; then echo "󰂄" elif [ $cap -ge 90 ]; then echo "󰁹" elif [ $cap -ge 80 ]; then echo "󰂂" elif [ $cap -ge 70 ]; then echo "󰂁" elif [ $cap -ge 60 ]; then echo "󰁿" elif [ $cap -ge 50 ]; then echo "󰁾" elif [ $cap -ge 40 ]; then echo "󰁽" elif [ $cap -ge 30 ]; then echo "󰁼" elif [ $cap -ge 20 ]; then echo "󰁻" elif [ $cap -ge 10 ]; then echo "󰁺" else echo "󰂎" fi } | jo