linux_notification_center
linux_notification_center copied to clipboard
Support for sound
This stackoverflow post implies that notification managers can actually control sounds. Not 100% sure if many applications use this, or if they just play the sounds themselves, but that's the deal. This is from the hints table:
+------------------------------------------------------------------------+
| Name | Value Type | Description |
|------------------+------------+----------------------------------------|
| "urgency" | byte | The urgency level. |
|------------------+------------+----------------------------------------|
| "category" | string | The type of notification this is. |
|------------------+------------+----------------------------------------|
| | | This specifies the name of the |
| | | desktop filename representing the |
| | | calling program. This should be the |
| | | same as the prefix used for the |
| "desktop-entry"> | string | application's .desktop file. An |
| | | example would be "rhythmbox" from |
| | | "rhythmbox.desktop". This can be used |
| | | by the daemon to retrieve the correct |
| | | icon for the application, for logging |
| | | purposes, etc. |
|------------------+------------+----------------------------------------|
| | | This is a raw data image format |
| | | which describes the width, height, |
| "image_data" | (iiibiiay) | rowstride, has alpha, bits per sample, |
| | | channels and image data respectively. |
| | | We use this value if the icon field is |
| | | left blank. |
|------------------+------------+----------------------------------------|
| "sound-file" | string | The path to a sound file to play |
| | | when the notification pops up. |
|------------------+------------+----------------------------------------|
| | | Causes the server to suppress |
| | | playing any sounds, if it has that |
| "suppress-sound" | boolean | ability. This is usually set when the |
| | | client itself is going to play its own |
| | | sound. |
|------------------+------------+----------------------------------------|
| | | Specifies the X location on the |
| "x" | int | screen that the notification should |
| | | point to. The "y" hint must also be |
| | | specified. |
|------------------+------------+----------------------------------------|
| | | Specifies the Y location on the |
| "y" | int | screen that the notification should |
| | | point to. The "x" hint must also be |
| | | specified. |
+------------------------------------------------------------------------+
It'd be cool to try to implement this functionality, specifically sound-file
and suppress-sound
.
As a general reference (you might have stumbled upon it already), https://developer.gnome.org/notification-spec/ is the official source for the protocol, that we need to implement.
I'd like this feature. But takes some effort.
The spec hosted on gnome.org 404s now. I used https://specifications.freedesktop.org/notification-spec/latest/ar01s09.html instead.
I have a rough version of sound support (it currently does not respect if do not disturb is set). You can find it here: https://github.com/S-NA/linux_notification_center/commit/7e204b18991388f6380a773dfe59e1ac3a827a64.patch
I will probably get around to adding do not disturb, eventually. Though I am not sure if the approach of spawning an external player is the correct one. Feedback is appreciated.
Intresting, this looks pretty good. Would you mind opening a Draft PR?
For playing sound, maybe this could be interesting: https://wiki.haskell.org/SDL