summaryrefslogtreecommitdiffhomepage
path: root/blog/entry/systemdtimerpersistent.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'blog/entry/systemdtimerpersistent.mdwn')
-rw-r--r--blog/entry/systemdtimerpersistent.mdwn36
1 files changed, 36 insertions, 0 deletions
diff --git a/blog/entry/systemdtimerpersistent.mdwn b/blog/entry/systemdtimerpersistent.mdwn
new file mode 100644
index 0000000..f53be1e
--- /dev/null
+++ b/blog/entry/systemdtimerpersistent.mdwn
@@ -0,0 +1,36 @@
+[[!meta title="Persistent=true when the timer never triggers when the system is powered up"]]
+[[!tag gnu+linux systemd]]
+
+I have this systemd timer unit
+
+[[!format ini """
+[Unit]
+Description=Run i3-rotate-wallpaper daily
+
+[Timer]
+OnCalendar=daily
+Persistent=true
+
+[Install]
+WantedBy=timers.target
+]]
+
+which says to start the i3-rotate-wallpaper.service unit at each
+midnight.
+
+`Persistent=true` is meant to ensure that the unit is triggered
+immediately when the system resumes from suspend or is powered on, if
+at the most recent midnight it was suspended or powered off. The idea
+is that when I first use my computer each day, the wallpaper gets
+changed -- I delight in seeing the wallpapers I've downloaded.
+
+The problem is that `Persistent=true` only works if the timer has been
+triggered at least once when the system is not suspended and powered
+on. But my computer is almost never on at midnight. I don't want to
+have to leave it turned on just for the first wallpaper change, or
+keep track of that when reinstalling the machine's operating system.
+
+The fix:
+
+ % mkdir -p "$HOME/.local/share/systemd/timers"
+ % touch "$HOME/.local/share/systemd/timers/stamp-i3-rotate-wallpaper.timer"