You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, September 18th 2005, 3:37am

Turn Off Computer From Desktop

How to I create an icon on the destop to take the place of the actions Kmenu, Logout, Turn Off Computer, in such a way as to save any active sessions?

Help is appreciated.

Thanks,
Bob

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Sunday, September 18th 2005, 3:02pm

You can do that through a script which uses the commandline DCOP client dcop

If you need it to work when more than one user is logged in, you have to run it as root and use --all-users --all-sessions switched

The target application is ksmserver, the target interface also ksmserver

For example (single user, single session, executed as that user)

#> dcop ksmserver ksmserver saveCurrentSession
#> dcop ksmserver ksmserver logout 0 2 0

Where 0 2 0 are values from http://developer.kde.org/documentation/l…pplication.html

0 (NoConfirm), 2 (ForceNow), 0 (Type None = just logout)

Cheers,
_
Qt/KDE Developer
Debian User

3

Wednesday, September 21st 2005, 12:06am

Turn Off Computer From Desktop

Anda,

Thank you for your direction. It is appreciated.

Here is the script I put together:

#!/bin/bash
dcop--all-users --all-sessions ksmserver ksmserver saveCurrentSession
dcop ksmserver ksmserver logout 0 2 0

I appears to save the session and then shut down.

However, when I start kde again the shell that the script ran in appears and the system shuts down again. When I start kde the second time the script shell is gone and kde stays up.

Am I missing something obvious?

Thanks for your help.

Bob

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Wednesday, September 21st 2005, 11:34am

Hmm, good question.

Maybe the session is also saving the script, but I have no idea how it would do that.

Do you execute that script in a terminal (I think there is an option for that when one creates the desktop icon link) or do you run it just like a normal program?

If you do the first, try the second approach.

Cheers,
_
Qt/KDE Developer
Debian User

5

Saturday, September 24th 2005, 9:37pm

I tried various options under Application, Advanced options and found that running without any opttions selected and DCOP Registration: None, it worked.

I takes about a minute to actually do anything visual and shut down, which at first made you wonder if was doing anything at all. But it worked.

Thanks for your help.

Bob