2018-01-01 18:28:52 +00:00
|
|
|
#!/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 ))`
|
2019-05-07 07:45:07 +00:00
|
|
|
# Put the below 2 in your crontab
|
2019-04-11 20:17:03 +00:00
|
|
|
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
|
|
|
|
XAUTHORITY=/home/nemo/.Xauthority
|
2018-01-01 18:28:52 +00:00
|
|
|
|
2018-10-21 12:40:17 +00:00
|
|
|
echo "Battery is at $PERCENT%"
|
|
|
|
|
|
|
|
if [[ `echo $BATTINFO | grep Discharging` && "$PERCENT" -lt "15" ]] ; then
|
|
|
|
echo "Not Charging, so alerting"
|
|
|
|
DISPLAY=:0.0 /usr/bin/notify-send --urgency=critical "Battery Running Low" "$BATTINFO"
|
2018-01-01 18:28:52 +00:00
|
|
|
fi
|