3

KDE supports saving sessions with arbitrary names. This can be accomplished by using the command saveCurrentSessionAs. For example, to save a session called 'session01', we execute

DISPLAY=:0.0 qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSessionAs "session01"

Then session01 will appear in the list returned by

DISPLAY=:0.0 qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.sessionList

as follows:

default
session01
saved by user
saved at previous logout

The content of all these saved sessions can be seen in $HOME/.config/ksmserverrc, which in particular will contain the lines

[Session: session01]
clientId1=102221941cd1ac000155588720400000011540004
clientId10=102221941cd1ac000155604496400000011810016

etc.

I would like to make the system assume the state described in session01.

I know of a hack to do it. I can manually overwrite, in the $HOME/.config/ksmserverrc file, the text corresponding to the saved by user session by the text corresponding to the session01 session. Now assume I have set up my system so that on login it restores the manually saved session (how to do that is described in the answer to this question: Save session settings in KDE environment without shutting down). Then on the next login, KDE will restore the state in saved by user—which of course will, after my hack, be identical to the state in session01.

This can be done through a script. Indeed, I believe this, more or less, has been done through a script, namely this old script from 2012 (look for the function sessionRestore).

But I am wondering if there is a way to do this without hacking. (The author of the script I just mentioned agrees that the script is a hack (not a solution)—see the end of this page). Here, then, is my question:

Is there a 'non-hacky' way of making my system assume the state saved in session01? In other words, is there a specific KDE command or a setting that will load that session, by name? And if there isn't, then what is the point of having saveCurrentSessionAs command?

(For what it's worth, I'm running KDE Plasma Version 5.12.7 on kubuntu 18.04.)

0 Answers0