KDE Shutdown, Logout, Restart

Inspired by this post.

It is interesting how simple specialised devices cope with their functions much better than a all-in-one PC. Sometimes, I wish to fall asleep with some music on. But how annoying it becomes, when you have to get up in the middle of the night to turn off your PC, which has been playing something all this time. Digital radios have mastered the trick decades ago. Of course there is a way to make a PC do it.

Running linux, I thought that it should be fairly straightforward to shut it down after say half an hour automatically.

Something like shutdown (below) will kill the X. The KDE then will just exit without saving the session. Next time you log on, you will see some session from a distant past. If you do this often, it gets really annoying. Also this requires superuser privileges on some distributions.

/sbin/shutdown -h now "Power button pressed"
# or
halt

Then how to make KDE quit without calling any dialogs (I am sound asleep by this time and I can't afford to wake up and press 'OK')? There is a way.

dcop ksmserver ksmserver logout 0 2 2

The three numbers are explained below (see source):

First parameter: confirm
Obey the user's confirmation setting: -1
Don't confirm, shutdown without asking: 0
Always confirm, ask even if the user turned it off: 1
Second parameter: type
Select previous action or the default if it's the first time: -1
Only log out: 0
Log out and reboot the machine: 1
Log out and halt the machine: 2
Third parameter: mode
Select previous mode or the default if it's the first time: -1
Schedule a shutdown (halt or reboot) for the time all active sessions have
exited: 0
Shut down, if no sessions are active. Otherwise do nothing: 1
Force shutdown. Kill any possibly active sessions: 2
Pop up a dialog asking the user what to do if sessions are still active: 3

2 thoughts on “KDE Shutdown, Logout, Restart

  1. Thank you ! Thank you ! Thank you !

    Why can’t the Debian folks list this information somewhere on their site ?
    Where did you find this ?

    Thank you again !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s