Created
May 21, 2015 00:24
-
-
Save John-K/6333786adbb6f1afca13 to your computer and use it in GitHub Desktop.
bash oneliner: kill caffeinate when battery < 10% and not on AC power
This file contains hidden or 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
while true; do VAR=`pmset -g batt|tr -d "'%;"`; if [ `echo $VAR | awk '{print $4}'` == 'Battery' ]; then if [ `echo $VAR|awk '{print $7}'` -lt 100 ]; then echo "Killing caffeinate"; pkill caffeinate; fi; fi; sleep 2; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment