Skip to content

Instantly share code, notes, and snippets.

@dhsathiya
Created April 21, 2020 19:26
Show Gist options
  • Save dhsathiya/88cba2a1ebb5a6025ae58aa1bcceb553 to your computer and use it in GitHub Desktop.
Save dhsathiya/88cba2a1ebb5a6025ae58aa1bcceb553 to your computer and use it in GitHub Desktop.
Notifies if battery is fully charged and/or low.
# Crontab Entries
# Notify if battery is full (equal to 100%)
*/1 * * * * if [ $(cat /sys/class/power_supply/BAT0/capacity) -eq 100 ]; then XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey "Battery Full"; fi
# Notify if battery is low (less than or equal to 10%)
*/1 * * * * if [ $(cat /sys/class/power_supply/BAT0/capacity) -le 10 ]; then XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey "Battery Low"; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment