pragma Singleton import QtQuick import Quickshell import Quickshell.Io // Keeps the session awake while on: holds a systemd idle and sleep inhibitor, // which hypridle and logind both honour. Off again after a shell restart. Singleton { id: root property bool active: false property var command: ["systemd-inhibit", "--what=idle:sleep", "--who=glassMxrph", "--why=Caffeine", "--mode=block", "sleep", "infinity"] readonly property bool running: inhibitor.running function toggle() { active = !active; return true; } Process { id: inhibitor command: root.command running: root.active // The inhibitor exiting on its own (logind refused it) turns the tile off. onRunningChanged: if (!running && root.active) root.active = false } IpcHandler { target: "caffeine" function toggle(): bool { return root.toggle(); } function status(): string { return JSON.stringify({ active: root.active, running: inhibitor.running }); } } }