Files
dotfiles/scripts/battery_notifier.sh
Kyren223 0f373f6ab9 Changed battery notifier to first have a normal notif on 80% and only at
90% have a critical, that way most of the time I can just ignore it, and
only if I was in a YT vid or smthing and didn't see it then at 90% I
will get notified even when fullscreening
2024-12-18 15:55:04 +02:00

21 lines
725 B
Bash
Executable File

set -eu
export DISPLAY=:0.0
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
if [ "$battery_status" = "Charging" ] && [ "$battery_level" -ge 80 ]; then
/etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
--app-name="Battery Notifier" \
--expire-time=5000 \
"Battery at $battery_level%, unplug!"
fi
if [ "$battery_status" = "Charging" ] && [ "$battery_level" -ge 90 ]; then
/etc/profiles/per-user/kyren/bin/notify-send --urgency=critical \
--app-name="Battery Notifier" \
--expire-time=5000 \
"Battery at $battery_level%, unplug!"
fi