Score:0

Start a GUI app automatically each 10 days

cn flag

My idea is to define a systemd user unit and start it with a timer unit. But I even fail to start the application manually with the unit in:
~/.config/systemd/user/signal-desktop.service :

[Unit]
Description=Start Signal Desktop GUI
Requires=default.target

[Service]
Type=notify
ExecStart=/usr/bin/gtk-launch signal-desktop

[Install]

When I start this unit manually, I see the icon of the application in the task bar, but after ~15 sec. it disappears again, and I never see the app window appear.

$ systemctl --user start signal-desktop.service
Job for signal-desktop.service failed because the service did not take the steps required by its unit configuration.
See "systemctl --user status signal-desktop.service" and "journalctl --user -xeu signal-desktop.service" for details.
$ systemctl --user stop signal-desktop.service
$ systemctl --user status signal-desktop.service
× signal-desktop.service - Start Signal Desktop GUI
     Loaded: loaded (/home/ich/.config/systemd/user/signal-desktop.service; static)
     Active: failed (Result: protocol) since Mon 2023-05-01 00:08:22 CEST; 22s ago
    Process: 93087 ExecStart=/usr/bin/gtk-launch signal-desktop (code=exited, status=0/SUCCESS)
   Main PID: 93087 (code=exited, status=0/SUCCESS)
        CPU: 115ms

Mai 01 00:08:22 T500 systemd[1005]: Starting Start Signal Desktop GUI...
Mai 01 00:08:22 T500 systemd[1005]: signal-desktop.service: Failed with result 'protocol'.
Mai 01 00:08:22 T500 systemd[1005]: Failed to start Start Signal Desktop GUI.

What is meant by "Active: failed (Result: protocol)"?

An alternative may be using a cron job with anacron.

waltinator avatar
it flag
In any of these cases, it's not how the program is started, it's the environment variables in each environment. GUI applications use the `DISPLAY` environment variable to find the screen. `DISPLAY` isn't set in your other runtime environments. `echo "$DISPLAY"` in your GUI environment, and copy this value to your service, cron job, or whatever. Read `man xhost` to see how to allow other users to access your display.
CoSoCo avatar
cn flag
@waltinator With `Environment=DISPLAY=:0` I get the exact same result. Anyway I'm in the assumption, that `gtk-launch` is able to set all needed things for a GUI app. Thanks for you trial.
CoSoCo avatar
cn flag
@waltinator Additionally I don't understand, which "other user" could be meant, because it's me who starts the systemd unit, nobody else.
CoSoCo avatar
cn flag
I now found out, that I should set `Type=forking`.
Score:0
cn flag

It works with:

~/.config/systemd/user/signal-desktop.service :

[Unit]
Description=Start Signal Desktop GUI
Requires=default.target

[Service]
Type=forking
ExecStart=/usr/bin/gtk-launch signal-desktop

[Install]

~/.config/systemd/user/signal-desktop.timer :

[Unit]
Description=Timer for Signal Desktop GUI

[Timer]
OnCalendar=*-*-3/10 05:00:00
Persistent=true
Unit=signal-desktop.service

[Install]
WantedBy=default.target

Then run :

systemctl --user enable signal-desktop.timer 
systemctl --user start signal-desktop.timer  # only needed, if the timer should start immediately, thus before next logoff/-in.

So my GUI app starts each 3rd, 13th and 23rd of a month at 05:00, or later, when the machine is woken up. Exactly each 10 days seems not possible, except someone has an alternative idea.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.