Created
December 25, 2014 17:27
-
-
Save Akii/184afee617b467987bb9 to your computer and use it in GitHub Desktop.
Hibernates the computer after sleeping for a while (don't use this without an SSD for obvious reasons)
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
#!/bin/bash | |
# /usr/lib/systemd/system-sleep/auto-hibernate.sh | |
# Go to hibernate in 30 minutes | |
autohibernate=1800 | |
if [ "$1" = "pre" ] && [ "$2" = "suspend" ] | |
then | |
# Suspending, set RTC wake alarm | |
rtcwake -m no -s $autohibernate | |
fi | |
if [ "$1" = "post" ] && [ "$2" = "suspend" ] | |
then | |
# Coming out of sleep | |
lidState=$(awk '{print $2}' /proc/acpi/button/lid/LID/state) | |
# Wake up no longer required | |
rtcwake -m disable | |
if [ "$lidState" = "closed" ] | |
then | |
/usr/bin/systemctl hibernate | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment