ConsoleKit2 Documentation
Chapter 1. Introduction
Report bugs and feature requests
Communication can be done through github comments/issues as well as on the IRC channel ConsoleKit2 on freenode. You can easily join the channel by going to Freenode Webchat
Table of Contents
- Introduction
- I. Concepts
- II. Reference
- I. D-Bus API Reference
- org.freedesktop.ConsoleKit.Manager — Manager interface
- org.freedesktop.ConsoleKit.Seat — Seat interface
- org.freedesktop.ConsoleKit.Session — Session interface
- Index
Table of Contents
Table of Contents
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.
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.
Table of Contents
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.
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.
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.
Table of Contents
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.
Use of this service will usually follow one of the following patterns:
This pattern operates as the Session Leader for a new Session. This pattern needs:
- To open a new Session.
- To set properties for the Session.
- To maintain a connection to the D-Bus system bus.
- To close the Session at logout.
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:
- To determine which Seat it is running on.
- To know if the current seat supports session switching.
- A list of all sessions on the current Seat.
- To know which session is active for the current Seat.
- To know when the session active state changes.
- To know when sessions are added or removed.
- Access to the metadata for any open Session.
This is generally a daemon process running outside of a user session as a special user. This pattern needs:
- To know if any user sessions are open.
- To know if the system is currently being used.
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:
- To determine what hardware is associated with a Seat.
- To determine what Session is active and inactive on a particular Seat.
- To know when the session active state changes.
- To determine what Session a process belongs to.
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:
- To determine which session it is running in.
- To determine which Seat it is running on.
- To know if the current seat supports session switching.
- A list of all sessions on the current Seat.
- Which session is active for the current Seat.
- To know when the session active state changes.
- Access to the metadata for any open Session.
- To know when sessions are added or removed.
This is typically a daemon running in a user session that acts on policy only when the session is active. This pattern needs:
- To determine which session it is running in.
- To know when the session active state changes.
Table of Contents
- I. D-Bus API Reference
- org.freedesktop.ConsoleKit.Manager — Manager interface
- org.freedesktop.ConsoleKit.Seat — Seat interface
- org.freedesktop.ConsoleKit.Session — Session interface
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.
Table of Contents
- org.freedesktop.ConsoleKit.Manager — Manager interface
- org.freedesktop.ConsoleKit.Seat — Seat interface
- org.freedesktop.ConsoleKit.Session — Session interface
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) ActivateSession (in 's' session_id) ActivateSessionOnSeat (in 's' session_id, in 's' seat_id) LockSession (in 's' session_id) UnlockSession (in 's' session_id) 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
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
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
ActivateSession ()
ActivateSession (in 's' session_id)
This method is used to activate the specified session.
May fail with: CK_MANAGER_ERROR_INVALID_INPUT, CK_MANAGER_ERROR_NO_SEATS, CK_MANAGER_ERROR_GENERAL
Since 1.2.0
session_id
:- The session to activate
ActivateSessionOnSeat ()
ActivateSessionOnSeat (in 's' session_id, in 's' seat_id)
This method is used to activate the specified session as as long as it's on the seat_id.
May fail with: CK_MANAGER_ERROR_INVALID_INPUT, CK_MANAGER_ERROR_GENERAL
Since 1.2.0
session_id
:- The session to activate
seat_id
:- The seat to activate the session on
LockSession ()
LockSession (in 's' session_id)
This will cause a Lock
signal to be emitted for this session.
session_id
:- The session to lock
Permissions
See also:
Lock signal
UnlockSession ()
UnlockSession (in 's' session_id)
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.
session_id
:- The session to unlock
Permissions
See also:
Unlock signal
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
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
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.
Name
org.freedesktop.ConsoleKit.Seat — Seat interface
Methods
GetId (out 'o' sid) GetName (out 's' name) GetSessions (out 'ao' sessions) GetDevices (out 'a(ss)' devices) GetActiveSession (out 'o' ssid) CanActivateSessions (out 'b' can_activate) ActivateSession (in 'o' ssid) SwitchTo (in 'u' vtnr)
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
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()
SwitchTo ()
SwitchTo (in 'u' vtnr)
Attempt to activate the specified VT. 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, CK_SEAT_ERROR_GENERAL
Since 1.1.1
vtnr
:- Virtual Terminal to switch to.
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
Name
org.freedesktop.ConsoleKit.Session — Session interface
Methods
GetId (out 'o' ssid) GetSeatId (out 'o' sid) GetSessionType (out 's' type) GetSessionClass (out 's' type) GetSessionState (out 's' type) GetUser (out 'u' uid) GetUnixUser (out 'u' uid) GetXDGRuntimeDir (out 's' xdg_runtime_dir) 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) GetVTNr (out 'u' VTNr) 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) SetLockedHint (in 'b' locked_hint) TakeControl (in 'b' force) ReleaseControl () TakeDevice (in 'u' major, in 'u' minor, out 'h' fd, out 'b' inactive) ReleaseDevice (in 'u' major, in 'u' minor) PauseDeviceComplete (in 'u' major, in 'u' minor)
Signals
PauseDevice ('u' major, 'u' minor, 's' type) ResumeDevice ('u' major, 'u' minor, 'h' fd) 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' read 'u' 'user' read 'u' 'Seat' read '(so)' 'session-type' read 's' 'session-class' read 's' 'session-state' read 's' 'remote-host-name' read 's' 'display-device' read 's' 'x11-display' read 's' 'x11-display-device' read 's' 'VTNr' read 'u' 'active' read 'b' 'is-local' read 'b' 'idle-hint' readwrite 'b' 'LockedHint' read '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
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 display type of the provided session. The following type may be returned:
"x11" - An X11/Xorg based session
"wayland" - A Wayland based session
"tty" - A text console based session
"mir" - A session using the Mir display server
"unspecified" - Unknown session type, the default.
Note: Additional types may be added in the future.
type
:- Session type
See also:
session-type
GetSessionClass ()
GetSessionClass (out 's' type)
Returns the display type of the provided session. The following classes may be returned:
"user" - A normal user session, the default
"greeter" - Display Manager pseudo session
"lock-screen" - Screensaver based session
"background" - A long running background process that requires its own session
Note: Additional classes may be added in the future.
Since 1.1.2
type
:- Session class
See also:
session-class
GetSessionState ()
GetSessionState (out 's' type)
Returns the current state of the session. The following states may be returned:
"online" - Session is logged in but not active
"active" - Session is logged in and active
"closing" - Session is in the process of shutting down
Note: Additional classes may be added in the future.
Since 1.1.2
type
:- Session state
See also:
session-state
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
GetXDGRuntimeDir ()
GetXDGRuntimeDir (out 's' xdg_runtime_dir)
Returns the XDG_RUNTIME_DIR location of the session. The XDG_RUNTIME_DIR is the same for all sessions of the same user and will be automatically removed once the last session of the user is closed.
May fail with: CK_SESSION_ERROR_FAILED if it failed to create a runtime dir for the user (such as root).
Since 1.1.0
xdg_runtime_dir
:- XDG_RUNTIME_DIR
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
GetVTNr ()
GetVTNr (out 'u' VTNr)
Returns the value of the virtual terminal that the underlying session runs on. If the seat doesn't support VTs, then this will always return 0.
Since 1.1.2
VTNr
:- The virtual terminal the session runs on, if any, 0 otherwise
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
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
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
SetLockedHint ()
SetLockedHint (in 'b' locked_hint)
This is used by Desktop Environments to update the
LockedHint
property. Calling Lock()
or Unlock()
will also
update the LockedHint
value.
Use of this method is restricted to the user that owns the session.
locked_hint
:- boolean value to set the locked-hint to
TakeControl ()
TakeControl (in 'b' force)
Allows a single process per session to request ConsoleKit2
managed devices by calling TakeDevice
.
Use of this method is restricted to the user that owns the session or root. The force argument will be honored for root only.
May fail with: CK_SESSION_ERROR_FAILED, CK_SESSION_ERROR_INSUFFICIENT_PERMISSION, CK_SESSION_ERROR_GENERAL, CK_SESSION_ERROR_NOT_SUPPORTED
Since 1.1.1
force
:- If set to TRUE, an existing session controller is replaced.
ReleaseControl ()
ReleaseControl ()
The process that previously successfully called
TakeControl
may use this to reliqunish control. Any devices acquired with
TakeDevice
will be released. If the session controller closes the dbus-connection,
this will implicitly call ReleaseControl.
Use of this method is restricted to the process that
called TakeControl
.
Since 1.1.1
TakeDevice ()
TakeDevice (in 'u' major, in 'u' minor, out 'h' fd, out 'b' inactive)
ConsoleKit2 automatically mutes the file-descriptor if the session is inactive and resumes it once the session gets active again. This guarantees that a session can only access session-devices if the session is active. Note that this revoke/resume mechanism is asynchronous and may happen at any given time. This only works on devices that are attached to the seat of the given session. A process is not required to have direct access to the device-node. Also note that any device can only be requested once. As long as you don't release it, further calls will fail.
Use of this method is restricted to the session-controller,
see TakeControl
.
May fail with: CK_SESSION_ERROR_FAILED, CK_SESSION_ERROR_GENERAL, CK_SESSION_ERROR_NOT_SUPPORTED
Since 1.1.1
major
:- Major number of the character-device.
minor
:- Minor number of the character-device.
fd
:- Returns a file descriptor for the specified device.
inactive
:- boolean value if the deivce is currently inactive.
ReleaseDevice ()
ReleaseDevice (in 'u' major, in 'u' minor)
Release a previously acquired device.
Use of this method is restricted to the session-controller,
see TakeControl
.
Since 1.1.1
major
:- Major number of the character-device.
minor
:- Minor number of the character-device.
PauseDeviceComplete ()
PauseDeviceComplete (in 'u' major, in 'u' minor)
Allows the session controller to synchronously pause a
device in response to the
PauseDevice
signal. Forced signals are automatically completed by ConsoleKit2.
Use of this method is restricted to the session-controller,
see TakeControl
.
Since 1.1.1
major
:- Major number of the character-device.
minor
:- Minor number of the character-device.
Signal Details
The PauseDevice signal
PauseDevice ('u' major, 'u' minor, 's' type)
Emitted for any device requested with
TakeDevice
.
A device may remain paused for unknown reasons even though the Session
is active. A type of 'force' means the device got paused by ConsoleKit2
already and this is only a notification. A type of 'pause' means
ConsoleKit2 is requesting to pause the device and grants the session
controller a limited amount of time to pause it. The session controller
must respond to this via
PauseDeviceComplete
.
This synchronous pausing-mechanism is used for backwards-compatibility
to VTs and ConsoleKit2 is free to not make use of it. ConsoleKit2 may
also send a force PauseDevice if you don't respond in a timely manner
(or for any other reason). A type of 'gone' means the device was unplugged from
the system and you will no longer get any notifications about it.
Since 1.1.1
major
:- Major number of the character-device.
minor
:- Minor number of the character-device.
type
:- Will either be: force, pause, or gone
The ResumeDevice signal
ResumeDevice ('u' major, 'u' minor, 'h' fd)
Emitted for any device requested with
TakeDevice
.
Sent whenever a session is active and a device is resumed.
It carries the major/minor as arguments and provides a new open
file-descriptor. You should switch to the new descriptor and close
the old one. They are not guaranteed to have the same underlying
file descriptor.
Since 1.1.1
major
:- Major number of the character-device.
minor
:- Minor number of the character-device.
fd
:- Will either be: force, pause, or gone
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 "user" property
'user' read '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 "Seat" property
'Seat' read '(so)'
The seat the session is assigned to. It is comprised of the seat id and object path of the seat.
The "remote-host-name" property
'remote-host-name' read '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' read 's'
The display device (aka TTY) that the session is connected to.
The "x11-display" property
'x11-display' read 's'
Value of the X11 DISPLAY for this session if one is present.
The "x11-display-device" property
'x11-display-device' read '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' read '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' read '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.
A
- Activate
- Session, Activate ()
- ActivateSession
- Manager, ActivateSession ()
- Seat, ActivateSession ()
- ActivateSessionOnSeat
- Manager, ActivateSessionOnSeat ()
- active
- Session, The "active" property
- ActiveChanged
- Session, The ActiveChanged signal
- ActiveSessionChanged
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
- GetIdleHint
- Session, GetIdleHint ()
- GetIdleSinceHint
- Session, GetIdleSinceHint ()
- GetLoginSessionId
- Session, GetLoginSessionId ()
- GetName
- Seat, GetName ()
- GetRemoteHostName
- Session, GetRemoteHostName ()
- GetSeatId
- Session, GetSeatId ()
- GetSeats
- Manager, GetSeats ()
- GetSessionByPID
- Manager, GetSessionByPID ()
- GetSessionClass
- Session, GetSessionClass ()
- GetSessionForCookie
- Manager, GetSessionForCookie ()
- GetSessionForUnixProcess
- Manager, GetSessionForUnixProcess ()
- GetSessions
- Manager, GetSessions ()
- Seat, GetSessions ()
- GetSessionsForUnixUser
- Manager, GetSessionsForUnixUser ()
- GetSessionsForUser
- Manager, GetSessionsForUser ()
- GetSessionState
- Session, GetSessionState ()
- GetSessionType
- Session, GetSessionType ()
- GetSystemIdleHint
- Manager, GetSystemIdleHint ()
- GetSystemIdleSinceHint
- Manager, GetSystemIdleSinceHint ()
- GetUnixUser
- Session, GetUnixUser ()
- GetUser
- Session, GetUser ()
- GetVTNr
- Session, GetVTNr ()
- GetX11Display
- Session, GetX11Display ()
- GetX11DisplayDevice
- Session, GetX11DisplayDevice ()
- GetXDGRuntimeDir
- Session, GetXDGRuntimeDir ()
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
- LockedHint
- Session, The "LockedHint" property
- LockSession
- Manager, LockSession ()
N
- name
- Seat, The "name" property
O
- OpenSession
- Manager, OpenSession ()
- OpenSessionWithParameters
- Manager, OpenSessionWithParameters ()
P
- PauseDevice
- Session, The PauseDevice signal
- PauseDeviceComplete
- Session, PauseDeviceComplete ()
- PowerOff
- Manager, PowerOff ()
- PrepareForShutdown
- Manager, The PrepareForShutdown signal
- PrepareForSleep
- Manager, The PrepareForSleep signal
R
- Reboot
- Manager, Reboot ()
- ReleaseControl
- Session, ReleaseControl ()
- ReleaseDevice
- Session, ReleaseDevice ()
- remote-host-name
- Session, The "remote-host-name" property
- Restart
- Manager, Restart ()
- ResumeDevice
- Session, The ResumeDevice signal
S
- Seat
- Session, The "Seat" property
- SeatAdded
- Manager, The SeatAdded signal
- SeatRemoved
- Manager, The SeatRemoved signal
- session-class
- Session, The "session-class" property
- session-state
- Session, The "session-state" property
- session-type
- Session, The "session-type" property
- SessionAdded
- Seat, The SessionAdded signal
- SessionNew
- Manager, The SessionNew signal
- SessionRemoved
- Manager, The SessionRemoved signal
- Seat, The SessionRemoved signal
- SetIdleHint
- Session, SetIdleHint ()
- SetLockedHint
- Session, SetLockedHint ()
- Stop
- Manager, Stop ()
- Suspend
- Manager, Suspend ()
- SwitchTo
- Seat, SwitchTo ()
- SystemIdleHintChanged
- Manager, The SystemIdleHintChanged signal
T
- TakeControl
- Session, TakeControl ()
- TakeDevice
- Session, TakeDevice ()
U
- unix-user
- Session, The "unix-user" property
- Unlock
- Session, Unlock (), The Unlock signal
- UnlockSession
- Manager, UnlockSession ()
- user
- Session, The "user" property
V
- VTNr
- Session, The "VTNr" property
X
- x11-display
- Session, The "x11-display" property
- x11-display-device
- Session, The "x11-display-device" property