Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for sound #82

Open
MyriaCore opened this issue Aug 28, 2020 · 3 comments
Open

Support for sound #82

MyriaCore opened this issue Aug 28, 2020 · 3 comments

Comments

@MyriaCore
Copy link
Contributor

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.

@phuhl
Copy link
Owner

phuhl commented Aug 31, 2020

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.

@S-NA
Copy link
Contributor

S-NA commented Mar 18, 2022

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.

@phuhl
Copy link
Owner

phuhl commented Mar 18, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants