Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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?

share|improve this answer
    
Yes I am using a single instance of VLC. I expected sending messages such as "play/pause" to those instances to be possible, since one can add additional items to a running instance from the command line. –  vemv Apr 6 '13 at 20:15
    
Yes but what's the point of sending a hotkey at launch time? Do you want it to start paused? I don't understand what your desired behavior is. Why don't you just hit space when the video window has the focus? –  terdon Apr 6 '13 at 20:17
    
No I don't want to send a hotkey at startup time. I want to send a message to running/existing instances: "stop the file you're playing". –  vemv Apr 6 '13 at 20:18
1  
I guess mine could be considered an XY question. I was attempting to build a music manager on top of VLC and sending messages sounded very tempting. Will look into a proper approach such as leveraging an API then. –  vemv Apr 6 '13 at 20:19
    
If all you want is to pause/unpause a single vlc instance, you can do kill -STOP $(pgrep vlc) to pause and kill -CONT $(pgrep vlc) to unpause. –  terdon Apr 6 '13 at 20:23

By using vlc --key-next foo you've assigned "Next" to a key named "Foo", which you probably don't have. ;)

The <string> is composed of modifier keys (Alt, Shift, Ctrl, Meta, Command) separated by a dash (-) and terminated by a key (*a...z, +, =, -, ',', +, <, >, `, /, ;, ', \, [, ], , Left, Right, Up, Down, Space, Enter, F1...F12, Home, End, Menu, Esc, Page Up, Page Down, Tab, Backspace, Mouse Wheel Up and Mouse Wheel Down).

So vlc --key-next alt-n will set Alt+n to go to the Next media file loaded.

More info here.

share|improve this answer
    
Strictly speaking, I believe this answers my question. However, could you please tell me how to trigger a command such as next, rather than bind the command to a key? –  vemv Apr 6 '13 at 19:02
1  
As far as I know, there's no way to control the player like that (start, stop, pause, prev, next, etc.) via command-line arguments. –  Ƭᴇcʜιᴇ007 Apr 6 '13 at 19:25
    
wiki.videolan.org/VLC-0-8-6_command-line_help It doesnt look like a way to control it live, just ways to start it up. Some of the scripting methods that people worked on, became obsolete in later versions. Talking to it with HTML? might stay longer, beings every thing is "web" these days :-) –  Psycogeek Apr 6 '13 at 19:50
    
Ahhh too bad. Given that VLC can run in single-instance mode (see terdon's answer) it should be feasible to communicate with the underlying running process behind the singleton instance. One can add files to its queue, so I was expecting that one could send it other kind of messages as well. –  vemv Apr 6 '13 at 20:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.