Last active
January 29, 2018 21:23
-
-
Save xu-chris/fc3b0306bb89c11e0b24 to your computer and use it in GitHub Desktop.
Return true when Mac battery percentage is under 10 percent
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/sh | |
# Use this shell script in combination with ControlPlane (http://www.controlplaneapp.com) to detect | |
# and automatize when the battery percentage is lower or equal than 10 percent. | |
# For example: let ControlPlane close for you all Cloud applications when you to low battery life. | |
batteryPercentage=`pmset -g batt | egrep -ow '([0-9]{1,3})[^%]'` | |
lowbatPercentage=10 | |
if [ ${batteryPercentage} -le ${lowbatPercentage} ]; then | |
exit 0 | |
else | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment