open-in-mpv: respect the player's executable config

config.yml allows to specify `executable` distinct from player name:
```
players:
  mpv:
    name: mpv
    executable: my-mpv-wrapper
    ...
```

before, the `executable` setting would be ignored:
```
$ open-in-mpv 'mpv:///open?url=https%3A%2F%2Fyoutu.be%2FdQw4w9WgXcQ'
2024/02/15 08:27:41 /usr/bin/mpv https://youtu.be/dQw4w9WgXcQ
```

after this patch, it's respected:
```
open-in-mpv 'mpv:///open?url=https%3A%2F%2Fyoutu.be%2FdQw4w9WgXcQ'
2024/02/15 08:27:53 /usr/local/bin/my-mpv-wrapper https://youtu.be/dQw4w9WgXcQ
```
This commit is contained in:
2024-02-15 08:09:31 +00:00
parent 07fc639b28
commit d48c57ca83
3 changed files with 8 additions and 8 deletions

View File

@@ -38,8 +38,8 @@ func main() {
log.Println("Error writing to socket, opening new instance") log.Println("Error writing to socket, opening new instance")
} }
args := opts.GenerateCommand() executable, args := opts.GenerateCommand()
player := exec.Command(opts.Player, args...) player := exec.Command(executable, args...)
log.Println(player.String()) log.Println(player.String())
must(player.Start()) must(player.Start())
// must(player.Wait()) // must(player.Wait())

View File

@@ -149,7 +149,7 @@ func (o Options) overrideFlags() string {
// Builds a CLI command used to invoke the player with the appropriate // Builds a CLI command used to invoke the player with the appropriate
// arguments // arguments
func (o Options) GenerateCommand() []string { func (o Options) GenerateCommand() (string, []string) {
var ret []string var ret []string
playerConfig := GetPlayerConfig(o.Player) playerConfig := GetPlayerConfig(o.Player)
@@ -172,7 +172,7 @@ func (o Options) GenerateCommand() []string {
ret = append(ret, o.Url.String()) ret = append(ret, o.Url.String())
return ret return playerConfig.Executable, ret
} }
// Builds the IPC command needed to enqueue videos if the player requires it // Builds the IPC command needed to enqueue videos if the player requires it

View File

@@ -31,8 +31,8 @@ func Test_GenerateCommand(t *testing.T) {
o.Flags = "--vo=gpu" o.Flags = "--vo=gpu"
o.Pip = true o.Pip = true
args := o.GenerateCommand() executable, args := o.GenerateCommand()
t.Logf("%s %v", o.Player, args) t.Logf("%s %v", executable, args)
} }
func Test_GenerateIPC(t *testing.T) { func Test_GenerateIPC(t *testing.T) {
@@ -98,8 +98,8 @@ func Test_Parse(t *testing.T) {
t.Fatal("Err should not be nil") t.Fatal("Err should not be nil")
} }
args := o.GenerateCommand() executable, args := o.GenerateCommand()
t.Logf("%s %v", o.Player, args) t.Logf("%s %v", executable, args)
} }
func Test_sliceContains(t *testing.T) { func Test_sliceContains(t *testing.T) {