# How can I do a remote logout from KDE?

Use the incredible dcop client!

To get an overview what is going on at the specific machine, type

    dcop --all-users --list-sessions

This will show all sessions by all users.

If you have the appropriate permissions you can picka specific user and session by typing

    dcop --user <username> --session <sessionid>

This will provide you with a list of all dcop-aware programms running in this session.

So let’s get to the logout. This is under controll of the KDE SessionManagemnet server.

    dcop --user <username> --session <sessionid> ksmserver default

provides a list of all available dcop commands to the specific programm. Among the list of ksmserver we will find `logout (int,int,int)`

The three integers have the following meanings:

- ShutdownConfirm
    - Default = -1: Obey the user’s confirmation setting.
    - No = 0: Don’t confirm, shutdown without asking.
    - Yes = 1: Always confirm, ask even if the user turned it off.
- ShutdownType
    - Default = -1: Select previous action or the default if it’s the first time.
    - None = 0: Only log out.
    - Reboot = 1: Log out and reboot the machine.
    - Halt = 2: Log out and halt the machine.
- ShutdownMode
    - Default = -1: Select previous mode or the default if it’s the first time.
    - Schedule = 0: Schedule a shutdown (halt or reboot) for the time all active sessions have exited.
    - TryNow = 1: Shut down, if no sessions are active. Otherwise do nothing.
    - ForceNow = 2: Force shutdown. Kill any possibly active sessions.
    - Interactive = 3: Pop up a dialog asking the user what to do if sessions are still active.

These flags are documented at [http://developer.kde.org/documentation/library/cvs-api/kdecore/html/classKApplication.html](https://web.archive.org/web/20050425021645/http://developer.kde.org/documentation/library/cvs-api/kdecore/html/classKApplication.html)

Thus, a logout could be initiated by

    dcop --user <username> --session <sessionid> ksmserver default logout 0,0,-1

More info of dcop at [http://developer.kde.org/documentation/library/kdeqt/dcop.html](https://web.archive.org/web/20061108034811/http://developer.kde.org/documentation/other/dcop.html) for the protocol and [http://www.volny.cz/bwian/dcop.html](https://web.archive.org/web/20070101143427/http://www.volny.cz/bwian/dcop.html) for the client program. 

salvaged from Wayback Machine at 2025-12-05, original timestamp 2005-11-23 15:15


