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

fix: remove pattern matching in favor of checking names with *and* without instance #39

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions services/mpris/mpris_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package mpris

import (
"path"
"sptlrx/player"
"strings"

Expand Down Expand Up @@ -38,15 +37,13 @@ func (c *Client) getPlayer() (*mpris.Player, error) {
return mpris.New(conn, players[0]), nil
}

// iterating over configured names
// iterating over configured whitelisted players
for _, p := range c.players {
// adding the D-Bus bus name prefix
p := "org.mpris.MediaPlayer2." + p
for _, player := range players {
// support pattern matching
match, err := path.Match("org.mpris.MediaPlayer2."+p, player)
if err != nil {
return nil, err
}
if match {
// check for the name with and without the instance suffix
if p == player || strings.HasPrefix(player, p+".instance") {
return mpris.New(conn, player), nil
}
}
Expand Down