summaryrefslogtreecommitdiffhomepage
path: root/blog/entry/systemdtimerpersistent.mdwn
blob: f53be1ea84f9b029d2f0adda076d2243eaf48b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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"