diff --git a/lowbatterycron.sh b/lowbatterycron.sh new file mode 100755 index 0000000..bddca00 --- /dev/null +++ b/lowbatterycron.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +BATTINFO=`acpi -b` +BATTERY=/sys/class/power_supply/BAT0 +REM=`grep "POWER_SUPPLY_CHARGE_NOW" $BATTERY/uevent | awk -F= '{ print $2 }'` +FULL=`grep "POWER_SUPPLY_CHARGE_FULL_DESIGN" $BATTERY/uevent | awk -F= '{ print $2 }'` +PERCENT=`echo $(( $REM * 100 / $FULL ))` + +if [[ `echo $BATTINFO | grep Discharging` && "$PERCENT" -lt "10" ]] ; then + DISPLAY=:0.0 /usr/bin/notify-send "low battery" "$BATTINFO" +fi \ No newline at end of file