Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

3 Answers

up vote 14 down vote accepted

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.

share|improve this answer
    
Thanks. This is what I was looking for :) –  txwikinger Aug 10 '10 at 20:42
    
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 at 8:29
add comment

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.

share|improve this answer
add comment

I usually use init command for restart and ... . I like this command

# Default run level. The run levels are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS 
#   (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)


sjb@sjb-laptop~$ init 6
share|improve this answer
1  
This does not shutdown the desktop gracefully –  txwikinger Aug 10 '10 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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