7

How can I use my laptop's media buttons [Play/Pause, Next, Previous] to work with Mplayer? The XF86 buttons I think they're called.

4

Create a named pipe like this:

mkfifo ~/.mplayer/pipe

Then, put the following line in ~/.mplayer/config:

input=file=/home/<username>/.mplayer/pipe

or you can run mplayer with input argument:

mplayer -input file=/home/<username>/.mplayer/pipe

Now use System Setting->Keyboard->Shortcut and add a shortcut with the command parameter as (see mplayer -input cmdlist for the command list):

echo "<mplayer command>" > /home/<username>/.mplayer/pipe

e.g. echo "pt_step 1" > /home/<username>/.mplayer/pipe for next track.

and then assign a key to this shortcut.

  • Sounds interesting, but what happens when I'm not using MPlayer? Will my media buttons still work as normal? Or will these keyboard shortcuts override the normal functions of them. – Matt Aug 26 '12 at 16:39
  • Nope! They would still echo commands to the pipe which will go wasted! – Hedy Aug 29 '12 at 23:08
  • 1
    Hmm.. ok, I finally got around to trying this, and it doesn't seem to work. Nothing I echo into the pipe does anything. I have tried both .config, and with the arg pointing to the pipe, but still no luck. version is MPlayer svn r34540. I just tried lsof and it lists .mplayer/pipe is open by mplayer. – Matt Sep 12 '12 at 21:36
  • 1
    This works well. But how to enable the key without caring about active window. Like if I want to press a key while I am browsing but I want to act that key on Mplayer. – soham Oct 12 '14 at 3:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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