bashrc alias add pluys battery alert scrip
This commit is contained in:
22
.local/bin/battery_alert.sh
Executable file
22
.local/bin/battery_alert.sh
Executable 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
|
||||
|
||||
Reference in New Issue
Block a user