script: battery-notify check if we are already on AC

This commit is contained in:
Joseph Ferano 2026-05-09 18:02:46 +07:00
parent eebfbdf622
commit 45ed3a8081

View File

@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
BATTERY_LEVEL=$(upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | awk '{print $2}' | sed 's/%//') BATTERY_LEVEL=$(upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | awk '{print $2}' | sed 's/%//')
AC_POWER=$(cat /sys/class/power_supply/AC0/online)
if [ $AC_POWER -eq 1 ]; then
exit
fi
if [ $BATTERY_LEVEL -le 5 ]; then if [ $BATTERY_LEVEL -le 5 ]; then
notify-send "Low Battery" "Battery level is ${BATTERY_LEVEL}%" -u critical notify-send "Low Battery" "Battery level is ${BATTERY_LEVEL}%" -u critical
exit exit