-
Notifications
You must be signed in to change notification settings - Fork 2
Description
On Linux some media players have instance suffixes, e.g. Firefox, Chrome, mpd and GSConnect. See examples in #9.
These should be stripped away and it should be possible to define an individual instance suffix regex:
The common base regex should be instance[_-\d]+, which should always be applied to any D-Bus service name by default. The rule is that any suffix match MUST be preceded by "org.mpris.MediaPlayer2.", the service identifier that is declared in a media player definition file, followed by a period e.g. (kdeconnect.) and must not be followed by any other characters. Consequently org.mpris.MediaPlayer2.instance123 should not be stripped at all and instance123 should be the identifier to match. The common base regex should be documented, but it doesn't have to be present in any player definition or in players.json, as this definition is a static. Media player definitions should be able to define an individual regex because some media players have a different suffix, e.g. mpd and GSConnect. When the individual regex doesn't match, then the service should be ignored. It should not be attempted to fall back to the common base regex.
Suffix examples:
kdeconnect.mpris_9bda6cc0087c4b9cbd567626bb1a5c8c
# https://github.com/GSConnect/gnome-shell-extension-gsconnect/issues/759
org.mpris.MediaPlayer2.GSConnect.XiaomiAmazonKindle
# https://github.com/natsukagami/mpd-mpris/blob/master/README.md
org.mpris.MediaPlayer2.mpd.arbitrary
sources:
lin_mpris:
- service: kdeconnect
instance_pattern: mpris[_aA-fF0-9]+sources:
lin_mpris:
# https://github.com/natsukagami/mpd-mpris/blob/master/README.md
- service: mpd
instance_pattern: .+The instance_pattern (could also be called instance_regex) MUST be a separate key here because it is often desirable to be able to strip away the instance suffix and be left with the static part, which can be used in places where raw identifiers are needed in application logic. Using regular expressions to match an identifier from #9 would not allow this, e.g.:
sources:
lin_mpris:
- service:
regex: mpd\..+ # can't extract a static component with this