Created
November 28, 2016 17:16
-
-
Save sameer/a63f7f52afd4657ad2931b064c03bf7e to your computer and use it in GitHub Desktop.
Script that runs only if battery > 50% (tested on Ubuntu 16.04 4.4.0-47-generic)
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 | |
command() { | |
# enter command here | |
} | |
POWER=`upower -i $(upower -e | grep BAT) | grep --color=never -E percentage|xargs|cut -d' ' -f2|sed s/%//` | |
if [ "$POWER" -gt "50" ] | |
then | |
command | |
else | |
echo "Refusing to run command, battery is low." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment