Using VLC’s hot keys via the command line

command linevlc-media-player

vlc --help lists, among other content, command line options like the following:

 Hot keys
      --global-key-toggle-fullscreen <string>
                                 Fullscreen
      --key-toggle-fullscreen <string>
                                 Fullscreen
      --global-key-leave-fullscreen <string>
                                 Leave fullscreen
      --key-leave-fullscreen <string>
                                 Leave fullscreen
      --global-key-play-pause <string>
                                 Play/Pause
      --key-play-pause <string>  Play/Pause

When I try to use them though, they don't work at all. I don't understand why do they have to take a <string> parameter as well.

So my scenario looks like this:

  • I run VLC either with a UI or in headless mode
  • I execute e.g. vlc --key-next foo (for triggering "next"), foo being a dummy parameter
  • VLC doesn't complain (unlike when you don't pass a string), but command has no effect

What's a working example of command-line-triggered VLC hot keys?

Best Answer

What you are asking for is almost certainly impossible. Command line arguments are passed to a program at launch. Once it has loaded, any settings changed will be in effect but you cannot pass any more arguments.

When you run vlc --whatever it will attempt to launch another instance of vlc which will load with the option --whatever set. If you have "allow only one instance" set in your vlc preferences, this will have no effect and it will look like "vlc does not complain". You might be able to get this sort of behavior from the VideoLanServer but I have never used it and do not know. You will not get this from any "normal" program that is not running in some kind of server or listening mode.

enter image description here

A better question is why would you need this behavior? If you are displaying vlc output normally, you can just use the hotkeys normally as long as the vlc window has the mouse focus. Even if you don't and you are, for example, watching vlc in a terminal over an ssh connection to a headless server using its ASCII art output modes, the hotkeys work as long as the terminal with the ssh has focus. Are you trying to somehow script this behavior? Could this be an XY problem?

Related Question