Created
August 26, 2019 21:17
-
-
Save AlD/26dd622eca640997ecbb8227261a2a43 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
sleep_cfg=/etc/systemd/sleep.conf.d/hibernate-reboot.conf | |
cleanup_cfg=/usr/lib/systemd/system-sleep/hibernate-reboot.sh | |
sudo mkdir -p "$(dirname "$sleep_cfg")" "$(dirname "$cleanup_cfg")" | |
sudo tee "$sleep_cfg" << '' | |
[Sleep] | |
HibernateMode=reboot | |
<<< '#!/bin/bash | |
case "$1" in | |
pre) echo "[hibernate-reboot] Going to reboot after hibernation" | |
;; | |
post) rm "'"$sleep_cfg"'" "'"$cleanup_cfg"'" || true | |
;; | |
*) exit 1 | |
;; | |
esac | |
' sudo tee "$cleanup_cfg" && sudo chmod +x "$cleanup_cfg" | |
systemctl hibernate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment