Files
arthur-os/shell/plugins/bar/widgets/idleInhibitor.qml
T

63 lines
1.2 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Io
import qs.Ui
BarIndicator {
id: root
moduleName: "idleInhibitor"
function refresh() {
if (!statusProc.running) statusProc.running = true
}
function toggle() {
if (root.bar) root.bar.run("omarchy-toggle-idle")
refreshTimer.restart()
}
Component.onCompleted: refresh()
Connections {
target: root.bar
ignoreUnknownSignals: true
function onIndicatorsRefreshRequested() { root.refresh() }
}
Process {
id: statusProc
command: ["bash", "-lc", "omarchy-shell idle status 2>/dev/null"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
var raw = String(text || "").trim()
try {
var parsed = JSON.parse(raw)
root.active = parsed && parsed.enabled === false
} catch (e) {
root.active = false
}
}
}
}
Timer {
id: refreshTimer
interval: 1500
onTriggered: root.refresh()
}
Timer {
interval: 5000
running: true
repeat: true
onTriggered: root.refresh()
}
activeText: "󰅶"
inactiveText: "󰅶"
activeTooltipText: "No lock or screensaver"
inactiveTooltipText: "Idle enabled"
onPressed: function() { root.toggle() }
}