Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Battery status check
# To see available batteries run "upower -e"
BATTERY_PERCENTAGE=`upower -i /org/freedesktop/UPower/devices/DisplayDevice |grep percentage |awk -F: '{ print $2}' |awk -F% '{gsub(/ /, ""); print $1 }' |awk -F, '{ print $1 }'`
if [ $((BATTERY_PERCENTAGE)) -lt 10 ]; then
notify-send -u critical -c device -i /usr/share/icons/gnome/48x48/status/battery-low.png "Battery Level Low!" "%$BATTERY_PERCENTAGE"
# Crontab entry:
#*/3 * * * * export DISPLAY=:0.0 && /usr/local/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment