[Tip] Logout of Plasma Session from the Terminal

By changing the numbers in the command you can do other log-out-related stuff.

As mentioned above

qdbus org.kde.ksmserver /KSMServer logout 1 0 1

will display the logout menu, with the “Log Out” button selected.

qdbus org.kde.ksmserver /KSMServer logout 1 1 1

will do the same, but with the “Restart” button selected. Changing it to 0 1 1 will restart your computer without prompting you. 0 2 1 will shut it down.

I’ll leave it to you to figure out what the other combinations do :wink:

At the moment, I have no idea what the third number does.

EDIT: I just did some more duckduckgoing and I found out an old post on Stack Overflow about it: https://askubuntu.com/questions/1871/how-can-i-safely-shutdown-reboot-logout-kde-from-the-command-line#1876

This may be outdated, but it appears that the three numbers are the following:

ShutdownConfirm ShutdownType ShutdownMode

ShutdownConfirm can take the following values:

-1: default
0: no
1: yes

ShutdownType can take the following values:

-1: default
0: none (log out)
1: reboot
2: halt (shutdown)
3: logout (same as 0? no idea…)

and finally, ShutdownMode can be:

-1: default
0: schedule
1: try now
2: force now
3: interactive

This is all for Plasma 4, so it may be outdated for Plasma 5. Also I have not noticed any difference with changing the ShutdownMode, further experiments are needed. :man_scientist:t3:

4 Likes