Reason for the blog

I'm changing KDE startup/shutdown a lot, whilst I aim to keep everything working exactly as before, please test this part thoroughly and report if you see any issues in the 5.15 cycle.

What is ksmserver?

In theory ksmserver is an X session manager.

An X session manager is responsible for saving/restoring your session when you log out and in

(and subsessions if you use activities) as well as prompting all your applications if it's safe to log out.

Currently this is one of the most important processes of the plasma session. Killing this process will immediately end the session.

As it runs all session it's a bit of a dumping ground for:

- handling all autostart (including plasmashell etc)

- running shutdown scripts

- screensaver

- some global shortcuts about session management

- spawning the logout prompts

- invoking the actual shutdown

Why change it?

As ksmserver handles startup our wayland session depends on X (or rather Xwayland), this is slower as we have to spawn it on startup, as well as being problematic for alternative devices where Xwayland may not be a useful option.

Also if we come up with a new session manager protocol that works well with wayland, we will need to replace just the session manager part.

Equally we have attempts to replace startup with for example, systemd units (and yes, there'd be a fallback) where we still want a working session manager.

In addition, some of the code isn't in the best state. It dates back to the 90s, without really having an active maintainer. There's been some significant changes to the way linux desktops work since that time. There's a lot to be cleaned up.

The plan

The golden rule is to refactor not rewrite. There have been numerous attempts at redoing startup, all good tech demos, but none are usable for production as they don't pay attention to matching with the current state and intricate startup hooks, something we need when we're talking about enterprise deployment who will have customisations.

The end goal is for KSMServer to be just an xsessionmanager. Allowing wayland-compatiable competitors to come alongside or potentially replace it down the line.

Startup and Shutdown will become multiple independent binaries (unix philosophy style) allowing them to be individually replaced all tied together with DBus activation. They will also be refactored to be considerably more readable.

Current state

There's been an internal refactor, which has been merged in master, the next step is to split into different processes once we've had feedback on the current work.