repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

notifications: play sound hints for eligible toasts

289c9b4f5b95fa121a368e6e3e6411cbbe9b7b63

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Honor the freedesktop sound hints: sound-file (path) plays via pw-play,
sound-name (theme id) via canberra-gtk-play, and suppress-sound mutes.
Only fires for toast-eligible notifications (skipped under DND). Verified
sound-file: quickshell spawns the player on arrival; suppress-sound stays
silent. sound-name needs canberra + a sound theme installed.

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

Changed files (1)

quickshell/nuguland/Notifications.qml

Modified
127 127 return h && h.value !== undefined && h.value !== null ? Number(h.value) : -1;
130 + // freedesktop sound hints. sound-file (path) plays via the PipeWire CLI;
131 + // sound-name (theme id) needs canberra + a sound theme. suppress-sound mutes.
132 + function playSound(notification) {
133 + const h = notification && notification.hints ? notification.hints : null;
134 + if (!h || h["suppress-sound"])
135 + return;
136 + const file = h["sound-file"];
137 + const name = h["sound-name"];
138 + if (file)
139 + Quickshell.execDetached(["pw-play", String(file)]);
140 + else if (name)
141 + Quickshell.execDetached(["canberra-gtk-play", "-i", String(name)]);
130 144 function toastTimeoutMs(row) {
131 145 if (row.urgency === "critical" || Number(row.expireTimeout) === 0)
132 146 return 0;
236 250 toastById = map;
237 251 activeToasts = activeToasts.filter((x) => x !== row.id).concat([row.id]);
252 + playSound(notification);
239 254 lastAction = {
240 255 "kind": "native-notification",