org.freedesktop.ConsoleKit.Manager

# 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)
    GetSessionByPID           (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)
    SessionNew            ('s' session_id,
                           'o' object_path)
    SessionRemoved        ('s' session_id,
                           'o' object_path)
    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

### GetSessionByPID ()

    GetSessionByPID (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

Since 1.1.1

`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

`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 SessionNew signal

    SessionNew ('s' session_id,
                'o' object_path)

Emitted when a session has been added to the system.

Since 1.1.1

`session_id`:

  The Session ID for the added session

`object_path`:

  The object path for the added session

### The SessionRemoved signal

    SessionRemoved ('s' session_id,
                    'o' object_path)

Emitted when a session has been removed from the system.

Since 1.1.1

`session_id`:

  The Session ID for the removed session

`object_path`:

  The object path for the removed session

### 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.