Skip to content

Instantly share code, notes, and snippets.

@assafmo
Created April 14, 2018 14:10
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 assafmo/3f1dcc6130db656be72cf6d25d78a6df to your computer and use it in GitHub Desktop.
Save assafmo/3f1dcc6130db656be72cf6d25d78a6df to your computer and use it in GitHub Desktop.
Notify on low battery
#!/bin/bash
# "low" = lower than 60 because my chinese battery dies at 51%
cat /sys/class/power_supply/BAT0/uevent |
awk -F = '/_FULL=/{full=$2} /_NOW=/{now=$2} END{if(now/full < 0.6){print "Bettery " 100*now/full "%"}}' |
xargs notify-send
@assafmo
Copy link
Author

assafmo commented Apr 15, 2018

My computer died and won't turn on exactly 39 minutes after deploying this script in my crontab 😆 😭 😭 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment