-
-
Save momolog/e12b9c25c9e976a76733cbadbf032bbb to your computer and use it in GitHub Desktop.
nap utility, put this into `~/bin/nap`
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 [ -z $1 ]; then | |
echo "No time provided. Usage: nap [-cl] [minutes]" | |
exit 2 | |
fi | |
if [[ $1 == *c ]]; then | |
echo Cancelling sleep. PIDs \(if any\): `pgrep -f "nap"` | |
pkill -f "nap" | |
exit 0 | |
fi | |
if [[ $1 == *l ]]; then | |
ps -Af | grep nap | |
exit 0 | |
fi | |
time=$(($1 * 60)) | |
echo Sleeping in $1 minutes... | |
sleep $time && pmset sleepnow& |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment