Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Create a named pipe like this:

mkfifo ~/.mplayer/pipe

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


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.

share|improve this answer
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! – Mohammad Aug 29 '12 at 23:08
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
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.m17 Oct 12 '14 at 3:30

Your Answer


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.