How to : Create keyboard shortcuts for MPC in e17

Posted on Tue 25 July 2006 in Life • 2 min read

In this article, we will just make our CLI life a bit easier by implementing a few keyboard shortcuts for our Music Player Daemon (MPD) These keyboard shortcuts will take care of common Multimedia Tasks such as Play, Pause, Raise/Lower Volume, Stop etc.. I will speak about configuring these keyboard shortcuts in Enlightenment 17 (e17) desktop manager. Lets begin :

1. Find the keycodes of shortcut keys

This step is necessary if you are going to use Multimedia Keys as
shortcuts..otherwise if you're using common shortcuts (e.g :
CTRL+ALT+ P for play) please skip this :)

We need to know the keycodes of the Multimedia keys and then map
them so that they can be used as shortcuts. Open up a Terminal type


A new window (Event Tester) would popup. Put that window under focus
and then press the multimedia keys.


Then note the *keycode* in the outputs that show up in the terminal
(ref. figure). We need to map these keycodes to the corresponding
keys. To do that open the file */usr/lib/X11/XKeysymDB* or
*/usr/share/X11/XKeysymDB* and look for the keywords "Play" etc..
Now create a new file *\~/.Xmodmap* then put the following text into
the file :

`keycode ppp = XF86AudioPlay  `

keycode qqq = XF86AudioNext

keycode rrr = XF86AudioPrev</code>

where ppp, qqq, rrr are the 3 digit keycodes you obtain for a
Multimedia Key from xev. Also replace *XF86AudioPlay* as per your

Now insert the following command into session startup :

`xmodmap /home/user_name/.Xmodmap`

  1. Bind the keys in Enlightenment 17 (e17)

    To include any keyboard shortcut in e17 we need to use the following command :

    enlightenment_remote -binding-key-add OPT1 OPT2 OPT3 OPT4 OPT5 OPT6Where the conventions are :

    CONTEXT = OPT1 (e.g : ANY)

    KEY = OPT2 (e.g : “Delete”)

    MODIFIERS = OPT3 (e.g : CTRL|ALT i.e ctrl or alt)

    ANY_MOD = OPT4 (e.g : 0)

    ACTION = OPT5 (e.g : “exit”)

    PARAMS = OPT6 (e.g : “”)

    In order to implement the play/pause shortcut we can use

    enlightenment_remote -binding-key-add ANY XF86AudioPlay NONE 0 "exec" "mpc toggle"

    Similarly here are the other commands :

    enlightenment_remote -binding-key-add ANY XF86AudioStop NONE 0 “exec” “mpc stop”

    enlightenment_remote -binding-key-add ANY XF86AudioRaiseVolume NONE 0 “exec” “mpc volume +5”

    enlightenment_remote -binding-key-add ANY XF86AudioLowerVolume NONE 0 “exec” “mpc volume -5”

    enlightenment_remote -binding-key-add ANY XF86AudioNext NONE 0 “exec” “mpc next”

    enlightenment_remote -binding-key-add ANY XF86AudioPrev NONE 0 “exec” “mpc prev”

References :

Using Multimedia Keys @ Gentoo Wiki

Keybindings @ e17 user guide

technorati tags:mpd, mpc, e17, enlightenment, keyboard+shortcuts, shortcut+keys, mp3, suse