Skip to content

Feature request: add a read-only query for the active graphical session #18

Description

@Pyrobrick

Background

I have been experimenting with replacing the standard KDE Plasma 6.7 desktop environment on my Steam Deck with KDE Plasma Bigscreen 6.7, providing a more suitable ten-foot interface while the device is connected to the official Steam Deck Dock.

While doing this, I noticed that steamos-session-select makes it very easy to switch between Gamescope and the configured desktop session using a single command with a single argument.

On my system, Plasma Bigscreen is installed as a separate Wayland session:

plasma-bigscreen-wayland.desktop

A local /usr/local/bin/steamos-session-select override intercepts the plasma argument and selects this Bigscreen session, while passing all other arguments through to the packaged /usr/bin/steamos-session-select command.

The feature request itself concerns the behaviour of the packaged command, which I tested directly.

However, neither the packaged steamos-session-select command nor the newer steamosctl interface appears to provide an equally straightforward way to determine which graphical session is currently active.

I have a local workaround for my particular use case, but it relies on implementation details. I am therefore not assuming that this feature is necessarily useful to everyone. I would also be interested to know whether other users or downstream projects have a need for a stable, read-only session-status query.

Current behaviour

steamos-session-select currently supports switching between Gamescope and Plasma, as well as configuring persistent or oneshot session behaviour:

persistent
oneshot
gamescope
plasma

Running the packaged command without arguments only prints the usage information and exits with status 1:

$ /usr/bin/steamos-session-select
Usage: steamos-session-select <mode>

Modes:
  persistent
      Enable persistent session mode.
      The system will remember the last session you used and boot into it
      next time. If you last used Gamescope, it will boot into Gamescope.
      If you last used the desktop, it will boot into the desktop.

  oneshot
      Restore default oneshot behaviour.
      Every fresh boot will start in Gamescope first, regardless of the
      previously used session.

  gamescope
      Immediately switch to the Gamescope session.

  plasma
      Immediately switch to the desktop session.
      This is the same action triggered by Steam's "Switch to Desktop".

Example:
    steamos-session-select persistent

$ echo $?
1

This means that the command can change the selected session, but it cannot report which graphical session is currently running.

Existing alternatives checked

I also checked the newer steamosctl interface provided by:

steamos-manager 26.3.0-1

The installed client advertises the following relevant commands:

switch-to-desktop-mode
switch-to-game-mode
switch-to-login-mode
set-default-desktop-session
get-default-desktop-session
set-default-login-mode
get-default-login-mode
get-valid-desktop-sessions

These commands appear to cover:

  • switching between Game Mode and Desktop Mode;
  • selecting the default login mode;
  • selecting the default desktop session;
  • reporting configured defaults;
  • listing available desktop sessions.

However, I could not find an advertised command that reports which graphical session is currently active on the local graphical seat.

The following commands concern configuration or session availability rather than runtime session state:

get-default-desktop-session
get-default-login-mode
get-valid-desktop-sessions

For example, the configured default desktop session may be Plasma Bigscreen while Gamescope is currently active, or vice versa.

On my current installation, the advertised session-management queries also fail because the corresponding SessionManagement1 D-Bus interface is unavailable:

$ steamosctl get-default-desktop-session
Error: org.freedesktop.DBus.Error.UnknownInterface: Unknown interface 'com.steampowered.SteamOSManager1.SessionManagement1'

This may be a separate packaging, daemon, or version-alignment issue. Regardless, I could not find a client command intended to report the currently active graphical session.

Current workarounds

Users currently have to rely on implementation details such as:

systemctl --user is-active gamescope-session.target

process matching:

pgrep -f '^gamescope([[:space:]]|$)'

or manually inspecting login sessions:

loginctl list-sessions
loginctl show-session <session>

These approaches are not entirely reliable or portable:

  • the command may be executed through SSH, where $XDG_SESSION_ID refers to the SSH session rather than the graphical session;
  • multiple loginctl sessions may belong to the same user;
  • more than one graphical session may still exist;
  • stale Plasma, Bigscreen, or Gamescope processes may remain after switching;
  • process names may differ between implementations;
  • systemd unit names are implementation details and may change;
  • correctly detecting the active session requires identifying the graphical session attached to the local seat, rather than merely finding a matching process.

Proposed functionality

Would there be broader interest in adding a stable, non-mutating session-status query?

For example:

$ steamos-session-select status
gamescope

and possibly also:

$ steamosctl get-active-session
plasma-bigscreen-wayland.desktop

Possible output values could include:

gamescope
plasma.desktop
plasma-bigscreen-wayland.desktop
unknown

Suggested behaviour

The command should:

  • report gamescope when the active graphical seat is running the Gamescope session;
  • report the active desktop-session identifier when Desktop Mode is active;
  • distinguish the active session from the configured default session;
  • inspect the graphical session attached to the local seat rather than the caller's SSH or terminal session;
  • print unknown and return a non-zero exit status when the active session cannot be determined;
  • avoid switching, terminating, restarting, or reconfiguring any session;
  • provide stable, machine-readable output suitable for shell scripts.

For example:

$ steamosctl get-active-session
gamescope

$ echo $?
0

Or, when the session cannot be determined:

$ steamosctl get-active-session
unknown

$ echo $?
1

Command placement

This may not necessarily need to be a choice between steamos-session-select and steamosctl.

A status subcommand in steamos-session-select would provide a convenient counterpart to its existing session-switching commands and could be useful to existing scripts and SteamOS-derived distributions:

steamos-session-select status

At the same time, exposing the same information through steamosctl would provide a more general and potentially preferable long-term interface:

steamosctl get-active-session

Both commands could expose the same underlying session-state detection rather than implementing separate behaviour.

Optionally, invoking steamos-session-select without arguments could perform the query. However, an explicit status subcommand may be preferable for compatibility with older SteamOS-derived implementations where invoking steamos-session-select without arguments selected Gamescope.

I am posting this here because the packaged steamos-session-select implementation is maintained in this repository. If the steamosctl portion belongs in a different upstream issue tracker, please let me know where it would be most appropriate to raise it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions