Created
November 19, 2014 00:31
-
-
Save Gaoithe/186ba4adaca66f2e020c to your computer and use it in GitHub Desktop.
Wish to suspend computer after a certain long-duration activity is finished. i.e. want to go to bed but not leave computer on all night
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 | |
# to run it optionally give it amount of seconds to wait | |
# e.g. two hours 7200, e.g. 10 mins 600 | |
echo e.g. invoke: sudo ~/bin/sleepandsuspend.sh 7200 | |
[[ "$USER" != "root" ]] && echo must run this as root. && exit 0; | |
SLEEP=3600 | |
[[ "$1" != "" ]] && SLEEP=$1 | |
which pm-suspend | |
[[ "$?" != 0 ]] && echo "Oh dear, I cannot run pm-suspend. This script will not work :-7" | |
echo will suspend after sleep=$SLEEP secs. USER=$USER | |
sleep $SLEEP && pm-suspend | |
# pmi action suspend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment