X-Git-Url: https://git.danix.xyz/?p=my-dotfiles.git;a=blobdiff_plain;f=bin%2Fexecutors%2Fbattery-level;fp=bin%2Fexecutors%2Fbattery-level;h=4078b351e354fafa15e630f83c2d1a66fd6f00e9;hp=0000000000000000000000000000000000000000;hb=7abef725078fc52196b630c95f354fb58864c743;hpb=6be4fcd546b01b14b5f06306ab5b7c0391913bfa diff --git a/bin/executors/battery-level b/bin/executors/battery-level new file mode 100644 index 0000000..4078b35 --- /dev/null +++ b/bin/executors/battery-level @@ -0,0 +1,26 @@ +#! /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