How to convert xdg/autostart processes to systemd services

As far as I understood, currently most if not all plasma services are automatically launched on login, and they are defined in /etc/xdg/autostart/.

This has several problems, such as annoying ones like DiscoverNotifier, or security relevant ones like kdeconnect-daemon not being trivial to disable.

I am currently experimenting with neutering these autostart entries and replacing them with systemd services.

Example for KDEConnect

# replace with empty entry (attempt to avoid distro updates reinstalling it)
sudo echo "" > /etc/xdg/autostart/org.kde.kdeconnect.daemon.desktop

# simple systemd service
sudo cat > /etc/systemd/user/org.kde.kdeconnect.service <<EOF
Description=Start the KDEConnect Daemon



This is a user service, which means it is part of the system, but can be managed by the user. This means following commands must not be ran with sudo!

systemctl --user daemon-reload
systemctl enable --user --now org.kde.kdeconnect.service

It works!

Now to improve them even further:

  1. replace all services (working on that, not that hard)
  2. find all requirements, make them as specific as possible
  3. find the correct order to run them (With Wants or After)
  4. Enhancement: Find out if they can be automatically activated
  5. Enhancement: group them together somehow

I hope there are some systemd expert here :smiley:



here is my initial script. It replaces all services in /etc/xdg/autostart/ with simple systemd services.

These services are placed in /etc/systemd/user/ so unprivileged users can manage them. They can be enabled or disabled individually per user, for example one user can use accessibility while another one doesnt.

The services state their Wants= entry, to define when they start. Some may start when a CLI interface is ready, some when a graphical interface is ready, some only when there is an active internet connection.

They should all state what other services depend on them, most notably plasmashell.

In the end the script enables a subset of them. This is alredy really great, as it allows to make plasma slimmer and more performant.

Example: Many users will not need XWaylandVideoBridge or legacy systray icons support, as they use modern Wayland apps. Also 95% will not need accessibility features.

Not launching these at all will likely decrease the systems resource usage and make it less “bloated”, as users can now choose what to start.

Pull requests welcome, lets experiment with this and discuss if something like this should replace the current old implementation!

There are also 3 different services for QEMU (Spice), VirtualBox and VMWare.

These have ExecStartPre lines in the service, which are validated. Only if the commands exit with “true” the ExecStart should run.

This is an experimental detection system, to make sure the services only run when they are actually needed.

Same with XWaylandVideobridge, which should only be ran if the user actually use a wayland session. (This makes little sense on Fedora Kinoite but well).

I suppose mainly false negatives should be found and fixed.