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

[bug] Playerctl is too restrictive in matching a media player instance #198

Closed
xPMo opened this issue Oct 19, 2020 · 4 comments
Closed

[bug] Playerctl is too restrictive in matching a media player instance #198

xPMo opened this issue Oct 19, 2020 · 4 comments
Assignees
Milestone

Comments

@xPMo
Copy link
Contributor

xPMo commented Oct 19, 2020

I use KDEConnect, which permits me to remotely control media in-between my laptop/desktop/phone.

However, the player names reported by playerctl are like the following:

$ playerctl -l
kdeconnect.mpris_e3c8035c2d55bf42ff347d4b0a60f4ac
kdeconnect.mpris_da39a3ee5e6b4b0d3255bfef95601890
kdeconnect.mpris_afd807095922a35fd0fd40b59abcf27c
strawberry

It is unwieldy to specify the full strings for these players. Multiple players from a single remote host will show up as multiple kdeconnect.mpris_[hash] on the local host. Also, Firefox uses something like firefox.instance[num].

Suggested solution:

Implement glob matching for player lists. Interpret playerctl -i 'kdeconnect.*,firefox.*' to ignore all matching players.

This kind of matching could also be useful in -p to specify preferences but allow any player to be controlled:

playerctl -p 'strawberry,spotify,*'   # prefer local strawberry and spotify, but if neither exists, control the first available player

Is this in-scope, or is scripting on the output of playerctl -l preferred?

Thank you!

@xPMo xPMo added the bug label Oct 19, 2020
@acrisci
Copy link
Member

acrisci commented Oct 19, 2020

For multiple instances, there's a part of the mpris specification for that kdeconnect should be using here. They should be specifying their instances with kdeconnect.mpris.instance[ID]. In that case, playerctl will match any instance when you specify kdeconnect.mpris or a specific instance if the full name is given.

https://specifications.freedesktop.org/mpris-spec/2.2/

In the case where the media player allows multiple instances running simultaneously, each additional instance should request a unique bus name, adding a dot and a unique identifier to its usual bus name, such as one based on a UNIX process id. For example, this could be:

org.mpris.MediaPlayer2.vlc.instance7389

Make an issue with them asking to implement this part of the spec.

As for your suggested solution, this is already implemented with the special player name %any which matches any player not given explicitly in the list. Try this:

playerctl -p strawberry,spotify,%any

There's also playerctld which can be used to select the last active player.

With all of these options to select players, I don't think general globbing is useful when players follow the instance spec.

@xPMo
Copy link
Contributor Author

xPMo commented Oct 19, 2020

They should be specifying their instances with kdeconnect.mpris.instance[ID]. In that case, playerctl will match any instance when you specify kdeconnect.mpris or a specific instance if the full name is given.

I answered my followup question by searching the code for ".instance". Thanks for linking that. I'll go see about reporting it upstream.

... %any ...

Thanks for that as well.

@xPMo xPMo closed this as completed Oct 19, 2020
@xPMo
Copy link
Contributor Author

xPMo commented Nov 3, 2020

I was looking to open the bug against KDEConnect, but I realized the specification doesn't require instanceN, just that the unique identifier is preceded with a period and only contains [a-z][A-Z][0-9]_-. So kdeconnect.mpris_2743f90f62ea442297cd4aa5e1809724 does match the specification and should be matched by -p kdeconnect.

@xPMo xPMo reopened this Nov 3, 2020
@xPMo xPMo changed the title [Feature Request] Ignore/select player(s) by pattern [bug] Playerctl is too restrictive in matching a media player instance Nov 3, 2020
@acrisci
Copy link
Member

acrisci commented Nov 3, 2020

Oh ok I think it would be safe to drop the instance requirement after the dot.

@acrisci acrisci added this to the 2.3.1 milestone Nov 3, 2020
@acrisci acrisci closed this as completed in d0a59e2 Nov 4, 2020
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

2 participants