battery-notify script

This commit is contained in:
teddy 2026-01-08 13:40:02 +01:00
parent 16cf74dffa
commit 5c394bfd80
2 changed files with 22 additions and 1 deletions

13
scripts/battery-notify.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
# Only warn when discharging (not plugged in)
if [[ $battery_status == "Discharging" ]]; then
if [[ $battery_level -le 15 ]]; then
notify-send -u critical "⚠️ Battery Critical" "Only ${battery_level}% remaining! Plug in NOW!"
elif [[ $battery_level -le 30 ]]; then
notify-send -u normal "🔋 Battery Low" "Battery at ${battery_level}%. Consider plugging in soon."
fi
fi