Skip to content

Instantly share code, notes, and snippets.

@tytso
Created November 21, 2018 22:12
Show Gist options
  • Save tytso/d4bc63c74451283e9a2c7c6c4bbe6e97 to your computer and use it in GitHub Desktop.
Save tytso/d4bc63c74451283e9a2c7c6c4bbe6e97 to your computer and use it in GitHub Desktop.
My suspend script
#!/bin/bash
# Install as /usr/local/bin/do-suspend
# Optionally add to your /etc/sudoers file:
# %sudo ALL=(ALL) NOPASSWD: /usr/local/bin/do-suspend
# You can then assign some keyboard shortcut to run this shell script
METHOD=deep
if [[ $EUID -ne 0 ]]; then
exec sudo /usr/local/bin/do-suspend $*
fi
if test "$1" = "--deep" ; then
METHOD=deep
elif test "$1" = "--s2idle" ; then
METHOD=s2idle
fi
/usr/bin/xflock4
sleep 0.5
echo $METHOD > /sys/power/mem_sleep
exec systemctl suspend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment