isScreenLocked
isScreenLocked returns whether the screensaver/lock screen is currently active.
Signature
isScreenLocked(): booleantyrus
import { isScreenLocked } from "tyrus:os";
const locked: boolean = isScreenLocked();
print(locked);Best effort, Linux-only for now
Queries the freedesktop screensaver D-Bus interface (org.freedesktop.ScreenSaver.GetActive, implemented by GNOME, KDE, and most other Linux screensavers/lockers). Returns false on any other platform, or when the D-Bus screensaver service cannot be reached, a headless machine, no session bus.
See isSessionLocked for the related, but distinct, session-level lock state.
