Add Night Light bar indicator

This commit is contained in:
David Heinemeier Hansson
2026-05-20 15:31:28 +02:00
parent 296ee20e98
commit 9e48d9658b
5 changed files with 164 additions and 3 deletions
@@ -0,0 +1,64 @@
import QtQuick
import Quickshell.Io
import qs.Ui
BarIndicator {
id: root
property bool nightlight: false
active: nightlight
activeText: "󰔎"
inactiveText: "󰔎"
activeTooltipText: "Night Light on"
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() {
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
refreshTimer.restart()
}
Component.onCompleted: refresh()
Connections {
target: root.bar
ignoreUnknownSignals: true
function onIndicatorsRefreshRequested() { 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()
}
Timer {
interval: 5000
running: true
repeat: true
onTriggered: root.refresh()
}
onPressed: function() { root.toggle() }
}
+1 -1
View File
@@ -133,7 +133,7 @@ Item {
left: [{ id: "omarchy" }, { id: "workspaces" }],
center: [
{ id: "calendar", format: "dddd HH:mm", formatAlt: "dd MMMM 'W'ww yyyy", verticalFormat: "HH\n\u2014\nmm" },
{ id: "weather" }, { id: "indicators", items: [ "dnd", "stayAwake", "screenrecording", "dictation" ] }, { id: "update" }
{ id: "weather" }, { id: "indicators", items: [ "dnd", "nightlight", "stayAwake", "screenrecording", "dictation" ] }, { id: "update" }
],
right: [
{ id: "tray" }, { id: "bluetoothPanel" }, { id: "networkPanel" },