Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Last active August 29, 2015 14:04
Show Gist options
  • Save alenbasic/2888865a8241dfc5170f to your computer and use it in GitHub Desktop.
Save alenbasic/2888865a8241dfc5170f to your computer and use it in GitHub Desktop.
Was assigned to a cron job and if the power was low would send a notification saying so.
# this was initially designed for cinnamon, but cinnamon in its latest update offers this "out of the box"
export DISPLAY=:0.0
charge=$(cat /sys/class/power_supply/BAT1/capacity)
status=$(cat /sys/class/power_supply/BAT1/status)
if [[ $status != "Charging" ]]; then
if [[ $charge < 20 ]]; then
notify-send "Charge now is at $charge%" "Plug it in now!" --icon=dialog-warning
elif [[ $charge < 10 ]]; then
notify-send "Charge now is at $charge%" "PLUG IT IN NOW!!!" --icon=dialog-warning
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment