Tuesday, July 26, 2011

MPC, xbindkeys and multimedia keys

I want to use my multimedia keys with MPD even without an always running client.
Here's one way to make it work independently of the used window manager.

Install MPC and xbindkeys:

emerge mpc xbindkeys

Start xbindkeys to find the right settings and press the key you want to bind:

xbindkeys -k

If you don't get any output at all, use the following switch:

xbindkeys -mk

The output should look like this, it's my toggle play/pause key:

"(Scheme function)"
m:0x10 + c:172
Mod2 + XF86AudioPlay

"(Scheme function)" might be "NoCommand" in your case.

Copy the output into ~/.xbindkeysrc and replace "(Scheme function)" or "NoCommand" with the command for mpc:

"mpc toggle"
m:0x10 + c:172
Mod2 + XF86AudioPlay

Do this for all the multimedia keys you want to use.

My .xbindkeysrc looks like this:

"mpc toggle"
m:0x10 + c:172
Mod2 + XF86AudioPlay

"mpc prev"
m:0x10 + c:173
Mod2 + XF86AudioPrev

"mpc next"
m:0x10 + c:171
Mod2 + XF86AudioNext

"mpc volume -2"
m:0x10 + c:121
Mod2 + XF86AudioMute

"mpc volume 0"
m:0x10 + c:122
Mod2 + XF86AudioLowerVolume

"mpc volume +2"
m:0x10 + c:123
Mod2 + XF86AudioRaiseVolume

And yes.. my mute and lower volume keys seem to be switched for any unknown reason. You have to check if it's this case for you too, otherwise fit the commands to your needs.

Check the man page of MPC for all possible parameters:

man mpc

Finally start xbindkeys and add it to your autostart:

xbindkeys &

There are still two small issues.
a) MPC can't toggle mute or restore the volume after mute.
b) Toggling play/pause is working but I don't get sound for any reason when it starts to play again. I have to skip to the next song to hear the music again.

Monday, July 11, 2011

mpdscribble 0.22

Mpdscribble 0.22 was released three days ago and the curl bug seems to be fixed.
I've added it to the install instruction.