Skip to content

Instantly share code, notes, and snippets.

@Gaoithe
Created November 19, 2014 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaoithe/186ba4adaca66f2e020c to your computer and use it in GitHub Desktop.
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
#!/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