org.freedesktop.ConsoleKit.Session

# 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

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

`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

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

### 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 "unix-user" property

    'unix-user'  read      'u'

The user assigned to the session.

### The "user" property

    'user'  read      'u'

The user assigned to the session.

`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 "session-type" property

    'session-type'  read      's'

The type of the session.

### The "session-class" property

    'session-class'  read      's'

The class of the session.

### The "session-state" property

    'session-state'  read      's'

The state of the session.

### 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 "VTNr" property

    'VTNr'  read      'u'

The virtual terminal the session runs on, if any, 0 otherwise.

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

### The "LockedHint" property

    'LockedHint'  read      'b'

This is a hint used by Desktop Environments to indicate that the session may be locked.