Jump to content

Cannot pass argument in alfred bash script to mpv 0.25.0 using "open -a mpv file_name_here --args" anymore

Guy Stan

Recommended Posts

I have modified the Searchio! Alfred workflow of Dean (http://www.packal.org/workflow/searchio) to be able to directly play audio (from youtube for example) using mpv. For this I took inspiration from the ShortFilms workflow of Vitor (http://www.packal.org/workflow/shortfilms).


To do this, I previously used:

open -a "${audio_player}" "${1}" --args --vid=no


This worked perfectly until I upgraded (using brew (not brew cask)) to mpv 0.25.0

Since the upgrade, mpv doesn't recognise the args that are passed to it by open through the use of --args.


A simple test for this is [in a terminal/command line window; note: this requires mpv and youtube-dl to be installed]:

open -a mpv "youtube_video_link_here" --args --vid=no


I have read the documentation of open and mpv and I am not sure why the behaviour changed.


Anyone can help with this? The arguments passing issue using "open -a App_Name File_Name --args arg1" might be more widespread than just for this use case.

Is there anything I am missing in the use of the command open?





1) I have also filed a bug report with mpv (https://github.com/mpv-player/mpv/issues/4354) but I fear that this issue is more linked to the way "open" interacts with other commands (this worked with previous mpv versions though, i.e. mpv<0.25)

2) The modifications I have made allow to call for youtube video search in Searchio! using the alfred keyword "yt" and then:

  • Choosing an item on the Alfred displayed list while using CMD launches the playback of the corresponding youtube video in mpv
  • Choosing an item on the Alfred displayed list while using ALT launches the playback of the corresponding youtube audio in mpv


Edited by Guy Stan
Added info
Link to comment
Share on other sites

Open the debugger, and post the output.

Also, what happens if you, in the terminal, do mpv "${1}" --args --vid=no? You’re using open -a mpv, but that is unnecessary in this case: the code is just for you and you don’t need it to open the app. The CLI (which you have, since you installed via HB) suffices.

Link to comment
Share on other sites

I have tried to execute directly in the terminal l: mpv "${1}" --args --vid=no


This has the correct behaviour and opens up the mpv GUI but with no video, playing only the audio.


In the modified workflow though, I would need to be able to launch mpg with the GUI to be able to get access to the forward, backward, next, previous functions of the GUI even when playing audio only. 


I will post the debug info as soon as I am back in front of the computer. 

Link to comment
Share on other sites

It does work as expected on the command line.


mpv "${1}" --args --vid=no

works as expected when launched from the command line.


it is the use within the workflow through "open -a" that causes problems as the args  that force mpv to only play the audio are not passed correctly from "open - a" to mpv or taken correctly by mpv. 

Link to comment
Share on other sites

This has now been resolved with the help of Akemi from the mpv developers' team.


The trick is to force the use of the GUI by calling directly mpv in a bash script (without using open):

mpv --player-operation-mode=pseudo-gui --video=no


Here is the corresponding mpv github thread: https://github.com/mpv-player/mpv/issues/4354


This can now be marked as resolved.


Thank you Vitor and Dean for your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...