Skip to content

isSessionLocked ​

isSessionLocked returns whether the current user session is locked.

SignatureisSessionLocked(): boolean
tyrus
import { isSessionLocked } from "tyrus:os";

const locked: boolean = isSessionLocked();
print(locked);

Best effort, Linux-only for now

Queries systemd-logind's per-session LockedHint property via loginctl, the session-level lock flag tracked by every desktop that registers a session with logind (GNOME, KDE, and most others on Linux). Returns false on any other platform, or when the session state cannot be reached.

See isScreenLocked for the related, but distinct, screensaver state.