repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nuguland: make bar/osd/toasts per-output on multi-monitor

e752ddef4fa27ff72e196079eab4da43af0d4e99

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Every surface already spawns per screen (Variants over Quickshell.screens),
but content was global: each bar's workspace strip showed the union of all
outputs' workspaces, and the OSD/toasts rendered on every monitor at once.

- Niri.workspacesForOutput(name): a bar's own monitor's visible workspaces,
  sorted by niri's per-output idx so each bar reads 1..N left-to-right
  (also fixes the scrambled order seen under single-output fallback). Empty
  name falls back to all.
- Niri.focusedOutput: the output name of the globally-focused workspace.
- OSD + toast surfaces gate visibility on modelData.name === focusedOutput
  (fall back to all screens if niri hasn't reported a focused output yet), so
  each shows once on the active monitor instead of duplicating per screen.

Matching is fully dynamic via screen.name vs workspace.output — no hardcoded
connector names. Verified on the live single-output session: pills render
idx-sorted, OSD shows once, clean journal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (3)

+31 / −3 text lines

Diff layout

quickshell/nuguland/Bar.qml

Modified

+3 / −1 text lines

200200 clip: true
202202 Repeater {
203 model: root.niriService ? root.niriService.visibleWorkspaces : []
203 // only this monitor's workspaces, idx-sorted, so each bar
204 // reads its own 1..N instead of every output's union.
205 model: root.niriService ? root.niriService.workspacesForOutput(root.screen ? root.screen.name : "") : []
205207 delegate: Rectangle {
206208 id: workspaceChip

quickshell/nuguland/Niri.qml

Modified

+22 / −0 text lines

1010 property string lastError: ""
1111 property var workspaces: []
1212 readonly property var visibleWorkspaces: displayWorkspaces(workspaces)
13 // niri output name (e.g. "DP-1") that currently holds focus, derived from
14 // the single globally-focused workspace; "" if none. Used to target the
15 // OSD/toast surfaces at the active monitor instead of every screen.
16 readonly property string focusedOutput: {
17 const list = workspaces || [];
18 for (let i = 0; i < list.length; i++)
19 if (list[i].is_focused)
20 return String(list[i].output || "");
21 return "";
22 }
1323 property var windows: []
1424 property var outputs: []
1525 property var focusedWindow: null
8393 });
8494 }
96 // visible workspaces belonging to one output (a bar's own monitor), sorted
97 // by niri's per-output idx so each bar reads 1..N left-to-right. When the
98 // output name is unknown/empty, fall back to all (single-monitor / no match).
99 function workspacesForOutput(outputName) {
100 const all = visibleWorkspaces;
101 const name = String(outputName || "");
102 if (name.length === 0)
103 return all;
104 const mine = all.filter((workspace) => String(workspace.output || "") === name);
105 return mine.sort((a, b) => Number(a.idx || 0) - Number(b.idx || 0));
106 }
86108 function parsePickedColor(text) {
87109 const value = String(text || "");
88110 const match = value.match(/#[0-9a-fA-F]{6}/);

quickshell/nuguland/shell.qml

Modified

+6 / −2 text lines

125125 objectName: "osdOverlaySurface"
126126 screen: modelData
127 visible: osd.visibleState
127 // only on the focused monitor (fall back to all if niri hasn't
128 // reported a focused output yet) instead of duplicating on each.
129 visible: osd.visibleState && (niri.focusedOutput.length === 0 || modelData.name === niri.focusedOutput)
128130 implicitWidth: 300
129131 implicitHeight: osdCard.implicitHeight + 16
130132 color: "transparent"
299301 objectName: "notificationToastSurface"
300302 screen: modelData
301 visible: toasts.length > 0
303 // focused monitor only (fall back to all if no focused output),
304 // so a toast shows once, not once per screen.
305 visible: toasts.length > 0 && (niri.focusedOutput.length === 0 || modelData.name === niri.focusedOutput)
302306 implicitWidth: 380
303307 implicitHeight: Math.max(1, toastColumn.implicitHeight + 16)
304308 color: "transparent"