Skip to content

Instantly share code, notes, and snippets.

@shollingsworth
Last active March 31, 2022 16:27
Show Gist options
  • Save shollingsworth/1a8f6db7d15787f8a47b272a226795df to your computer and use it in GitHub Desktop.
Save shollingsworth/1a8f6db7d15787f8a47b272a226795df to your computer and use it in GitHub Desktop.
disable / enable linux hibernation / sleep settings via systemd
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
usage() {
echo "Usage: $0 <enable|disable>"
exit 1
}
action="${1:-}"
test -z "${action}" && usage
case "${action}" in
"disable")
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
;;
"enable")
systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment