每 10 天自动启动一个 GUI 应用程序

每 10 天自动启动一个 GUI 应用程序

我的想法是定义一个 systemd 用户单元并用计时器单元启动它。但我甚至无法用以下单元手动启动应用程序:
~/.config/systemd/用户/信号桌面.service

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

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

[Install]

当我手动启动此装置时,我会在任务栏中看到该应用程序的图标,但约 15 秒后它再次消失,并且我再也没有看到应用程序窗口出现。

$ 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.

“活动:失败(结果:协议)”是什么意思?

另一种选择可能是使用cron带有 的工作anacron

答案1

它适用于:

~/.config/systemd/用户/信号桌面.service

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

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

[Install]

~/.config/systemd/用户/信号桌面.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

然后运行:

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.

因此,我的 GUI 应用程序会在每月的 3 号、13 号和 23 号凌晨 5:00 或更晚的时间启动,此时机器会被唤醒。每 10 天准确启动一次似乎是不可能的,除非有人有其他想法。

相关内容