? Editing: Post:21.body Save Delete Cancel
Content changed Sign & Publish new content

The Blinking Prompt Times █

Zite Index/Best Of
Latest znqa release : 0.2.0
I'm on ZeroMe
Feel free to propose a Chinese translation !
寻找这篇文章的翻译!
谢谢!
Best viewed in Dark Mode™, like anything else really :)

Follow in NewsfeedFollowing

Latest comments:

Add new post

Title

21 hours ago · 2 min read ·
3 comments
Body
Read more

Not found

Script : Wake your Linux system at a certain time with rtcwake

on Jun 13, 2019

Long time no post ZeroNet ! Thanks to the seeders keeping my zite alive 💪 31 hosts is more than I thought for a zite not updated in 6 months !

So here's another script I made which might be useful as a boilerplate to build your own, it allows you to start your Linux computer at a certain moment using rtcwake(8) and either S3 sleep (suspend to RAM) or hibernate sleep.

You need to have BIOS support for either RAM or disk sleep and sudo rights for rtcwake(8) to do its magic but otherwise the script can run as you regular user.

The script source an utils.sh file which should contains the stuff you want to run at wake time within a darkwake_system_maintenance function

It is affectionately named after the macOS internal name for the Power Nap feature (clearnet : https://www.howtogeek.com/277742/what-is-power-nap-in-macos/)

As usual, apologies for the poor formatting, I'll put a link to the plaintext file here if I find a good way to do so.

#!/bin/bash

DARKWAKE_VERSION="0.6.3"
DARKWAKE_UID=$(id -u)
DARKWAKE_MODE="disk"
DARKWAKE_ICON="/home/user/pixmaps/darkwake_icon.png"
TOMORROW=$(date --date "tomorrow" +%Y%m%d)
TODAY=$(date +%Y%m%d)
MORNING_TIME="0655"
MORNING_TIME_PRETTY="6h55"
EVENING_TIME="1745"
EVENING_TIME_PRETTY="17h45"
source /home/user/scripts/utils.sh

function darkwake_splash()
{
printf "DarkWake $DARKWAKE_VERSION, an RTC clock sleep/wake scheduler performing various actions.\n"
printf "UID: $DARKWAKE_UID, "
check_id
}

while test $# -gt 0; do
case "$1" in
--wake-this-morning|-m)
darkwake_splash
notify-send "DarkWake" "Will wake you up at $MORNING_TIME_PRETTY tomorrow" -i $DARKWAKE_ICON ; sleep 5
sudo rtcwake -m $DARKWAKE_MODE --date ${TOMORROW}${MORNING_TIME}00
darkwake_system_maintenance
break
;;
--wake-this-evening|-e)
darkwake_splash
notify-send "DarkWake" "Will welcome you back at $EVENING_TIME_PRETTY later today" -i $DARKWAKE_ICON ; sleep 5
sudo rtcwake -m $DARKWAKE_MODE --date ${TODAY}${EVENING_TIME}00
darkwake_system_maintenance
break
;;
--version|-v)
DARKWAKE_POWERNAP_HOURS=$((DARKWAKE_POWERNAP_TIME / 60))
darkwake_splash
notify-send "DarkWake $DARKWAKE_VERSION" "Sleep mode set to $DARKWAKE_MODE\nMorning : $MORNING_TIME_PRETTY | Evening : $EVENING_TIME_PRETTY" -i $DARKWAKE_ICON
break
;;
--help|-h)
darkwake_splash
printf "Available options : --wake-this-morning | --wake-this-evening | --version | --help\n"
break
;;
*)
break
;;
esac
done

Happy scripting !

2 Comments:

user_name1 day ago
Reply
Body
jamesholdenon Jun 14, 2019
Reply

caryoscelus: Wow, apparently i'm subscribed to another suddenly revived blog ;)

Have you tried using triple "back-quote"? ` (without spaces; starts and ends "raw" block)

You are, I do not post frequently but I sure hop in from time to time :)

Thanks for the tip, I'll definitely try next time

caryosceluson Jun 13, 2019
Reply

Wow, apparently i'm subscribed to another suddenly revived blog ;)

As usual, apologies for the poor formatting, I'll put a link to the plaintext file here if I find a good way to do so.

Have you tried using triple "back-quote"? ` ` ` (without spaces; starts and ends "raw" block)

This page is a snapshot of ZeroNet. Start your own ZeroNet for complete experience. Learn More