repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

osd: redesign in the notification-card visual language

e3aa110c5d337200319f62f9299a94a2e88f10ef

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Apply what the notification work established. Was: a 2-letter text slice of
an abstract role string ('au', 'br') in a heavy bordered pill, lowercase raw
event name as title, and a microphone path that never matched (checked
'active' while Audio sends 'unmuted', and numeric mic levels drew no bar).

Now:
- real IconImage glyphs via freedesktop names resolved through
  Quickshell.iconPath() (audio-volume-{muted,low,medium,high},
  microphone-sensitivity-{muted,high}, display-brightness, media-playback-*,
  applets-screenshooter, color-picker, dialog-error) — all verified present
  in the Adwaita theme.
- card idiom shared with notifications: backdrop alpha 0.92, radius 14, left
  accent strip, IBM Plex, accent-coloured hero meter that animates.
- clean capitalised label + glance value ('72%' / 'muted' / 'on' / hex);
  errors render their message in the body line.
- microphone joins volume/brightness as a metered event; mute toggles and
  non-numeric events correctly hide the bar instead of drawing it empty.
- window height now derives from content instead of a fixed 88px.

Model changes are additive — iconName/displayLabel/displayValue added to the
OSD state JSON, existing keys untouched (IPC contract preserved). The empty
mask is kept deliberately: the OSD is non-interactive and must pass clicks
through — the inverse of the toast mask, which needed an item.

Verified: every event type driven through osdTrigger resolves the right
icon/label/value/bar with a clean journal; notifications selftest green.

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

Changed files (2)

quickshell/nuguland/Osd.qml

Modified
27 27 return "info";
30 + function isNumeric(value) {
31 + const text = String(value).replace("%", "").trim();
32 + return text.length > 0 && isFinite(Number(text));
33 + }
35 + // 0..1 for the meter-style events (volume/brightness/microphone) when the
36 + // value is a real number; -1 otherwise (mute toggles, media, color, error)
37 + // so the bar is hidden rather than drawn empty.
30 38 function normalizedValue(event, value) {
31 39 const name = String(event);
32 - if (name !== "volume" && name !== "brightness")
40 + if (name !== "volume" && name !== "brightness" && name !== "microphone")
33 41 return -1;
42 + if (!isNumeric(value))
43 + return -1;
44 + return Math.max(0, Math.min(1, Number(String(value).replace("%", "")) / 100));
45 + }
35 - const number = Number(String(value).replace("%", ""));
36 - if (!isFinite(number))
37 - return 0;
47 + // freedesktop icon name for the event; resolved to a path at render time
48 + // via Quickshell.iconPath(). All names verified present in the Adwaita theme.
49 + function iconName(event, value) {
50 + const name = String(event);
51 + const text = String(value);
52 + const muted = text === "muted" || (isNumeric(text) && Number(text.replace("%", "")) <= 0);
53 + if (name === "volume")
54 + return muted ? "audio-volume-muted" : (Number(text.replace("%", "")) < 34 ? "audio-volume-low" : (Number(text.replace("%", "")) < 67 ? "audio-volume-medium" : "audio-volume-high"));
55 + if (name === "microphone")
56 + return muted ? "microphone-sensitivity-muted" : "microphone-sensitivity-high";
57 + if (name === "brightness")
58 + return "display-brightness-symbolic";
59 + if (name === "media")
60 + return text.indexOf("pause") >= 0 ? "media-playback-pause" : "media-playback-start";
61 + if (name === "screenshot")
62 + return "applets-screenshooter";
63 + if (name === "color")
64 + return "color-picker";
65 + if (name === "error")
66 + return "dialog-error";
67 + return "dialog-information";
68 + }
39 - return Math.max(0, Math.min(1, number / 100));
70 + function displayLabel(event) {
71 + const name = String(event);
72 + const labels = {
73 + "volume": "Volume",
74 + "microphone": "Microphone",
75 + "brightness": "Brightness",
76 + "media": "Media",
77 + "screenshot": "Screenshot",
78 + "color": "Color",
79 + "error": "Error"
80 + };
81 + return labels[name] || (name.length > 0 ? name : "OSD");
82 + }
84 + // right-aligned glance value: "72%" for meters, a word for toggles, the
85 + // raw payload (media event / colour hex) otherwise. Errors render their
86 + // message in the body line instead, so the corner stays empty.
87 + function displayValue(event, value) {
88 + const name = String(event);
89 + const text = String(value);
90 + const normalized = normalizedValue(name, text);
91 + if (normalized >= 0)
92 + return `${Math.round(normalized * 100)}%`;
93 + if (text === "muted")
94 + return "muted";
95 + if (text === "unmuted")
96 + return "on";
97 + if (name === "error")
98 + return "";
99 + return text;
42 102 function iconRole(event, value) {
66 126 function numericText(event, value) {
67 - const name = String(event);
68 - if (name !== "volume" && name !== "brightness")
69 - return "";
71 - return `${Math.round(normalizedValue(name, value) * 100)}`;
127 + const normalized = normalizedValue(event, value);
128 + return normalized >= 0 ? `${Math.round(normalized * 100)}` : "";
74 131 function valueIndicator(event, value) {
80 137 "source": "Nuguland OsdValueIndicator.qml plus Nuguland OSD sliders",
81 138 "layout": "icon-left-value-right",
82 139 "iconRole": iconRole(name, text),
140 + "iconName": iconName(name, text),
141 + "displayLabel": displayLabel(name),
142 + "displayValue": displayValue(name, text),
83 143 "value": text,
84 144 "normalizedValue": hasProgress ? normalized : null,
85 145 "progressBar": {
116 176 "event": currentEvent,
117 177 "value": currentValue,
118 178 "role": currentRole,
179 + "iconName": iconName(currentEvent, currentValue),
180 + "displayLabel": displayLabel(currentEvent),
181 + "displayValue": displayValue(currentEvent, currentValue),
119 182 "lifetimeMs": lifetimeMs,
120 183 "restartCount": restartCount,
121 184 "supportedEvents": supportedEvents,

quickshell/nuguland/shell.qml

Modified
2 2 import QtQuick
3 3 import Quickshell
4 4 import Quickshell.Io
5 5 import Quickshell.Wayland
6 +import Quickshell.Widgets
7 8 ShellRoot {
8 9 id: shell
124 125 objectName: "osdOverlaySurface"
125 126 screen: modelData
126 127 visible: osd.visibleState
127 - implicitWidth: 320
128 - implicitHeight: 88
128 + implicitWidth: 300
129 + implicitHeight: osdCard.implicitHeight + 16
129 130 color: "transparent"
130 131 exclusionMode: ExclusionMode.Ignore
131 132 WlrLayershell.layer: WlrLayer.Overlay
142 143 right: 16
146 + // Mirrors the notification card's visual language (backdrop
147 + // alpha, radius, IconImage, IBM Plex, accent) but stays a
148 + // glance-only meter — no close/actions/body. The mask is left
149 + // empty on purpose: the OSD is non-interactive, so the surface
150 + // must pass clicks through (the inverse of the toast mask).
145 151 Rectangle {
146 152 id: osdCard
148 154 readonly property var indicator: osd.valueIndicator(osd.currentEvent, osd.currentValue)
149 155 readonly property string roleColor: osd.currentRole === "error" ? nuguTheme.error : (osd.currentRole === "warning" ? nuguTheme.warning : nuguTheme.ui.accent)
156 + readonly property bool hasBar: indicator.progressBar && indicator.progressBar.visible
157 + readonly property bool isError: osd.currentRole === "error"
158 + readonly property string resolvedIcon: Quickshell.iconPath(String(osd.iconName(osd.currentEvent, osd.currentValue)), true)
151 - anchors.fill: parent
160 + anchors.left: parent.left
161 + anchors.right: parent.right
162 + anchors.top: parent.top
152 163 anchors.margins: 8
153 - radius: 20
154 - color: nuguTheme.withAlpha(nuguTheme.ui.backdrop, 0.94)
155 - border.width: 0
156 - border.color: roleColor
164 + implicitHeight: osdRow.implicitHeight + 24
165 + radius: 14
166 + color: nuguTheme.withAlpha(nuguTheme.ui.backdrop, 0.92)
157 167 opacity: osd.visibleState ? 1 : 0
169 + // left accent strip, like the notification card's urgency bar
159 170 Rectangle {
160 - id: osdIcon
162 171 anchors.left: parent.left
163 - anchors.leftMargin: 14
164 - anchors.verticalCenter: parent.verticalCenter
165 - width: 42
166 - height: 42
167 - radius: 14
168 - color: nuguTheme.withAlpha(osdCard.roleColor, 0.2)
169 - border.width: 0
170 - border.color: osdCard.roleColor
172 - Text {
173 - anchors.centerIn: parent
174 - color: nuguTheme.content.normal
175 - font.family: "IBM Plex Mono"
176 - font.pixelSize: 13
177 - font.bold: true
178 - text: String(osdCard.indicator.iconRole || "osd").slice(0, 2)
172 + anchors.top: parent.top
173 + anchors.bottom: parent.bottom
174 + width: 3
175 + radius: 2
176 + color: osdCard.roleColor
183 - Column {
184 - anchors.left: osdIcon.right
185 - anchors.leftMargin: 12
179 + Row {
180 + id: osdRow
181 + anchors.left: parent.left
186 182 anchors.right: parent.right
183 + anchors.leftMargin: 14
187 184 anchors.rightMargin: 14
188 185 anchors.verticalCenter: parent.verticalCenter
189 - spacing: 6
191 - Row {
192 - width: parent.width
193 - spacing: 8
195 - Text {
196 - color: nuguTheme.content.normal
197 - font.family: "IBM Plex Sans"
198 - font.pixelSize: 15
199 - font.bold: true
200 - text: osd.currentEvent.length > 0 ? osd.currentEvent : "osd"
201 - width: parent.width - valueText.width - parent.spacing
202 - elide: Text.ElideRight
205 - Text {
206 - id: valueText
208 - color: nuguTheme.ui.normal
209 - font.family: "IBM Plex Mono"
210 - font.pixelSize: 13
211 - text: osd.currentValue
186 + spacing: 12
216 188 Rectangle {
217 - width: parent.width
218 - height: osdCard.indicator.progressBar && osdCard.indicator.progressBar.visible ? 8 : 0
219 - visible: height > 0
220 - radius: 4
221 - color: nuguTheme.withAlpha(nuguTheme.ui.minor, 0.3)
189 + anchors.verticalCenter: parent.verticalCenter
190 + width: 40
191 + height: 40
192 + radius: 12
193 + color: nuguTheme.withAlpha(osdCard.roleColor, 0.18)
223 - Rectangle {
224 - anchors.left: parent.left
225 - anchors.top: parent.top
226 - anchors.bottom: parent.bottom
227 - width: parent.width * Math.max(0, Math.min(1, osdCard.indicator.normalizedValue || 0))
228 - radius: parent.radius
229 - color: osdCard.roleColor
195 + IconImage {
196 + anchors.centerIn: parent
197 + width: 24
198 + height: 24
199 + source: osdCard.resolvedIcon
200 + visible: source.toString().length > 0
204 + Column {
205 + width: parent.width - 40 - parent.spacing
206 + anchors.verticalCenter: parent.verticalCenter
207 + spacing: 7
209 + Row {
210 + width: parent.width
211 + spacing: 8
213 + Text {
214 + id: osdLabel
215 + color: nuguTheme.content.normal
216 + font.family: "IBM Plex Sans"
217 + font.pixelSize: 14
218 + font.bold: true
219 + text: String(osdCard.indicator.displayLabel || "OSD")
220 + width: parent.width - osdValue.width - parent.spacing
221 + elide: Text.ElideRight
224 + Text {
225 + id: osdValue
226 + anchors.baseline: osdLabel.baseline
227 + color: osdCard.hasBar ? osdCard.roleColor : nuguTheme.ui.normal
228 + font.family: "IBM Plex Mono"
229 + font.pixelSize: osdCard.hasBar ? 14 : 13
230 + font.bold: osdCard.hasBar
231 + text: osdCard.isError ? "" : String(osdCard.indicator.displayValue || "")
235 + // hero meter for volume/brightness/microphone levels
236 + Rectangle {
237 + width: parent.width
238 + height: osdCard.hasBar ? 5 : 0
239 + visible: osdCard.hasBar
240 + radius: 2.5
241 + color: nuguTheme.withAlpha(nuguTheme.ui.minor, 0.28)
234 - Text {
235 - visible: osd.currentRole === "error"
236 - color: nuguTheme.error
237 - font.family: "IBM Plex Sans"
238 - font.pixelSize: 12
239 - text: osd.currentValue
240 - width: parent.width
241 - elide: Text.ElideRight
243 + Rectangle {
244 + anchors.left: parent.left
245 + anchors.top: parent.top
246 + anchors.bottom: parent.bottom
247 + width: parent.width * Math.max(0, Math.min(1, osdCard.indicator.normalizedValue || 0))
248 + radius: parent.radius
249 + color: osdCard.roleColor
250 + Behavior on width {
251 + NumberAnimation { duration: nuguTheme.lowPowerMode ? 0 : 160; easing.type: Easing.OutCubic }
256 + // error payload reads in the body line
257 + Text {
258 + visible: osdCard.isError
259 + color: nuguTheme.error
260 + font.family: "IBM Plex Sans"
261 + font.pixelSize: 12
262 + text: osd.currentValue
263 + width: parent.width
264 + wrapMode: Text.WordWrap
265 + maximumLineCount: 2
266 + elide: Text.ElideRight
246 271 Behavior on opacity {