Comment 21 for bug 1871030

Revision history for this message
In , Linut (linut) wrote :

Created attachment 155243
KDE Connect systemd user unit

Sorry, somehow I totally forgot about this. Anyway, here is a proposal for a systemd user unit.
First, move /etc/xdg/autostart/org.kde.kdeconnect.daemon.desktop out of that autostart dir and make sure KDE Connect is not started (possibly kill it). Keep in mind that this file will come back if you reinstall or upgrade the package.
Then copy the file to ~/.config/systemd/user and do
# One time so systemd picks up the new file:
systemctl --user daemon-reload
# to start/stop:
systemctl --user start kdeconnect.service
systemctl --user stop kdeconnect.service
# to enable, which means it is started automatically when you login (and killed when you logout. The --now part also starts/stops it right away
systemctl --user enable --now kdeconnect.service
# and disable
systemctl --user disable --now kdeconnect.service
# output status and log (add e.g. -n 30, if you want to have more log lines)
systemctl --user status kdeconnect.service

The restart part isn't really necessary, it's merely a precaution to avoid spamming with restarts, should kdeconnect continue to crash for whatever reason.
From what I can tell, it works normally. I'm not sure about one thing though.
The xdg autostart file mentions "X-KDE-Wayland-Interfaces=org_kde_kwin_fake_input". I'm not sure what this does and if this means that it should be started after kwin?
We can't add a dependency on kwin, since 1. it's unclear whether the user actually uses the systemd units to start KDE (even though it's the default now) and 2. there is no kde.service, but two seperate service files plasma-kde_x11.service and plasma-kde_wayland.service.
I could maybe add something like After=plasma-kcminit.service, if that would make sense. Someone knowing the internals of kdeconnect better might help here.
There might be another way and that would be Type=dbus. Here we can actually let the service wait for the appearance of a certain service on dbus, e.g. org_kde_kwin_fake_input. However, I don't have any experience with this type of service yet, so I'd first would like some input on what org_kde_kwin_fake_input actually does and whether it's be necessary to add a dependency here before making the whole thing more complex. ;)

If you want a GUI to manage the systemd units, there is systemdgenie, which should be available via the typical package ressources.
Unfortunately, I don't think it's shipped with the default KDE installation, but I'm not sure. Could also depend on the distribution.