pragma Singleton import Quickshell import QtQuick // Which window manager is driving this session? Detected once, from the // environment only. // // This deliberately does no IPC of its own. Widgets branch on these flags to // pick a backend, and reading a flag must never be able to instantiate the // service singleton for a window manager that isn't running -- an idle backend // would sit there retrying a socket that will never answer. Anything that // wants a backend gates on the matching flag first (`Compositor.isAttwm && // Attwm.x`), relying on `&&` / `?:` to leave the other branch untouched. Singleton { // Hyprland always exports this signature. readonly property bool _hyprSig: !!Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") // Sway and i3 both point clients at their IPC socket. readonly property bool _i3Sock: !!Quickshell.env("SWAYSOCK") || !!Quickshell.env("I3SOCK") // attwm exports no signature of its own: it is a window management client // of river rather than a compositor, so there is nothing session-wide to // look for. Treat it as the fallback -- an explicit socket override wins // outright, otherwise assume attwm once the two that do announce // themselves are ruled out. Guessing wrong is cheap: everything attwm // renders also gates on `Attwm.connected`, so a session with no window // manager we recognise shows nothing rather than a row of dead tags. readonly property bool isAttwm: !!Quickshell.env("ATTWM_SOCKET") || (!_hyprSig && !_i3Sock) readonly property bool isHyprland: !isAttwm && _hyprSig readonly property bool isI3: !isAttwm && !isHyprland && _i3Sock }