Products › lamco-dsi-tools › Interfaces › systemd-logind

systemd-logind sessions: Locked, idle or active, and how to watch

systemd-logind (org.freedesktop.login1) tracks each login session's state: Active, idle, locked. How it works, why long runs get locked, and how to watch it.

D-Bus (system bus) org.freedesktop.login1

systemd-logind is the systemd service that tracks login sessions, and org.freedesktop.login1 is its D-Bus interface on the system bus: Which sessions there are, which is in the foreground, and whether each is idle or locked. Compositors, screen lockers, session managers and remote desktop servers all read it, and so does anything that has to know why a long run stopped seeing the screen. lamco-dsi-tools (DSI: Desktop session interfaces) records every session's state, follows the display session through every run that records for a window, and takes logind's idle inhibitor when asked to.

What it is

logind's manager object, /org/freedesktop/login1, lists sessions, users and seats, and maps a process to its session with GetSessionByPID. Each session is an object of its own with the interface org.freedesktop.login1.Session. The properties that matter here are Type (wayland, x11, tty and others), Class (user, greeter and others), Active, State, IdleHint with IdleSinceHint, and LockedHint. A desktop sets the idle and locked hints itself with SetIdleHint and SetLockedHint. The session object sends Lock and Unlock signals when the session is asked to lock or unlock, and PropertiesChanged when a hint changes.

The manager's Inhibit method takes four strings, what, who, why and mode, and returns a file descriptor. The lock holds until that descriptor and every copy of it is closed. With what set to idle it inhibits what systemd's manual calls "the automatic idle logic", logind's own IdleAction. The manual says nothing of a desktop's own lock or blanking timer, which is why a long screen capture can still be locked by the idle timer while a logind inhibitor is held. The session's org.freedesktop.ScreenSaver service is the other interface a program asks.

A command started from an SSH login is in a different session from the display's. Asking logind about "my session" from there gets the SSH session, whose hints don't show the display's lock.

Which desktops offered it

The desktop matrix has no row for logind alone. Its session function rests on logind's records:

DesktopState
GNOME Shell 48.7 (Debian 13)working
GNOME Shell 51.0 (Fedora 45)working
KDE Plasma, KWin 6.5.6 (NixOS)working
KDE Plasma, KWin 6.8.2 (KDE neon)working
Sway 1.9working
Hyprland 0.56.2working
COSMIC, cosmic-comp 1.0.0present
labwc 0.20.3 (Budgie session, CachyOS)working
Cinnamon Wayland session (Linux Mint)working

Each cell is one version of that desktop on one virtual machine, captured on 2026-11-27 or 2026-11-28 with dsisee observe and no permission dialog answered. The COSMIC capture raised SES-003, since logind listed no graphical session in the foreground there. The README's run record adds that the session watch, started from an SSH login, followed the display session on Sway 1.9 and on KWin 6.8.2, and on KWin recorded the idle lock. It also records a ten-minute screen cast on KWin 6.8.2 that KDE's idle timer locked partway through, with the display switched off, which is why the watch was built.

The project's record of runs, reconciled on 2026-12-04, adds:

  • The idle inhibitor, on GNOME Shell 48.7 on 2026-11-29: It took both locks it asked for, logind's and the screen saver interface's with a cookie, and gave them back. The idle delay of that machine was zero, so there was no lock to hold off.
  • The idle inhibitor and the session watch against a real lock, on GNOME Shell 48.7 on 2026-11-29, with the session set for the run to go idle after 60 seconds and to lock, and put back afterwards: Without the inhibitor the session was locked and idle at 1 minute 55 seconds, the capture beside it stopped delivering, and the stalls were attributed to the locked span. With it the session never locked or went idle, and there were no stalls.

How to check it with lamco-dsi-tools

dsisee session logind --out sessions.json          # every login session's state, as a snapshot
dsitell health sessions.json                       # the session function, SES-002 and SES-003
dsitell timing cast.jsonl --series portal_screencast.buffer_interval --exclude-locked   # a long run without its locked spans

dsisee session logind records each session's id, user, seat, Active, State, IdleHint, LockedHint, Type and Class, each as read or not read with the reason. Every command that records for a window, makes a long run or drives the machine also follows the display session: It finds the session the compositor runs in (by the process on the other end of the Wayland socket, then three fallbacks), says which way found it, and records its hints at the start and the end, each PropertiesChanged and each Lock and Unlock between. dsitell health states each span in which the session was locked, idle, not active, or had an output switched off (SOAK-005), and dsitell timing --series can leave those spans out. The watch calls nothing that changes a session.

Driving it with dsido

dsido session inhibit --duration 12m --out inhibit.json &    # logind's idle inhibitor, and the session's
dsisee capture observe --route portal --soak 10m --out cast.jsonl   # a long screen cast beside it
dsitell health cast.jsonl inhibit.json                        # SOAK-005, SOAK-006

dsido session inhibit calls logind's Inhibit with idle in block mode, and records logind's IdleAction and BlockInhibited after the call. It also asks the session's ScreenSaver service, where one is there. It gives both back when it ends, on a signal as well. Whether a desktop honors either is read from what the session then did, never assumed: The README's run record has the inhibitor holding off the lock on KWin 6.8.2 for a run of 6.5 minutes, and the project's record of runs, reconciled on 2026-12-04, has it on GNOME Shell 48.7 taking both locks and, against a real lock, keeping the session from locking. The record, through 2026-11-29, has no run of it on any other desktop. dsido screen animate --inhibit-idle holds the same locks around an animation.

Findings

  • SES-002: A graphical login session is locked.
  • SES-003: No graphical login session is active.
  • SES-004: A property of a login session could not be read.
  • SOAK-005: The session was locked or idle during the run.
  • SOAK-006: The session was locked or idle although an idle inhibitor was held.

Related