nova-shell/shell/services/IdleInhibitService.qml

31 lines
801 B
QML

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() : ""
}
}
}