Created
May 14, 2017 13:41
-
-
Save connors511/55d5794cd1bd21487c4c2a1f394f466b to your computer and use it in GitHub Desktop.
Auto suspend & wake-up script
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 | |
# Auto suspend and wake-up script | |
# | |
# Puts the computer on standby and automatically wakes it up at specified time | |
# | |
# Written by Romke van der Meulen <[email protected]> | |
# Minor mods fossfreedom for AskUbuntu | |
# | |
# Takes a 24hour time HH:MM as its argument | |
# Example: | |
# suspend_until 9:30 | |
# suspend_until 18:45 | |
# ------------------------------------------------------ | |
# Argument check | |
if [ $# -lt 1 ]; then | |
echo "Usage: suspend_until HH:MM" | |
exit | |
fi | |
# Check whether specified time today or tomorrow | |
DESIRED=$((`date +%s -d "$1"`)) | |
NOW=$((`date +%s`)) | |
if [ $DESIRED -lt $NOW ]; then | |
DESIRED=$((`date +%s -d "$1"` + 24*60*60)) | |
fi | |
# Set RTC wakeup time | |
# N.B. change "disk" for the suspend option | |
# find this by "man rtcwake" | |
echo "$(date "+%d.%m.%Y %T") Suspending..." | |
/usr/sbin/rtcwake -u -m disk -t $DESIRED | |
echo "$(date "+%d.%m.%Y %T") Good morning!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment