Skip to content

Commit

Permalink
Merge pull request #39 from BachoSeven/master
Browse files Browse the repository at this point in the history
fix: remove pattern matching in favor of checking names with *and* without instance
  • Loading branch information
raitonoberu authored Jan 12, 2024
2 parents 33899ed + 01250ff commit 05dfbd2
Showing 1 changed file with 5 additions and 8 deletions.
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

0 comments on commit 05dfbd2

Please sign in to comment.