fxde-core/scripts/posix/batman

15 lines
595 B
Bash
Executable File

#!/bin/sh
while true
do if [ -e /sys/class/power_supply/BAT1/capacity ] # Do we have a battery to monitor?
then sleep 60
x=`cat /sys/class/power_supply/BAT1/capacity`
if [ $x -le 25 ] # When do we notify the user?
do aplay $FVWM_USERDIR/sounds/CritNotif.wav &
printf "Battery alert!\nYour battery only has a remaining capacity of $x%!" | xmessage -file - -center
sleep 300 # Don't spam the user!!!
x=`cat /sys/class/power_supply/BAT1/capacity` # Obtain new value.
else exit
fi
done