aurora9c4cb2d
aurora: add notification sound on popup
+13 −0
3 files changed
- M .config/hypr/hyprland.lua +1 −0
- M .config/quickshell/aurora/Notifs.qml +12 −0
- A .config/quickshell/aurora/sounds/Blow.aiff
| @@ -20,6 +20,7 @@ hl.on("hyprland.start", function() | |||
| 20 | 20 | hl.exec_cmd("wl-paste --type image --watch cliphist store") | |
| 21 | 21 | hl.exec_cmd("hyprpm reload -n") | |
| 22 | 22 | hl.exec_cmd("kanshi") | |
| 23 | + | hl.exec_cmd("systemctl --user start aurora") | |
| 23 | 24 | -- hl.exec_cmd("waybar") | |
| 24 | 25 | -- hl.exec_cmd("swaync") | |
| 25 | 26 | hl.exec_cmd("gammastep") | |
| @@ -8,6 +8,11 @@ import Quickshell.Services.Notifications | |||
| 8 | 8 | Singleton { | |
| 9 | 9 | id: root | |
| 10 | 10 | property bool dnd: false | |
| 11 | + | ||
| 12 | + | // sound played on every toast (silenced by do-not-disturb, except critical ones) | |
| 13 | + | property bool soundEnabled: true | |
| 14 | + | property string soundFile: Quickshell.env("HOME") + "/.config/quickshell/aurora/sounds/Blow.aiff" | |
| 15 | + | property real soundVolume: 0.7 | |
| 11 | 16 | property var popups: [] // [{n, until}] | |
| 12 | 17 | readonly property var model: server.trackedNotifications | |
| 13 | 18 | readonly property int count: server.trackedNotifications.values.length | |
| @@ -26,7 +31,14 @@ Singleton { | |||
| 26 | 31 | function dropPopup(n) { | |
| 27 | 32 | popups = popups.filter(function (p) { return p.n !== n }) | |
| 28 | 33 | } | |
| 34 | + | function playSound() { | |
| 35 | + | if (!soundEnabled) return | |
| 36 | + | Quickshell.execDetached(["sh", "-c", | |
| 37 | + | '[ -f "$1" ] || exit 0; pw-play --volume="$2" "$1" 2>/dev/null || paplay "$1" 2>/dev/null', | |
| 38 | + | "sh", soundFile, String(soundVolume)]) | |
| 39 | + | } | |
| 29 | 40 | function push(n) { | |
| 41 | + | playSound() | |
| 30 | 42 | var ms = n.urgency === NotificationUrgency.Critical ? 12000 | |
| 31 | 43 | : (n.expireTimeout > 0 ? n.expireTimeout * 1000 : 5000) | |
| 32 | 44 | var next = popups.concat([{ n: n, until: Date.now() + ms }]) | |
[Binary file]