extract IdleInhibitService singleton from IdleInhibitorModule

This commit is contained in:
Damocles 2026-04-18 10:39:37 +02:00
parent de35cf016c
commit 07dfbb1337
3 changed files with 39 additions and 27 deletions

View file

@ -0,0 +1,31 @@
pragma Singleton
import QtQuick
import Quickshell.Io
QtObject {
id: root
property bool active: false
property string inhibitors: ""
function toggle() {
active = !active;
}
function refreshInhibitors() {
_listProc.running = true;
}
property Process _inhibitor: Process {
command: ["systemd-inhibit", "--what=idle", "--who=nova-shell", "--why=user", "sleep", "infinity"]
running: root.active
}
property Process _listProc: Process {
command: ["sh", "-c", "systemd-inhibit --list 2>/dev/null | grep -i idle | awk '{print $NF}' | sort -u | tr '\\n' ', ' | sed 's/, $//'"]
stdout: StdioCollector {
onStreamFinished: root.inhibitors = text.trim() ? "Blocked by: " + text.trim() : ""
}
}
}