Last active
May 25, 2022 00:05
-
-
Save luckylittle/8dabdd8492f589cb74d920c6a436253a to your computer and use it in GitHub Desktop.
Make your computer go to sleep today at 16:59 (once)
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/zsh | |
# Old way of doing it: | |
# at -M 16:59 <<END | |
# /usr/bin/sudo /bin/systemctl hybrid-sleep | |
# END | |
# New way of doing it: | |
# systemd-analyze calendar --iterations=5 '16:59' <-- this would run every day | |
# systemd-analyze calendar "$(date +%Y-%m-%d) 16:59" <-- only today | |
systemd-run --user --on-calendar="$(date +%Y-%m-%d) 16:59" --timer-property=AccuracySec=1s --timer-property=RandomizedDelaySec=10s /bin/systemctl hybrid-sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: It creates these two files:
1.
And this unit can be listed:
As well as observe here:
To remove the timer, do not delete the transient files, instead run:
If you already deleted the transient files, remove them from systemd: