Skip to content

Instantly share code, notes, and snippets.

@cemkeylan
Created February 2, 2020 18:57
Show Gist options
  • Save cemkeylan/2b989cc072f0bd415cae4603131809b3 to your computer and use it in GitHub Desktop.
Save cemkeylan/2b989cc072f0bd415cae4603131809b3 to your computer and use it in GitHub Desktop.
#!/bin/sh
# nap - not the full zzz, but a light one
usage() { printf 'Usage: %s\nThere are not many options when taking a nap.\n' "${0##*/}" ; exit 1 ;}
[ "$1" ] && usage
grep -q mem /sys/power/state || { printf "Suspend not supported.\n"; exit 1 ;}
test -w /sys/power/state || { printf "Sleep permission denied.\n" ; exit 1 ;}
for hook in /etc/zzz.d/suspend/* ; do
[ -x "$hook" ] && "$hook"
done
printf mem >/sys/power/state || { printf "Could not suspend.\n" ; exit 1 ;}
for hook in /etc/zzz.d/resume/*; do
[ -x "$hook" ] && "$hook"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment