Extract system update bar widget

This commit is contained in:
David Heinemeier Hansson
2026-05-20 18:28:13 +02:00
parent 4835119e48
commit 1e63e86133
7 changed files with 60 additions and 40 deletions
-35
View File
@@ -54,7 +54,6 @@ Item {
Behavior on foreground { ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
Behavior on background { ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
Behavior on urgent { ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
property bool updateAvailable: false
property bool clockAlt: false
property var tooltipTarget: null
property var pendingTooltipTarget: null
@@ -259,7 +258,6 @@ Item {
function builtinModuleComponent(name) {
switch (String(name)) {
case "clock": return clockModuleComponent
case "update": return updateModuleComponent
case "indicators": return indicatorsModuleComponent
case "tray": return trayModuleComponent
default: return null
@@ -366,10 +364,6 @@ Item {
clearTooltip()
}
function refreshUpdate() {
runProcess(updateProc)
}
function refreshIndicators() {
indicatorsRefreshRequested()
}
@@ -459,23 +453,6 @@ Item {
onFileChanged: barHiddenProbe.running = true
}
Process {
id: updateProc
command: ["bash", "-lc", "omarchy-update-available"]
stdout: StdioCollector { waitForEnd: true }
onExited: function(exitCode) {
root.updateAvailable = exitCode === 0
}
}
Timer {
interval: 21600000
running: true
repeat: true
triggeredOnStart: true
onTriggered: root.refreshUpdate()
}
Timer {
interval: 2000
running: true
@@ -487,10 +464,6 @@ Item {
IpcHandler {
target: "bar"
function refreshUpdate(): void {
root.refreshUpdate()
}
function refreshScreenRecording(): void {
root.refreshIndicators()
}
@@ -646,7 +619,6 @@ Item {
Component { id: emptyModuleComponent; Item { implicitWidth: 0; implicitHeight: 0; visible: false } }
Component { id: clockModuleComponent; ClockModule {} }
Component { id: updateModuleComponent; UpdateModule {} }
Component { id: indicatorsModuleComponent; IndicatorsModule {} }
Component { id: trayModuleComponent; TrayModule {} }
@@ -1385,13 +1357,6 @@ Item {
}
}
component UpdateModule: ModuleButton {
text: root.updateAvailable ? "" : ""
fontSize: Style.font.caption
tooltipText: root.updateAvailable ? "Omarchy update available" : ""
onPressed: function() { root.run("omarchy-launch-floating-terminal-with-presentation omarchy-update") }
}
component TrayModule: Item {
id: trayRoot
+1
View File
@@ -16,6 +16,7 @@ QtObject {
"bluetoothPanel": { displayName: "Bluetooth", description: "Bluetooth device list with connect/disconnect", category: "Network", allowMultiple: false, sourceDir: "../panels", sourceName: "Bluetooth" },
"daytime": { displayName: "Daytime", description: "Day/time label with date tooltip", category: "Time", allowMultiple: false, settingsForm: "daytimeSettings" },
"notificationCenter": { displayName: "Notification center", description: "Recent notifications + DND", category: "Status", allowMultiple: false },
"systemUpdate": { displayName: "System update", description: "Indicates available system updates", category: "System", allowMultiple: false },
"systemStats": { displayName: "System stats", description: "CPU icon — hover for graphs, click to open btop", category: "System", allowMultiple: false },
"weather": { displayName: "Weather", description: "Weather pill with detail popup", category: "Info", allowMultiple: false, settingsForm: "weatherSettings" },
"microphone": { displayName: "Microphone", description: "Mic input state and mute toggle", category: "Audio", allowMultiple: false },
+2 -1
View File
@@ -59,6 +59,7 @@ Example `shell.json` (bar subtree only shown):
| `media` | MPRIS now-playing — scrolling track + artist, cover-art popup | left = play/pause · middle = next · scroll = prev/next · right = popup |
| `daytime` | Day/time label with date tooltip | hover = date |
| `notificationCenter` | Bell with badge + popup with recent notifications, DND toggle | left = popup · right = toggle DND |
| `systemUpdate` | Available update indicator | left = update |
| `systemStats` | Inline CPU + memory sparklines, popup with detail | left = popup · right = terminal |
| `weather` | Weather icon + popup with forecast | left = popup · right = full notification |
| `microphone` | Mic icon + scroll volume | left = mute toggle · middle = audio panel · scroll = source volume |
@@ -75,7 +76,7 @@ Example `shell.json` (bar subtree only shown):
### Built-in base modules (in `Bar.qml`)
`clock`, `update`, `indicators`, `tray`.
`clock`, `indicators`, `tray`.
The `indicators` module loads individual bar indicators from `indicators/`, ordered by its `items` array in `shell.json`. Rich panels such as `powerPanel`, `networkPanel`, and `audioPanel` live in `../panels/` above.
@@ -0,0 +1,54 @@
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
BarWidget {
id: root
moduleName: "systemUpdate"
property bool updateAvailable: false
function refresh() {
if (!updateProc.running) updateProc.running = true
}
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
IpcHandler {
target: "systemUpdate"
function refresh(): void {
root.refresh()
}
}
Process {
id: updateProc
command: ["bash", "-lc", "omarchy-update-available"]
stdout: StdioCollector { waitForEnd: true }
onExited: function(exitCode) {
root.updateAvailable = exitCode === 0
}
}
Timer {
interval: 21600000
running: true
repeat: true
triggeredOnStart: true
onTriggered: root.refresh()
}
WidgetButton {
id: button
anchors.fill: parent
bar: root.bar
text: root.updateAvailable ? "\uf021" : ""
fontSize: Style.font.caption
tooltipText: root.updateAvailable ? "Omarchy update available" : ""
onPressed: function() { root.bar.run("omarchy-launch-floating-terminal-with-presentation omarchy-update") }
}
}
+1 -2
View File
@@ -133,7 +133,7 @@ Item {
left: [{ id: "omarchy" }, { id: "workspaces" }],
center: [
{ id: "daytime", format: "dddd HH:mm", formatAlt: "dd MMMM yyyy", verticalFormat: "HH\n\u2014\nmm" },
{ id: "weather" }, { id: "indicators", items: [ "dnd", "nightlight", "stayAwake", "screenrecording", "dictation" ] }, { id: "update" }
{ id: "weather" }, { id: "indicators", items: [ "dnd", "nightlight", "stayAwake", "screenrecording", "dictation" ] }, { id: "systemUpdate" }
],
right: [
{ id: "tray" }, { id: "bluetoothPanel" }, { id: "networkPanel" },
@@ -292,7 +292,6 @@ Item {
// ---------------- widget catalog -----------------------------------------
readonly property var builtinWidgetMeta: ({
"clock": { name: "Clock", description: "Date / time text", category: "Time" },
"update": { name: "Updates", description: "Indicates available system updates", category: "System" },
"indicators": { name: "Indicators", description: "Manual state indicators", category: "Status" },
"tray": { name: "System tray", description: "Status notifier items", category: "Status" }
})