23 lines
487 B
Bash
Executable File
23 lines
487 B
Bash
Executable File
#!/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
|
|
|