Skip to content

Instantly share code, notes, and snippets.

@xor3r
Last active September 10, 2019 18:56
Show Gist options
  • Save xor3r/2d0874173c9ae0b032521f39098ff212 to your computer and use it in GitHub Desktop.
Save xor3r/2d0874173c9ae0b032521f39098ff212 to your computer and use it in GitHub Desktop.
Alert messages in case of low charge level
#!/bin/bash
file="/sys/class/power_supply/BAT0/capacity"
while IFS= read -r line
do
if [[ "$line" -le 10 ]]
then
notify-send -u critical "CRITICAL CHARGE LEVEL (10%)"
else
exit
fi
done < "$file"
@xor3r
Copy link
Author

xor3r commented Sep 10, 2019

If you want to schedule this script to be run every certain amount of time, use the following command (example for every 5 minutes):

watch -n 300 ./batteryAlert.sh

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