Save session using shell command in KDE

kdescriptsessionshell

I can save my KDE session using the KDE start menu. But how could I achieve to save my session by shell command ?

Best Answer

If you're looking to save what the Session Management control module calls the "manually saved session":

qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSession

If you're looking to overwrite the session that normally gets saved upon logout:

qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSessionAs "saved at previous logout"

Get a list of existing sessions:

qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.sessionList
(Notable session names are "saved by user" and "saved at previous logout")

You can find more interesting commands if you omit the method from the command as such:

qdbus org.kde.ksmserver /KSMServer

Session data is stored in:

  • KDE 4: ~/.kde4/share/config/ksmserverrc
  • KDE 5: ~/.config/ksmserverrc