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