7abef725 |
1 | #! /bin/bash |
2 | |
3 | BAT_LEVEL=$(acpi -b | awk ' { print ($4)-0}') |
4 | CHARGER_ON=$(acpi -a | grep -i "on") |
5 | CHARGER_OFF=$(acpi -a | grep -i "off") |
6 | |
7 | if [ "$BAT_LEVEL" -le "20" ] ; then |
8 | if [ "$CHARGER_OFF" ]; then |
9 | logger "battery not charging, we're gonna die soon." |
10 | notify-send -u critical -i dialog-error "BATTERY LOW" "battery level is below 20%, please plug the AC charger" |
11 | pactl set-sink-volume 0 100\% |
12 | pactl set-sink-mute 0 0 |
13 | play -q /usr/share/sounds/Oxygen-Sys-App-Error.ogg |
14 | else |
15 | logger "battery low but charging. It's all fine." |
16 | fi |
17 | elif [ "$BAT_LEVEL" -lt "10" ]; then |
18 | if [ "$CHARGER_ON" ]; then |
19 | logger "battery extremely low but charging. It's all fine." |
20 | else |
21 | notify-send -u critical -i dialog-error "BATTERY EXTREMELY LOW" "battery level is below 10%, the system is going to shutdown." |
22 | pactl set-sink-volume 0 100\% |
23 | pactl set-sink-mute 0 0 |
24 | play -q /usr/share/sounds/Oxygen-Sys-App-Error-Serious.ogg |
25 | fi |
26 | fi |