Add service files for systemd and D-Bus
orhun opened this issue · 1 comments
I tried to utilize the following service files for running runst
automatically via D-Bus activation but couldn't access the DISPLAY
from systemd unit:
/usr/share/dbus-1/services/org.orhun.runst.service
:
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/runst
SystemdService=runst.service
/usr/lib/systemd/user/runst.service
:
[Unit]
Description=Runst notification daemon
Documentation=man:runst(1)
PartOf=graphical-session.target
[Service]
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=/usr/bin/runst
Couldn't get this to work. It needs more investigation.
I tried to fiddle with this and ran into the a similar issue.
Mar 06 18:45:58 madagascar systemd[1859]: Starting Runst notification daemon...
Mar 06 18:45:58 madagascar runst[15414]: 2023-03-06T23:45:58.472377Z INFO runst: starting
Mar 06 18:45:58 madagascar systemd[1859]: Started Runst notification daemon.
Mar 06 18:46:12 madagascar runst[15414]: Failed to handle X11 events: X11 connection error: `Unknown connection error`
What I noted that is that if I run
systemctl --user restart runst.service
after login, then everything works fine.
I suspect what's going on here is that runst
is trying to connect to the X server before it's ready. There may be some sort of fix by configuring the systemd service to not launch right away, but it also occurs to me that the cleanest fix might be to delay opening the X connection until the first notification comes in. There's no real need to open an X connection right on startup, so delaying that initialization would be pretty reasonable.
I haven't checked, but this might be how dunst
is avoiding the issue (since it uses nearly identical systemd/d-bus service files and works fine on my computer).