sucklessConfigs

configurations of the suckless.org software that I use
Log | Files | Refs

batteryNotification.sh (504B)


      1 #! /bin/sh
      2 
      3 export DISPLAY=:0
      4 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
      5 
      6 
      7 while true; do
      8 	battery=$(acpi -b | awk '{print $4}' | sed s/%,//)
      9 	charging=$(acpi -b | grep -c "Charging")
     10 	if [ "$battery" -lt 20 ] && [ "$charging" -eq 0 ]; then
     11 		notify-send --urgency=critical "Low Battery!" "Your battery is at $battery %"
     12 	elif [ "$battery" -gt 90 ] && [ "$charging" -eq 1 ]; then
     13 		notify-send --urgency=normal "Battery fully charged" "Your battery is at $battery %"
     14 	fi
     15 	sleep 5m
     16 done