Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer 1

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.

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! –  Hedy 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
add comment

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.