Skip to content

Commit d2e1587

Browse files
dhhclaude
andcommitted
Refresh bar widgets on every monitor, not just one
A bar surface is built per monitor, so a widget in the layout is live once per screen — but an IPC target only ever routes to the handler that registered first. `omarchy.indicators refresh` therefore reached a single bar, and since indicators only re-read their state on that signal, the other screens kept showing a stale reminder count, tmux alert, or DND state until the next reload. Clock and system-update refreshes had the same reach. Let the bar resolve every live instance of a widget id and relay the call to all of them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 49efe2d commit d2e1587

6 files changed

Lines changed: 36 additions & 9 deletions

File tree

‎shell/Ui/BarWidget.qml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ Item {
2222
readonly property bool vertical: bar ? bar.vertical : false
2323
readonly property int barSize: bar ? bar.barSize : Style.bar.sizeHorizontal
2424

25+
// Run `method` on every live instance of this widget. An IPC target only
26+
// ever routes to one handler, but a bar surface exists per monitor, so the
27+
// instance that owns the target relays the call to its peers — otherwise a
28+
// refresh would land on a single screen and leave the others stale.
29+
function broadcast(method) {
30+
var items = bar && typeof bar.moduleWidgets === "function"
31+
? bar.moduleWidgets(moduleName) : [root]
32+
for (var i = 0; i < items.length; i++) {
33+
if (items[i] && typeof items[i][method] === "function") items[i][method]()
34+
}
35+
}
36+
2537
// Read a single value from this widget's inline shell.json entry, with a
2638
// fallback for missing/null values. Every widget that takes user-tunable
2739
// settings needs this; defining it once on the base keeps the wiring

‎shell/plugins/bar/Bar.qml‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,25 @@ Item {
384384
return true
385385
}
386386

387+
// Every live instance of a widget id. A bar surface is built per monitor, so
388+
// a widget that appears once in the layout is still live once per screen.
389+
function moduleWidgets(pluginId) {
390+
var id = String(pluginId || "")
391+
var items = []
392+
if (!id) return items
393+
for (var i = 0; i < moduleSlots.length; i++) {
394+
var slot = moduleSlots[i]
395+
if (!slot || !slot.activeItem || slot.moduleName !== id) continue
396+
items.push(slot.activeItem)
397+
}
398+
return items
399+
}
400+
387401
// Resolve the live bar-widget instance for a plugin id (e.g. "omarchy.bluetooth").
388402
// Only widgets that expose popup open/close methods count; plain indicators
389403
// (clock, workspaces, tray) return null. Used by shell.summon/toggle so
390-
// panel hotkeys route through the bar instead of a per-target IpcHandler
391-
// that goes stale when the bar reloads its widget instances.
404+
// panel hotkeys route through the bar instead of a per-target IPC handler
405+
// that only reaches whichever per-monitor instance claimed the target.
392406
function findPanelWidget(pluginId) {
393407
var id = String(pluginId || "")
394408
if (!id) return null

‎shell/plugins/bar/widgets/Clock.qml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ BarWidget {
4949

5050
IpcHandler {
5151
target: "omarchy.clock"
52-
function refresh(): void { root.refresh() }
52+
function refresh(): void { root.broadcast("refresh") }
5353
}
5454

5555
WidgetButton {

‎shell/plugins/bar/widgets/Indicators.qml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ BarWidget {
152152
syncActiveIndicatorModel()
153153
}
154154

155+
function refresh() { root.refreshRequested() }
156+
155157
onIndicatorEntriesChanged: syncActiveIndicatorOrder()
156158

157159
implicitWidth: root.vertical
@@ -165,7 +167,7 @@ BarWidget {
165167
target: "omarchy.indicators"
166168

167169
function refresh(): void {
168-
root.refreshRequested()
170+
root.broadcast("refresh")
169171
}
170172
}
171173

‎shell/plugins/bar/widgets/SystemUpdate.qml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ BarWidget {
2828
target: "omarchy.system-update"
2929

3030
function refresh(): void {
31-
root.refresh()
31+
root.broadcast("refresh")
3232
}
3333

3434
function clear(): void {
35-
root.clear()
35+
root.broadcast("clear")
3636
}
3737
}
3838

‎shell/shell.qml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,8 @@ ShellRoot {
423423
// Bar-widget panels (audio, bluetooth, network, power, monitor, etc.)
424424
// are mounted inside the bar, not via the panel loader below. Route
425425
// summon/hide/toggle to the live bar instance so panel hotkeys survive
426-
// plugin/bar reloads: the bar re-creates the widget, while a fixed
427-
// IpcHandler target would go stale ("first handler wins" leaves a
428-
// destroyed instance's handler active and the new one rejected).
426+
// plugin/bar reloads: the bar re-creates the widget, while a fixed IPC
427+
// target only ever routes to one of the per-monitor instances.
429428
function isBarWidgetPanelPlugin(pluginId) {
430429
var plugins = shell.pluginRegistry.installedPlugins
431430
var m = plugins[String(pluginId || "")]

0 commit comments

Comments
 (0)