mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-04 12:47:51 +02:00
60 lines
1.1 KiB
QML
60 lines
1.1 KiB
QML
import QtQuick
|
|
import Quickshell.Io
|
|
import qs.Ui
|
|
|
|
BarIndicator {
|
|
id: root
|
|
|
|
activeText: ""
|
|
inactiveText: ""
|
|
activeTooltipText: "Allow Idle Lock & Screensaver"
|
|
inactiveTooltipText: "Stay Awake"
|
|
|
|
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.indicatorHost
|
|
ignoreUnknownSignals: true
|
|
function onRefreshRequested() { root.refresh() }
|
|
}
|
|
|
|
Process {
|
|
id: statusProc
|
|
command: ["omarchy-toggle-idle", "--status"]
|
|
stdout: StdioCollector {
|
|
waitForEnd: true
|
|
onStreamFinished: {
|
|
var data = root.extractData(text)
|
|
root.active = data && data.enabled === true
|
|
}
|
|
}
|
|
onExited: function(exitCode) {
|
|
if (exitCode !== 0) root.active = false
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: refreshTimer
|
|
interval: 1500
|
|
onTriggered: root.refresh()
|
|
}
|
|
|
|
Timer {
|
|
interval: 5000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: root.refresh()
|
|
}
|
|
|
|
onPressed: function() { root.toggle() }
|
|
}
|