KF6 Proposal: Replace kded with systemd user services on systemd systems
A while ago in plasma 21 we had systemd boot and for a year this is default plasma/plasma-workspace!1356 (merged). On the other hand we are using kded which is a combination of background services and dbus-activated services which essentially duplicates the functionality of systemd user service manager.
The original objective was (from Readme)
Some things can be greatly simplified if they can be coordinated from a central place. KDED has support for modules that will be demand-loaded whenever an application attempts to make DBus call to the module. This can be useful for central administration tasks.
This was really useful in pre-systemd era.
Here is a somewhat oversimplified approach:
-
Refactor all dbus calls to org.kde.kded5
/modules/<module_name>/...
to some well known prefixed dbus call, for exampleorg.kde.kded6.<module_name>
or move them to respective api (like bluetooth, solid etc) specific prefixes altogether. -
Make all used kded modules as QApplications and generate respective systemd .service
files using the metadata in plugin.json. -
(Backward compatibility) Mark kded as an optional dependency and make kded service dbus activated unless there are any leftover phase-1 modules.
Current implementations and ui:
Moddules are present in /usr/lib64/qt5/plugins/kf5/kded/
. There is a kded kcm called "background services".
Referring to point 2 above, in my system (default installation of fedora) there are 34 modules.
appmenu.so baloosearchmodule.so bluedevil.so browserintegrationreminder.so colorcorrectlocationupdater.so colord.so desktopnotifier.so device_automounter.so dnssdwatcher.so filenamesearchmodule.so freespacenotifier.so gtkconfig.so kcookiejar.so kded_accounts.so kded_bolt.so kded_touchpad.so keyboard.so khotkeys.so kscreen.so ksysguard.so ktimezoned.so kwrited.so networkmanagement.so networkstatus.so plasma_accentcolor_service.so plasmavault.so printmanager.so proxyscout.so recentdocumentsnotifier.so remotenotifier.so smart.so smbwatcher.so soliduiserver.so statusnotifierwatcher.so
Porting all this might require a while but this can be done systematically and atomically.
Benefits of using systemd in place of kded:
- Stability: Currently if one module crashes it takes kded down. Sometime crashing module leads to a restart loop for
plasma-kded.service
which prevents plasma from booting up. - Parallelized startup using systemd.
- Dependency management and conditional invocation. For example keyboard module should only be activated in X11 session, hence
plasma-workspace-wayland.target
should not start that where it crashes (and takes kded with) on any method call. - (Better logging?)
For non systemd systems:
Conditionally enable kded subsystem similar to current systemd startup. Multiple inheritances, boilerplate class or preprocessor conditions will work well here. (Please comment if there is a better approach). Most module classes have small number of dbus methods.