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

Ignore Specific Players #10

Open
prikhi opened this issue Mar 21, 2024 · 2 comments
Open

Ignore Specific Players #10

prikhi opened this issue Mar 21, 2024 · 2 comments

Comments

@prikhi
Copy link

prikhi commented Mar 21, 2024

Hey, love this & use it to get desktop notifications for media players that either don't send dbus notifications or want to send their own, uniquely styled notifications that look out of place from the rest of my WM themeing!

The one annoyance is I don't care about some "players" and would like to ignore relaying their mpris notifications to desktop notifications. I.e., Firefox creates excessive messages, like watching a video in firefox will make it start sending mpris messages, and then it proceeds to send one notification for every sound that is made anywhere(like, per slack message, for each tick in a figma timer, etc).

Would love it if we could specify a config option for ignoring specific clients - maybe through the identifier in the bus name? Ideally it wouldn't care about the instance-specific identifier, I want to ignore all *.firefox.* messages, not just *.firefox.instance9001.

@l1na-forever
Copy link
Owner

Hi Pavan,
I'm so glad to hear that you've found this useful 😁! Yeah, the request makes total sense, looking into it.

@l1na-forever
Copy link
Owner

One thing that's a bit tricky is that (at least on my system), Firefox messages posted to DBus don't have a useful sender field (it's unique to the outer Firefox process, but otherwise not useful). From dbus-monitor:

signal time=1711425911.382899 sender=:1.45 -> destination=(null destination) serial=1645 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [                             
      dict entry(                                                                                                          
         string "Metadata"
         variant             array [
               dict entry(
                  string "mpris:trackid"
                  variant                      object path "/org/mpris/MediaPlayer2/firefox"
               )
...

Although the sender=:1.45 as part of the signal message metadata isn't too useful for filtering, the MPRIS specification does indicate that there should be a useful and unique bus name for message senders:

Each media player must request a unique bus name which begins with org.mpris.MediaPlayer2.

So, we can query for available MPRIS players via DBus' ListNames method:

$ dbus-send --print-reply --session --dest=org.freedesktop.DBus "/org/freedesktop/DBus" "org.freedesktop.DBus.ListNames"

method return time=1711427804.876720 sender=org.freedesktop.DBus -> destination=:1.351 serial=3 reply_serial=2
   array [          
      string "org.freedesktop.DBus"
      string ":1.7"                
      string "org.freedesktop.Notifications"
      string "org.mpris.MediaPlayer2.firefox.instance_1_45"
      string ":1.9"                                                                                                        
      string "org.mpris.MediaPlayer2.spotifyd.instance2353"
      string ":1.22"
      ...

and from there, figure out all of that bus' other "queued owners":

dbus-send --print-reply --session --dest=org.freedesktop.DBus "/org/freedesktop/DBus" "org.freedesktop.DBus.ListQueuedOwners" "string:org.mpris.MediaPlayer2.firefox.instance_1_45"                                     

method return time=1711427880.878966 sender=org.freedesktop.DBus -> destination=:1.352 serial=3 reply_serial=2
   array [
      string ":1.45"
   ]

.. which we can use to map back to a MPRIS signal sender 🎉. So, the actual exclusion filter will look more like excluding an MPRIS Media Player's namespace (in your case, org.mpris.MediaPlayer2.firefox). I'll work on this in the short term.

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

No branches or pull requests

2 participants