Adds a low battery cron job

- See https://bbs.archlinux.org/viewtopic.php?id=138755
This commit is contained in:
Nemo 2018-01-01 23:58:52 +05:30
parent ce30098bad
commit cf7ca917a1
1 changed files with 11 additions and 0 deletions

11
lowbatterycron.sh Executable file
View File

@ -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