bashrc alias add pluys battery alert scrip

This commit is contained in:
2025-04-29 23:19:57 -07:00
parent e5b720af93
commit aaa45d6009
2 changed files with 25 additions and 1 deletions

22
.local/bin/battery_alert.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
BAT_PATH="/sys/class/power_supply/BAT0"
CAPACITY=$(cat "$BAT_PATH/capacity")
STATUS=$(cat "$BAT_PATH/status")
notify() {
dunstify -u critical -r 999 "⚡ Battery low: $1%" "Plug in your charger NOW!"
}
if [ "$STATUS" != "Charging" ]; then
if [ "$CAPACITY" -le 5 ]; then
notify 5
elif [ "$CAPACITY" -le 10 ]; then
notify 10
elif [ "$CAPACITY" -le 20 ]; then
notify 20
elif [ "$CAPACITY" -le 30 ]; then
notify 30
fi
fi