The indicators widget broadcast a refresh every 2s, fanning out to four status subprocesses (nightlight, idle, reminder, screen-recording), and NightLight/StayAwake each ran an additional 5s poll. On an idle desktop this was the dominant source of process churn (~33 of ~53 forks/sec in a VM). The state-changing commands already push `omarchy.indicators refresh` over IPC, so the polling was redundant. Drop the 2s broadcast and the two 5s timers; indicators now refresh at startup and on the IPC push. Also fix three callers that pushed to the wrong target `Indicators` instead of `omarchy.indicators` (screen recording, notification silencing, and the omarchy-shell help example) — those pushes silently failed and only appeared to work because the poll masked them. Idle fork rate drops ~53/s to ~20/s. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
59 lines
1.1 KiB
QML
59 lines
1.1 KiB
QML
import QtQuick
|
|
import Quickshell.Io
|
|
import qs.Ui
|
|
|
|
BarIndicator {
|
|
id: root
|
|
|
|
property bool nightlight: false
|
|
|
|
active: nightlight
|
|
activeText: ""
|
|
inactiveText: ""
|
|
activeTooltipText: "Day Light"
|
|
inactiveTooltipText: "Night Light"
|
|
|
|
function refresh() {
|
|
if (!statusProc.running) statusProc.running = true
|
|
}
|
|
|
|
function update(raw) {
|
|
var data = extractData(raw)
|
|
nightlight = data && data.enabled === true
|
|
}
|
|
|
|
function toggle() {
|
|
nightlight = !nightlight
|
|
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
|
|
refreshTimer.restart()
|
|
}
|
|
|
|
Component.onCompleted: refresh()
|
|
|
|
Connections {
|
|
target: root.indicatorHost
|
|
ignoreUnknownSignals: true
|
|
function onRefreshRequested() { root.refresh() }
|
|
}
|
|
|
|
Process {
|
|
id: statusProc
|
|
command: ["omarchy-toggle-nightlight", "--status"]
|
|
stdout: StdioCollector {
|
|
waitForEnd: true
|
|
onStreamFinished: root.update(text)
|
|
}
|
|
onExited: function(exitCode) {
|
|
if (exitCode !== 0) root.nightlight = false
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: refreshTimer
|
|
interval: 1500
|
|
onTriggered: root.refresh()
|
|
}
|
|
|
|
onPressed: function() { root.toggle() }
|
|
}
|