I am not talking about shutdown and reboot commands. I want to initiate the same routine from command line that would be performed if I would press the logout/reboot/shutdown button inside the KDE desktop.

  • I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :) – myusuf3 Aug 10 '10 at 18:51
  • I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout – txwikinger Aug 10 '10 at 20:39

For kde4:

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

The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.

| improve this answer | |
  • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^ – user3099609 Feb 10 '14 at 8:29

For any version of KDE (maybe also GNOME and others):

In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):

xvkbd -text '\C\S\A\d'

You can create an alias for this (e.g. kdehalt);

My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.

| improve this answer | |

So I tried the answer presented by Gilles, but that only works for KDE4.

After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:

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

My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.