Last active
March 31, 2022 16:27
-
-
Save shollingsworth/1a8f6db7d15787f8a47b272a226795df to your computer and use it in GitHub Desktop.
disable / enable linux hibernation / sleep settings via systemd
This file contains hidden or 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
| #!/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