Last active
March 26, 2016 06:47
-
-
Save vivekannan/20191b674b8ba14c6fbd to your computer and use it in GitHub Desktop.
Simple BASH Script to mind battery charge level.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $(cat /sys/class/power_supply/BAT0/status) == "Charging" ]]; then | |
exit | |
fi | |
charge=$(cat /sys/class/power_supply/BAT0/capacity) | |
icon="/usr/share/icons/HighContrast/32x32/status/battery-caution.png" | |
if [[ $charge < 10 ]]; then | |
notify-send --icon=$icon "Critically low Battery level!" "Battery level is critically low!\nShutting down in 1 minute!" | |
sudo shutdown -h +1 | |
elif [[ $charge < 20 ]]; then | |
notify-send --icon=$icon "Low Battery level!" "Battery level is low!\nCurrent Charge: $charge %" | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment