extract IdleInhibitService singleton from IdleInhibitorModule
This commit is contained in:
parent
de35cf016c
commit
07dfbb1337
3 changed files with 39 additions and 27 deletions
31
shell/services/IdleInhibitService.qml
Normal file
31
shell/services/IdleInhibitService.qml
Normal 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() : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue