Skip to content

Instantly share code, notes, and snippets.

@ozgun
Created February 13, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozgun/e9f596943f5e9b9790600c02b4f3e184 to your computer and use it in GitHub Desktop.
Save ozgun/e9f596943f5e9b9790600c02b4f3e184 to your computer and use it in GitHub Desktop.
Battery status check
#!/bin/bash
# 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"
fi
# Crontab entry:
#*/3 * * * * export DISPLAY=:0.0 && /usr/local/bin/battery_status_check.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment