# ConsoleKit2 1.0.0 Documentation

### William Jon McCann

`<william.jon.mccann@gmail.com>`

### Eric Koegel

`<eric.koegel@gmail.com>`

Version 1.0.0

# Introduction

# Part I. Concepts

## Chapter 1. Introduction

## About

ConsoleKit2 is a framework for keeping track of the various users, sessions, and seats present on a system. It provides a mechanism for software to react to changes of any of these items or of any of the metadata associated with them. ConsoleKit2 also allows fast switching between open sessions on the computer.

ConsoleKit2 is a fork of ConsoleKit since it is no longer maintained. Information on ConsoleKit can be found at: http://freedesktop.org/wiki/Software/ConsoleKit/ William Jon McCann was the primary maintainer of ConsoleKit and most of this documentation was written by him for ConsoleKit. It has been adapted for ConsoleKit2.

## Defining the Problem

A simple example is two users logging into a computer at the same time. They may be sharing the same set of hardware for their graphical session, such as the monitor, keyboard, and mouse. ConsoleKit2 will keep track of those resouces and which session is active and should have use of that hardware at a given time.

## Relevant art

Logind is a Linux daemon providing the similar functionality to ConsoleKit2.

## Chapter 2. Terminology

## Session

A session is a collection of all processes that share knowledge of a secret. In the typical (or ideal) case, these processes all originate from a single common ancestor.

As an implementation detail, for now, this secret should be stored in the process environment by the session leader under the name XDG_SESSION_COOKIE. When and if we are able to take advantage of a mechanism in the underlying system to store session registration information - we will. However, such a mechanism is not known at the present time.

Using an environment variable does have certain advantages. For one, it is quite easy for a process to opt-out of a Session by simply unsetting the XDG_SESSION_COOKIE variable.

Limitations of using an environment variable implementation include not being able to strictly limit visibility of the secret to a particular process ancestry. So, it is not possible to enforce session boundaries other than on a per-user basis. For example, we don't yet have a way to prevent a process from moving between sessions owned by the same user.

## Session leader

The session leader is the process that requests that a new session be opened. It does this by connecting to the D-Bus system bus and using either org.freedesktop.ConsoleKit.Manager.OpenSession() or org.freedesktop.ConsoleKit.Manager.OpenSessionWithParameters(). The session that it registers will remain open until the connection to the system bus is lost or it calls org.freedesktop.ConsoleKit.Manager.CloseSession().

The session leader is the only process for which CloseSession() will be allowed.

## Seat

A seat is a collection of sessions and a set of hardware (usually at least a keyboard and mouse). Only one session may be active on a seat at a time.

At the present time, all Sessions that are considered "local" to a system will be added the the first Seat and every other Session will be added to its own Seat.

True, hardware, multi-seat capabilities will be added in a later release.

## Chapter 3. Design

## Session Lifecycle

The session leader process is responsible for asking ConsoleKit2 to open a new session. In this respect, it is similar to the traditional POSIX user login accounting framework. In the typical case, the session leader is either an immediate descendant of a login manager or the login manager itself. The leader makes a connection to the D-Bus system bus and asks ConsoleKit2 to open a session. There are two methods available for opening a session: org.freedesktop.ConsoleKit.Manager.OpenSession() and org.freedesktop.ConsoleKit.Manager.OpenSessionWithParameters().

If the operation succeeds, a secret cookie will be returned to the session leader. The session leader should store this secret in the environment as XDG_SESSION_COOKIE so that it may be shared with its child processes.

At this point the session will be registered with ConsoleKit2 and a particular set of information about the session will be stored along with it.

ConsoleKit2 will decide, based on the information associated with the session, what Seat the session will be added to.

It will also be determined, based on the same set of information, whether the Session will control the hardware associated with the Seat. In other words, whether the Session will be active for the Seat it is attached to. The exact mechanism for this determination depends on the type of Seat and the capabilities of the host system.

The Session will remain open until the Session Leader disconnects from the D-Bus system bus or calls org.freedesktop.ConsoleKit.Manager.CloseSession(). The session will be removed from its Seat, and deregistered.

## Expected Usage

Use of this service will usually follow one of the following patterns:

### Text Login Manager

This pattern operates as the Session Leader for a new Session. This pattern needs:

1. To open a new Session.
2. To set properties for the Session.
3. To maintain a connection to the D-Bus system bus.
4. To close the Session at logout.

### Graphical Login Manager

In addition to the requirements for the Text Graphical Login Manager, this pattern is typically used to show information about currently open sessions. It needs:

1. To determine which Seat it is running on.
2. To know if the current seat supports session switching.
3. A list of all sessions on the current Seat.
4. To know which session is active for the current Seat.
5. To know when the session active state changes.
6. To know when sessions are added or removed.
7. Access to the metadata for any open Session.

### System Daemon

This is generally a daemon process running outside of a user session as a special user. This pattern needs:

1. To know if any user sessions are open.
2. To know if the system is currently being used.

### Hardware Abstraction Layer

This is a special case of System Daemon that provides catalogs and control mechanisms for hardware devices. In addition to the requirements of System Daemon, this pattern needs:

1. To determine what hardware is associated with a Seat.
2. To determine what Session is active and inactive on a particular Seat.
3. To know when the session active state changes.
4. To determine what Session a process belongs to.

### Fast User Switching Agent

This is related to the Graphical Login Manager and provides a shortcut to similar functionality. It is usually a tool available in the user session that allows one to quickly switch to another user session. This pattern needs:

1. To determine which session it is running in.
2. To determine which Seat it is running on.
3. To know if the current seat supports session switching.
4. A list of all sessions on the current Seat.
5. Which session is active for the current Seat.
6. To know when the session active state changes.
7. Access to the metadata for any open Session.
8. To know when sessions are added or removed.

### Session Daemon (aka Policy Agent)

This is typically a daemon running in a user session that acts on policy only when the session is active. This pattern needs:

1. To determine which session it is running in.
2. To know when the session active state changes.

### Session Application

This is typically an application running in a user session that may alter its behavior when the session active state changes. This pattern needs:

1. To determine which session it is running in.
2. To know when the session active state changes.

# Part II. Reference

# D-Bus API Reference

ConsoleKit2 provides a D-Bus API for programs to obtain information about the users, sessions, and seats that are present on a system.

Please see the other sections of this manual for an introduction to these concepts.

This API is not yet stable and is likely to change in the future.

## Name

org.freedesktop.ConsoleKit.Manager — Manager interface

## Methods

    Restart()
    CanRestart(out'b'can_restart)
    Stop()
    CanStop(out'b'can_stop)
    Reboot(in'b'policykit_interactivity)
    CanReboot(out's'can_reboot)
    PowerOff(in'b'policykit_interactivity)
    CanPowerOff(out's'can_poweroff)
    Suspend(in'b'policykit_interactivity)
    CanSuspend(out's'can_suspend)
    Hibernate(in'b'policykit_interactivity)
    CanHibernate(out's'can_hibernate)
    HybridSleep(in'b'policykit_interactivity)
    CanHybridSleep(out's'can_hybridsleep)
    Inhibit(in's'what,
    in's'who,
    in's'why,
    in's'mode,
    out'h'fd)
    ListInhibitors(out'a(ssssuu)'inhibitors)
    OpenSession(out's'cookie)
    OpenSessionWithParameters(in'a(sv)'parameters,
    out's'cookie)
    CloseSession(in's'cookie,
    out'b'result)
    GetSeats(out'ao'seats)
    GetSessions(out'ao'sessions)
    GetSessionForCookie(in's'cookie,
    out'o'ssid)
    GetSessionForUnixProcess(in'u'pid,
    out'o'ssid)
    GetCurrentSession(out'o'ssid)
    GetSessionsForUnixUser(in'u'uid,
    out'ao'sessions)
    GetSessionsForUser(in'u'uid,
    out'ao'sessions)
    GetSystemIdleHint(out'b'idle_hint)
    GetSystemIdleSinceHint(out's'iso8601_datetime)

## Signals

    SeatAdded('o'sid)
    SeatRemoved('o'sid)
    SystemIdleHintChanged('b'hint)
    PrepareForShutdown('b'active)
    PrepareForSleep('b'active)

## Implemented Interfaces

Objects implementing org.freedesktop.ConsoleKit.Manager also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties

## Description

## Details

### Restart ()

    Restart ()

This method initiates a request to restart (ie. reboot) the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

### CanRestart ()

    CanRestart (out'b'can_restart)

This method returns whether the user is authorized to restart the computer system.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

`can_restart`:

### Stop ()

    Stop ()

This method initiates a request to stop (ie. shutdown) the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

### CanStop ()

    CanStop (out'b'can_stop)

This method returns whether the user is authorized to shutdown the computer system.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

`can_stop`:

### Reboot ()

    Reboot (in'b'policykit_interactivity)

This method emulates the logind implementation. This method initiates a request to reboot the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

Since 0.9.2

`policykit_interactivity`:
  policykit_interactivity determines whether PolicyKit (if enabled) should interactively ask the user for authentication credentials if it needs to.

### CanReboot ()

    CanReboot (out's'can_reboot)

This method emulates the logind implementation.

Returns whether the system supports rebooting and whether the calling user is eligible to reboot the system.

Returns one of "na", "yes", "no" or "challenge".

If "na" is returned rebooting is not available because of hardware support.

If "yes" is returned rebooting is supported and the user may suspend without further authentication.

If "no" is returned rebooting is available but the user is not allowed to reboot.

If "challenge" is returned rebooting is available, but only after authorization.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

Since 0.9.2

`can_reboot`:

### PowerOff ()

    PowerOff (in'b'policykit_interactivity)

This method initiates a request to shutdown the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

Since 0.9.2

`policykit_interactivity`:
  policykit_interactivity determines whether PolicyKit (if enabled) should interactively ask the user for authentication credentials if it needs to.

### CanPowerOff ()

    CanPowerOff (out's'can_poweroff)

This method emulates the logind implementation.

Returns whether the system supports shutdown and whether the calling user is eligible to shutdown the system.

Returns one of "na", "yes", "no" or "challenge".

If "na" is returned shutdown is not available because of hardware support.

If "yes" is returned shutdown is supported and the user may hibernate without further authentication.

If "no" is returned shutdown is available but the user is not allowed to shutdown.

If "challenge" is returned shutdown is available, but only after authorization.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

Since 0.9.2

`can_poweroff`:

### Suspend ()

    Suspend (in'b'policykit_interactivity)

This method initiates a request to suspend the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

Since 0.9.2

`policykit_interactivity`:
  policykit_interactivity determines whether PolicyKit (if enabled) should interactively ask the user for authentication credentials if it needs to.

### CanSuspend ()

    CanSuspend (out's'can_suspend)

This method emulates the logind implementation.

Returns whether the system supports suspending and whether the calling user is eligible to hibernate the system.

Returns one of "na", "yes", "no" or "challenge".

If "na" is returned suspending is not available because of hardware support.

If "yes" is returned suspending is supported and the user may suspend without further authentication.

If "no" is returned suspending is available but the user is not allowed to suspend.

If "challenge" is returned suspending is available, but only after authorization.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

Since 0.9.1

`can_suspend`:

### Hibernate ()

    Hibernate (in'b'policykit_interactivity)

This method initiates a request to hibernate the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

Since 0.9.2

`policykit_interactivity`:
  policykit_interactivity determines whether PolicyKit (if enabled) should interactively ask the user for authentication credentials if it needs to.

### CanHibernate ()

    CanHibernate (out's'can_hibernate)

This method emulates the logind implementation.

Returns whether the system supports hibernation and whether the calling user is eligible to hibernate the system.

Returns one of "na", "yes", "no" or "challenge".

If "na" is returned hibernation is not available because of hardware support.

If "yes" is returned hibernation is supported and the user may hibernate without further authentication.

If "no" is returned hibernation is available but the user is not allowed to hibernate.

If "challenge" is returned hibernation is available, but only after authorization.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

Since 0.9.1

`can_hibernate`:

### HybridSleep ()

    HybridSleep (in'b'policykit_interactivity)

This method initiates a request to hybrid sleep (suspend + hibernate) the computer system.

May fail with: CK_MANAGER_ERROR_INHIBITED, CK_MANAGER_ERROR_INSUFFICIENT_PERMISSION, CK_MANAGER_ERROR_AUTHORIZATION_REQUIRED, CK_MANAGER_ERROR_GENERAL, CK_MANAGER_ERROR_BUSY

Since 0.9.2

`policykit_interactivity`:
  policykit_interactivity determines whether PolicyKit (if enabled) should interactively ask the user for authentication credentials if it needs to.

### CanHybridSleep ()

    CanHybridSleep (out's'can_hybridsleep)

This method emulates the logind implementation.

Returns whether the system supports hybrid sleep (suspend + hibernate) and whether the calling user is eligible to hybrid sleep the system.

Returns one of "na", "yes", "no" or "challenge".

If "na" is returned hybrid sleeping is not available because of hardware support.

If "yes" is returned hybrid sleeping is supported and the user may hybrid sleep without further authentication.

If "no" is returned hybrid sleeping is available but the user is not allowed to hybrid sleep.

If "challenge" is returned hybrid sleeping is available, but only after authorization.

May fail with: CK_MANAGER_ERROR_FAILED if polkit is used and fails checking authorization.

Since 0.9.1

`can_hybridsleep`:

### Inhibit ()

    Inhibit (in's'what,
    in's'who,
    in's'why,
    in's'mode,
    out'h'fd)

Inhibit locks are named pipes used by ConsoleKit2 to prevent the system from performing actions such as suspending, restarting, or going idle. There are various reasons and application would like to prevent one or more of these functions such as a movie player preventing the screen saving from activating or a package manager ensuring an application installs before allowing the computer to shutdown.

Note: Each application can have only one lock open at any given time. Multiple applications can hold locks to the same thing, for example a media player application and a cd burning application can both prevent the system from being marked idle.

May fail with: CK_MANAGER_ERROR_INVALID_INPUT, CK_MANAGER_ERROR_OOM, CK_MANAGER_ERROR_GENERAL

Since 0.9.0

See this simple example:

        DBusConnection *bus_connection;
        DBusMessage *message = NULL, *reply = NULL;
        DBusError error;
        gint fd = -1;
        const char *what = "shutdown:sleep";
        const char *who = "Xfburn";
        const char *why = "Burning a DVD, interrupting now will ruin the DVD.";
        const char *mode = "block";

        message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit",
                                                "/org/freedesktop/ConsoleKit/Manager",
                                                "org.freedesktop.ConsoleKit.Manager",
                                                "Inhibit");

        if (!message)
        {
            g_warning ("Unable to call Inhibit()");
            return fd;
        }

        if (!dbus_message_append_args (message,
                                       DBUS_TYPE_STRING, &what,
                                       DBUS_TYPE_STRING, &who,
                                       DBUS_TYPE_STRING, &why,
                                       DBUS_TYPE_STRING, &mode,
                                       DBUS_TYPE_INVALID))
        {
            g_warning ("Unable to call Inhibit()");
            dbus_message_unref (message);
            return fd;
        }

        reply = dbus_connection_send_with_reply_and_block (bus_connection, message, -1, &error);
        if (!reply)
        {
            g_warning ("Unable to inhibit: %s", error.message);
            dbus_message_unref (message);
            return fd;
        }

        if (!dbus_message_get_args (reply, &error,
                                    DBUS_TYPE_UNIX_FD, &fd,
                                    DBUS_TYPE_INVALID))
        {
            g_warning ("Inhibit() reply parsing failed: %s", error.message);
        }

        dbus_message_unref (message);
        dbus_message_unref (reply);
        dbus_error_free (&error);
        return fd;

`what`:
  What is a colon-separated list of lock types. The list of lock types are: shutdown, sleep, idle, handle-power-key, handle-suspend-key, handle-hibernate-key. Example: "shutdown:idle"
`who`:
  Who is a human-readable, descriptive string of who is taking the lock. Example: "Xfburn"
`why`:
  Why is a human-readable, descriptive string of why the program is taking the lock. Example: "Burning a DVD, interrupting now will ruin the DVD."
`mode`:
  Mode is either "block" or "delay" which determines if the inhibit lock is mandatory or should just delay the operation to a certain maximum time.
`fd`:
  Returns a file descriptor that encapsulates the lock, or -1 on failure. As soon as the file descriptor is closed (and all its duplicates) the lock is automatically released. If the client dies while the lock is taken it is automatically closed and the lock is released.

### ListInhibitors ()

    ListInhibitors (out'a(ssssuu)'inhibitors)

This method emulates the logind implementation.

Returns the current list of inhibitors, an array of strings representing the what, who, why, mode, and two unsigned int32 representing the user ID and process ID.

May fail with: CK_MANAGER_ERROR_GENERAL or CK_MANAGER_ERROR_NOTHING_INHIBITED.

Since 0.9.5

`inhibitors`:

### OpenSession ()

    OpenSession (out's'cookie)

This method requests that a new Session be created for the calling process. The properties of this new Session are set automatically from information collected about the calling process.

This new session exists until the calling process disconnects from the system bus or calls `CloseSession()`.

It is the responsibility of the calling process to set the environment variable XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only be made available to child processes of the caller so that they may be identified as members of this session.

May fail with: CK_MANAGER_ERROR_GENERAL

See this simple example:

    	DBusError       error;
    	DBusMessage    *message;
    	DBusMessage    *reply;

    	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit",
    						"/org/freedesktop/ConsoleKit/Manager",
    						"org.freedesktop.ConsoleKit.Manager",
    						"OpenSession");
    	if (message == NULL) {
    		goto out;
    	}

            dbus_error_init (&error);
            reply = dbus_connection_send_with_reply_and_block (connector->connection,
                                                               message,
                                                               -1,
                                                               &error);
            if (reply == NULL) {
    		goto out;
            }

            dbus_error_init (&error);
            if (! dbus_message_get_args (reply,
                                         &error,
                                         DBUS_TYPE_STRING, &cookie,
                                         DBUS_TYPE_INVALID)) {
    		goto out;
            }

`cookie`:
  The secret cookie that is used to identify the new session

See also: `OpenSessionWithParameters()`

### OpenSessionWithParameters ()

    OpenSessionWithParameters (in'a(sv)'parameters,
    out's'cookie)

This method requests that a new Session be created for the calling process. The properties of this new Session are from the parameters provided.

This new session exists until the calling process disconnects from the system bus or calls `CloseSession()`.

It is the responsibility of the calling process to set the environment variable XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only be made available to child processes of the caller so that they may be identified as members of this session.

See the Session properties for a list of valid parameters.

May fail with: CK_MANAGER_ERROR_GENERAL

`parameters`:
  An array of sets of property names and values
`cookie`:
  The secret cookie that is used to identify the new session

### Permissions

This method is restricted to privileged users by D-Bus policy.

See also: org.freedesktop.ConsoleKit.Session

### CloseSession ()

    CloseSession (in's'cookie,
    out'b'result)

This method is used to close the session identified by the supplied cookie.

The session can only be closed by the same process that opened the session.

`cookie`:
  The secret cookie that is used to identify the session
`result`:
  Whether the session was successfully closed

### GetSeats ()

    GetSeats (out'ao'seats)

This gets a list of all the Seats that are currently present on the system.

Each Seat ID is an D-Bus object path for the object that implements the Seat interface.

`seats`:
  an array of Seat IDs

See also: org.freedesktop.ConsoleKit.Seat

### GetSessions ()

    GetSessions (out'ao'sessions)

This gets a list of all the Sessions that are currently present on the system.

Each Session ID is an D-Bus object path for the object that implements the Session interface.

`sessions`:
  an array of Session IDs

See also: org.freedesktop.ConsoleKit.Session

### GetSessionForCookie ()

    GetSessionForCookie (in's'cookie,
    out'o'ssid)

Returns the session ID that is associated with the specified cookie.

May fail with: CK_MANAGER_ERROR_GENERAL

`cookie`:
  The secret cookie that is used to identify the session
`ssid`:
  The object identifier for the current session

### GetSessionForUnixProcess ()

    GetSessionForUnixProcess (in'u'pid,
    out'o'ssid)

Attempts to determine the session ID for the specified POSIX process ID (pid).

May fail with: CK_MANAGER_ERROR_GENERAL

`pid`:
  The POSIX process ID
`ssid`:
  The object identifier for the current session

### GetCurrentSession ()

    GetCurrentSession (out'o'ssid)

Attempts to determine the session ID that the caller belongs to.

May fail with: CK_MANAGER_ERROR_GENERAL

See this example of using dbus-send:

      dbus-send --system --dest=org.freedesktop.ConsoleKit \
      --type=method_call --print-reply --reply-timeout=2000 \
      /org/freedesktop/ConsoleKit/Manager \
      org.freedesktop.ConsoleKit.Manager.GetCurrentSession

`ssid`:
  The object identifier for the current session

### GetSessionsForUnixUser ()

    GetSessionsForUnixUser (in'u'uid,
    out'ao'sessions)

This gets a list of all the Sessions that are currently open for the specified user.

Each Session ID is an D-Bus object path for the object that implements the Session interface.

`uid`:
  POSIX User identification
`sessions`:
  an array of Session IDs

### GetSessionsForUser ()

    GetSessionsForUser (in'u'uid,
    out'ao'sessions)

This gets a list of all the Sessions that are currently open for the specified user.

Each Session ID is an D-Bus object path for the object that implements the Session interface.

`uid`:
  User identification
`sessions`:
  an array of Session IDs

### Warning

`GetSessionsForUser` is deprecated since version 0.1.3 and should not be used in newly-written code. Use `GetSessionsForUnixUser` instead.

### GetSystemIdleHint ()

    GetSystemIdleHint (out'b'idle_hint)

Returns TRUE if the `idle-hint` property of every open session is TRUE or if there are no open sessions.

`idle_hint`:
  The value of the system-idle-hint

### GetSystemIdleSinceHint ()

    GetSystemIdleSinceHint (out's'iso8601_datetime)

Returns an ISO 8601 date-time string that corresponds to the time of the last change of the system-idle-hint.

`iso8601_datetime`:
  An ISO 8601 format date-type string

## Signal Details

### The SeatAdded signal

    SeatAdded ('o'sid)

Emitted when a Seat has been added to the system.

`sid`:
  The Seat ID for the added seat

### The SeatRemoved signal

    SeatRemoved ('o'sid)

Emitted when a Seat has been removed from the system.

`sid`:
  The Seat ID for the removed seat

### The SystemIdleHintChanged signal

    SystemIdleHintChanged ('b'hint)

Emitted when the value of the system-idle-hint has changed.

`hint`:
  The value of the system-idle-hint

### The PrepareForShutdown signal

    PrepareForShutdown ('b'active)

Emitted when the system is halting (active = TRUE). If successful there will not be a FALSE signal emitted since the system will poweroff or reboot. It will emit a FALSE signal if the shutdown operation failed.

`active`:
  TRUE when the system is starting to halt.

### The PrepareForSleep signal

    PrepareForSleep ('b'active)

Emitted when the system is starting the sleep process. It will emit with an active = FALSE when resuming from sleep or if the sleep operation failed.

`active`:
  TRUE when starting to sleep.

## Name

org.freedesktop.ConsoleKit.Seat — Seat interface

## Methods

    GetId(out'o'sid)
    GetSessions(out'ao'sessions)
    GetDevices(out'a(ss)'devices)
    GetActiveSession(out'o'ssid)
    CanActivateSessions(out'b'can_activate)
    ActivateSession(in'o'ssid)

## Signals

    ActiveSessionChanged('o'ssid)
    SessionAdded('o'ssid)
    SessionRemoved('o'ssid)
    DeviceAdded('(ss)'device)
    DeviceRemoved('(ss)'device)

## Implemented Interfaces

Objects implementing org.freedesktop.ConsoleKit.Seat also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties

## Description

A seat is a collection of sessions and a set of hardware (usually at least a keyboard and mouse). Only one session may be active on a seat at a time.

## Details

### GetId ()

    GetId (out'o'sid)

Returns the ID for Seat.

`sid`:
  Seat ID

### GetSessions ()

    GetSessions (out'ao'sessions)

This gets a list of all the Sessions that are currently attached to this seat.

Each Session ID is an D-Bus object path for the object that implements the Session interface.

`sessions`:
  an array of Session IDs

### GetDevices ()

    GetDevices (out'a(ss)'devices)

This gets a list of all the devices that are currently associated with this seat.

Each device is an D-Bus structure that represents the device type and the device id.

`devices`:
  an array of devices

### GetActiveSession ()

    GetActiveSession (out'o'ssid)

Gets the Session ID that is currently active on this Seat.

Fails with CK_SEAT_ERROR_NO_ACTIVE_SESSION if there is no active session.

`ssid`:
  Session ID

### CanActivateSessions ()

    CanActivateSessions (out'b'can_activate)

Used to determine whether the seat supports session activation.

`can_activate`:
  TRUE if seat supports session activation

### ActivateSession ()

    ActivateSession (in'o'ssid)

Attempt to activate the specified session. In most cases, if successful, this will cause the session to become visible and take control of the hardware that is associated with this seat.

May fail with: CK_SEAT_ERROR_FAILED, CK_SEAT_ERROR_ALREADY_ACTIVE, CK_SEAT_ERROR_NOT_SUPPORTED

`ssid`:
  Session ID

See also: `Activate()`

## Signal Details

### The ActiveSessionChanged signal

    ActiveSessionChanged ('o'ssid)

Emitted when the active session has changed.

`ssid`:
  Session ID

### The SessionAdded signal

    SessionAdded ('o'ssid)

Emitted when a session has been added to the seat.

`ssid`:
  Session ID

### The SessionRemoved signal

    SessionRemoved ('o'ssid)

Emitted when a session has been removed from the seat.

`ssid`:
  Session ID

### The DeviceAdded signal

    DeviceAdded ('(ss)'device)

Emitted when a device has been associated with the seat.

`device`:
  Device structure

### The DeviceRemoved signal

    DeviceRemoved ('(ss)'device)

Emitted when a device has been dissociated from the seat.

`device`:
  Device structure

## Name

org.freedesktop.ConsoleKit.Session — Session interface

## Methods

    GetId(out'o'ssid)
    GetSeatId(out'o'sid)
    GetSessionType(out's'type)
    GetUser(out'u'uid)
    GetUnixUser(out'u'uid)
    GetX11Display(out's'display)
    GetX11DisplayDevice(out's'x11_display_device)
    GetDisplayDevice(out's'display_device)
    GetRemoteHostName(out's'remote_host_name)
    GetLoginSessionId(out's'login_session_id)
    IsActive(out'b'active)
    IsLocal(out'b'local)
    GetCreationTime(out's'iso8601_datetime)
    Activate()
    Lock()
    Unlock()
    GetIdleHint(out'b'idle_hint)
    GetIdleSinceHint(out's'iso8601_datetime)
    SetIdleHint(in'b'idle_hint)

## Signals

    ActiveChanged('b'is_active)
    IdleHintChanged('b'hint)
    Lock()
    Unlock()

## Implemented Interfaces

Objects implementing org.freedesktop.ConsoleKit.Session also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties

## Properties

    'unix-user'readwrite'u'
    'user'readwrite'u'
    'session-type'readwrite's'
    'remote-host-name'readwrite's'
    'display-device'readwrite's'
    'x11-display'readwrite's'
    'x11-display-device'readwrite's'
    'active'readwrite'b'
    'is-local'readwrite'b'
    'idle-hint'readwrite'b'

## Description

Session objects represent and store information related to a user session.

The properties associated with the Session specifically refer to the properties of the "session leader".

## Details

### GetId ()

    GetId (out'o'ssid)

Returns the ID for Session.

`ssid`:
  Session ID

### GetSeatId ()

    GetSeatId (out'o'sid)

Returns the ID for the Seat the Session is attached to.

May fail with CK_SESSION_ERROR_FAILED if the session isn't attached to a seat

`sid`:
  Seat ID

See also: org.freedesktop.ConsoleKit.Seat

### GetSessionType ()

    GetSessionType (out's'type)

Returns the type of the session.

Warning: we haven't yet defined the allowed values for this property. It is probably best to avoid this until we do.

`type`:
  Session type

See also: `session-type`

### GetUser ()

    GetUser (out'u'uid)

Returns the user that the session belongs to.

`uid`:
  User ID

### Warning

`GetUser` is deprecated since version 0.1.3 and should not be used in newly-written code. Use `GetUnixUser` instead.

See also: `user`

### GetUnixUser ()

    GetUnixUser (out'u'uid)

Returns the POSIX user ID that the session belongs to.

`uid`:
  POSIX User ID

See also: `unix-user`

### GetX11Display ()

    GetX11Display (out's'display)

Returns the value of the X11 DISPLAY for this session if one is present.

`display`:
  The value of the X11 display

See also: `x11-display`

### GetX11DisplayDevice ()

    GetX11DisplayDevice (out's'x11_display_device)

Returns the value of the display device (aka TTY) that the X11 display for the session is connected to. If there is no x11-display set then this value is undefined.

`x11_display_device`:
  The value of the X11 display device

See also: `x11-display-device`

### GetDisplayDevice ()

    GetDisplayDevice (out's'display_device)

Returns the value of the display device (aka TTY) that the session is connected to.

`display_device`:
  The value of the display device

See also: `display-device`

### GetRemoteHostName ()

    GetRemoteHostName (out's'remote_host_name)

Returns the value of the remote host name for the session.

`remote_host_name`:
  The remote host name

See also: `remote-host-name`

### GetLoginSessionId ()

    GetLoginSessionId (out's'login_session_id)

Returns the value of the login session ID that the underlying system uses to enforce session boundaries. If there is no login session ID set then this value is an empty string.

`login_session_id`:
  The value of the native system login session ID

### IsActive ()

    IsActive (out'b'active)

Returns whether the session is active on the Seat that it is attached to.

If the session is not attached to a seat this value is undefined.

`active`:
  TRUE if the session is active, otherwise FALSE

See also: `active`

### IsLocal ()

    IsLocal (out'b'local)

Returns whether the session is local

FIXME: we need to come up with a concrete definition for this value. It was originally used as a way to identify XDMCP sessions that originate from a remote system.

`local`:
  TRUE if the session is local, otherwise FALSE

See also: `is-local`

### GetCreationTime ()

    GetCreationTime (out's'iso8601_datetime)

Returns an ISO 8601 date-time string that corresponds to the time that the session was opened.

`iso8601_datetime`:
  An ISO 8601 format date-type string

### Activate ()

    Activate ()

Attempt to activate the this session. In most cases, if successful, this will cause the session to become visible and become active on the seat that it is attached to.

May fail with: CK_SESSION_ERROR_ALREADY_ACTIVE, CK_SESSION_ERROR_NOT_SUPPORTED, CK_SESSION_ERROR_GENERAL

See also: `Seat.ActivateSession()`

### Lock ()

    Lock ()

This will cause a `Lock` signal to be emitted for this session.

### Permissions

This method is restricted to privileged users by D-Bus policy.

See also: `Lock signal`

### Unlock ()

    Unlock ()

This will cause an `Unlock` signal to be emitted for this session.

This can be used by login managers to unlock a session before it is re-activated during fast-user-switching.

### Permissions

This method is restricted to privileged users by D-Bus policy.

See also: `Unlock signal`

### GetIdleHint ()

    GetIdleHint (out'b'idle_hint)

Gets the value of the `idle-hint` property.

`idle_hint`:
  The value of the idle-hint

See also: `idle-hint`

### GetIdleSinceHint ()

    GetIdleSinceHint (out's'iso8601_datetime)

Returns an ISO 8601 date-time string that corresponds to the time of the last change of the idle-hint.

`iso8601_datetime`:
  An ISO 8601 format date-type string

### SetIdleHint ()

    SetIdleHint (in'b'idle_hint)

This may be used by the session to indicate that it is idle.

Use of this method is restricted to the user that owns the session.

`idle_hint`:
  boolean value to set the idle-hint to

## Signal Details

### The ActiveChanged signal

    ActiveChanged ('b'is_active)

Emitted when the active property has changed.

`is_active`:
  TRUE if the session is active, otherwise FALSE

### The IdleHintChanged signal

    IdleHintChanged ('b'hint)

Emitted when the idle-hint property has changed.

`hint`:
  the new value of idle-hint

### The Lock signal

    Lock ()

Emitted in response to a call to the `Lock()` method.

It is intended that the screensaver for the session should lock the screen in response to this signal.

### The Unlock signal

    Unlock ()

Emitted in response to a call to the `Unlock()` method.

It is intended that the screensaver for the session should unlock the screen in response to this signal.

## Property Details

### The "unix-user" property

    'unix-user'readwrite'u'

The user assigned to the session.

### The "user" property

    'user'readwrite'u'

The user assigned to the session.

### Warning

`user` is deprecated since version 0.1.3 and should not be used in newly-written code. Use `unix-user` instead.

### The "session-type" property

    'session-type'readwrite's'

The type of the session.

Warning: we haven't yet defined the allowed values for this property. It is probably best to avoid this until we do.

### The "remote-host-name" property

    'remote-host-name'readwrite's'

The remote host name for the session.

This will be set in situations where the session is opened and controlled from a remote system.

For example, this value will be set when the session is created from an SSH or XDMCP connection.

### The "display-device" property

    'display-device'readwrite's'

The display device (aka TTY) that the session is connected to.

### The "x11-display" property

    'x11-display'readwrite's'

Value of the X11 DISPLAY for this session if one is present.

### The "x11-display-device" property

    'x11-display-device'readwrite's'

The display device (aka TTY) that the X11 display for the session is connected to. If there is no x11-display set then this value is undefined.

### The "active" property

    'active'readwrite'b'

Whether the session is active on the Seat that it is attached to.

If the session is not attached to a seat this value is undefined.

### The "is-local" property

    'is-local'readwrite'b'

Whether the session is local

FIXME: we need to come up with a concrete definition for this value. It was originally used as a way to identify XDMCP sessions that originate from a remote system.

### The "idle-hint" property

    'idle-hint'readwrite'b'

This is a hint used to indicate that the session may be idle.

For sessions with a `x11-display` set (ie. graphical sessions), it is up to each session to delegate the responsibility for updating this value. Typically, the screensaver will set this.

However, for non-graphical sessions with a `display-device` set the Session object itself will periodically update this value based on the activity detected on the display-device itself.

This should not be considered authoritative.

# Index

### A

Activate
  Session, Activate ()
ActivateSession
  Seat, ActivateSession ()
active
  Session, The "active" property
ActiveChanged
  Session, The ActiveChanged signal
ActiveSessionChanged
  Seat, The ActiveSessionChanged signal

### C

CanActivateSessions
  Seat, CanActivateSessions ()
CanHibernate
  Manager, CanHibernate ()
CanHybridSleep
  Manager, CanHybridSleep ()
CanPowerOff
  Manager, CanPowerOff ()
CanReboot
  Manager, CanReboot ()
CanRestart
  Manager, CanRestart ()
CanStop
  Manager, CanStop ()
CanSuspend
  Manager, CanSuspend ()
CloseSession
  Manager, CloseSession ()

### D

DeviceAdded
  Seat, The DeviceAdded signal
DeviceRemoved
  Seat, The DeviceRemoved signal
display-device
  Session, The "display-device" property

### G

GetActiveSession
  Seat, GetActiveSession ()
GetCreationTime
  Session, GetCreationTime ()
GetCurrentSession
  Manager, GetCurrentSession ()
GetDevices
  Seat, GetDevices ()
GetDisplayDevice
  Session, GetDisplayDevice ()
GetId
  Seat, GetId ()
  Session, GetId ()
GetIdleHint
  Session, GetIdleHint ()
GetIdleSinceHint
  Session, GetIdleSinceHint ()
GetLoginSessionId
  Session, GetLoginSessionId ()
GetRemoteHostName
  Session, GetRemoteHostName ()
GetSeatId
  Session, GetSeatId ()
GetSeats
  Manager, GetSeats ()
GetSessionForCookie
  Manager, GetSessionForCookie ()
GetSessionForUnixProcess
  Manager, GetSessionForUnixProcess ()
GetSessions
  Manager, GetSessions ()
  Seat, GetSessions ()
GetSessionsForUnixUser
  Manager, GetSessionsForUnixUser ()
GetSessionsForUser
  Manager, GetSessionsForUser ()
GetSessionType
  Session, GetSessionType ()
GetSystemIdleHint
  Manager, GetSystemIdleHint ()
GetSystemIdleSinceHint
  Manager, GetSystemIdleSinceHint ()
GetUnixUser
  Session, GetUnixUser ()
GetUser
  Session, GetUser ()
GetX11Display
  Session, GetX11Display ()
GetX11DisplayDevice
  Session, GetX11DisplayDevice ()

### H

Hibernate
  Manager, Hibernate ()
HybridSleep
  Manager, HybridSleep ()

### I

idle-hint
  Session, The "idle-hint" property
IdleHintChanged
  Session, The IdleHintChanged signal
Inhibit
  Manager, Inhibit ()
is-local
  Session, The "is-local" property
IsActive
  Session, IsActive ()
IsLocal
  Session, IsLocal ()

### L

ListInhibitors
  Manager, ListInhibitors ()
Lock
  Session, Lock (), The Lock signal

### O

OpenSession
  Manager, OpenSession ()
OpenSessionWithParameters
  Manager, OpenSessionWithParameters ()

### P

PowerOff
  Manager, PowerOff ()
PrepareForShutdown
  Manager, The PrepareForShutdown signal
PrepareForSleep
  Manager, The PrepareForSleep signal

### R

Reboot
  Manager, Reboot ()
remote-host-name
  Session, The "remote-host-name" property
Restart
  Manager, Restart ()

### S

SeatAdded
  Manager, The SeatAdded signal
SeatRemoved
  Manager, The SeatRemoved signal
session-type
  Session, The "session-type" property
SessionAdded
  Seat, The SessionAdded signal
SessionRemoved
  Seat, The SessionRemoved signal
SetIdleHint
  Session, SetIdleHint ()
Stop
  Manager, Stop ()
Suspend
  Manager, Suspend ()
SystemIdleHintChanged
  Manager, The SystemIdleHintChanged signal

### U

unix-user
  Session, The "unix-user" property
Unlock
  Session, Unlock (), The Unlock signal
user
  Session, The "user" property

### X

x11-display
  Session, The "x11-display" property
x11-display-device
  Session, The "x11-display-device" property