HOWTO:  Getting your Dell Inspiron 6000 Multimedia Keys to work with XFCE

If you are using a Dell Inspiron 6000 you have probably noticed that the multimedia keys on your notebook work fine in Gnome, but fail to work in XFCE.  After searching the net hundreds of times for a solution, I was only misinformed at the right method to take this on.  I have tested this method with Ubuntu 6.06, but I am sure it will work on any other Linux distribution.

The first thing first, I'm not going to give you a lot of irrelevant information, these notebooks use the same keysym codes, and it has already been done.  You need a file that contains the keymap for your notebook.  To do this create and save the following information to a file called .Xmodmap in your home directory.    (mousepad ~/.Xmodmap)

keycode 160=XF86AudioMute
keycode 162=XF86AudioPlay
keycode 176=XF86AudioRaiseVolume
keycode 174=XF86AudioLowerVolume
keycode 153=XF86AudioNext
keycode 144=XF86AudioPrev
keycode 164=XF86AudioStop


Now you should be able to issue this command and see the above codes:
       cat ~/.Xmodmap

Once this is finished you need to check your xmodmap for duplicate  keys.  This is most likely an issue for you, as it was for me.   Run the following command:
       xmodmap -pke

Make sure that no two Key codes have the same mapping.   For example if you notice that "keycode 131= XF86AudioPrev"    and also "keycode 144 = XF86AudioPrev"  you need to remove the key mapping for keycode 131.  The only XF86Audio  that needs to be mapped are for the keycodes in the file you created.  So if you see other keycodes that have the same mapping, you will need to remove them.

On my setup I had the following duplicate keycodes:

keycode 129
keycode 130
keycode 131
keycode 132

In order to remove those you need to issue the following commands at your shell prompt:

xmodmap -e "keycode 129 = "
xmodmap -e "keycode 130 = "
xmodmap -e "keycode 131 = "
xmodmap -e "keycode 132 = "

Now that you have removed the invalid keycodes, you should have the appropriate ones, please double check and make sure that the following only occur once each:

XF86AudioMute
XF86AudioPlay
XF86AudioRaiseVolume
XF86AudioLowerVolume
XF86AudioNext
XF86AudioPrev
XF86AudioStop

Now that you have your keybindings mapped right and have no duplicate mappings, you need to go into XFCE's  Keyboard Settings

Click the XFCE menu, Go to Settings, Click Keyboard Settings.  Now click the "Shortcuts" tab.  You now need to add a new "Theme"  Click the Add button that is on the left and name the new theme "Multimedia Keys"

Now on the right, these keybindings will need to meet your specific needs, so I am going to give you a few different examples of what to use.  I use Amarok for my music player, but I doubt most of you use amarok. I'd say the majority use xmms.


MUTE
To add a new keybinding click the "add" under the  "Shortcuts" box.  This will prompt for a command.  This is where you need to know what software your going to be controlling with your multimedia keys.    You can mute / unmute your Master mixer with the mute button, and it will work with all apps, or you can use keybindings for your specific multimedia player.

The command: amixer -q set Master toggle   can be set and when it asks for you to press the key combination, press the "mute" multimedia key.  
The command: dcop amarok player mute  can be used to mute Amarok player, once again when prompted hit the "mute" multimedia key.

VOLUMEDOWN
You can use the VolumeDown key either system wide or application wide, much like the mute button, this is totally left up to you for your own personal preferences

The command : amixer -q set PCM 2- unmute   will decrease the volume of the PCM mixer by 2 levels
The command :  dcop amarok player volumeDown  will decrease the volume in Amarok player  (by about 4% each time it's pressed)

VOLUMEUP
The volumeup multimedia key works just like the volumedown key but with an opposite effect of course

The command: amixer -q set PCM 2+ unmute   will increaste the PCM level by 2 each time pressed
The command: dcop amarok player volumeUp  will increase the volume by about 4% in Amarok player only


PLAY/PAUSE
With play/pause you will want to configure it for your specific player,  I am going to give the commands for Xmms and Amarok:

Amarok: dcop amarok player playPause
Xmms:  /usr/bin/xmms --play-pause

PREVIOUS/REWIND
This  key will go back one track with amaroK, but in xmms I think it will rewind 5 seconds, haven't tested it with xmms. The commands for each player are as follows

amaroK: dcop amarok player prev
Xmms: /usr/bin/xmms --rew

NEXT/FORWARD
Like the Previous/Rewind key, this song will do the opposite and move to the next track or in xmms likely it fast forwards 5 seconds into the current track.

amaroK: dcop amarok player next
Xmms: /usr/bin/xmms --fwd

STOP
The stop button stops the currently playing song in the media player.  I tend not to use this button, because it will stop the music in amaroK, and the Play multimedia key will not initiate properly after you have hit "stop"  However if you want to use this button anyway the following is what you need:

amaroK: dcop amarok player stop
Xmms:  /usr/bin/xmms --stop



Now that you have set all of the settings you need to test them to see if they work. If they work you need to put this simple script in your xfce autostart programs.  To do this follow these instructions:

At the command line do the following:  
mousepad ~/.xmodmap.sh

Now in mousepad copy and paste this section:
#!/bin/bash
xmodmap -e "keycode 129 = "
xmodmap -e "keycode 130 = "
xmodmap -e "keycode 131 = "
xmodmap -e "keycode 132 = "

xmodmap ~/.Xmodmap

exit

Save the file and exit.. **Be sure that you named your map file .Xmodmap and saved it in your $HOME directory, this section was at the very beginning of this howto.  If you saved the file as something else, replace the line that says "xmodmap ~/.Xmodmap" with the exact location of the xmodmap settings you saved earlier.

Next from the command line do:
chmod +x ~/xmodmap.sh

Now click your XFCE menu, go to Settings, Autostarted Applications, click ADD.  For the name, just make it xmodmap, for the description you can leave it blank.  For the command be sure you enter this exactly as I am showing it:

~/xmodmap.sh

Now close all running applications, and use <CTRL>+<ALT>+<BACKSPACE> to restart your X server.. Login and start up your preferred media player.  Test that the keybindings are still working.  If they are not, and you feel you have done everything correctly, please contact me (ttyfscker on irc **see below**)

I really hope this HOWTO solved your Dell Notebook multimedia keys issues in XFCE, if for some reason you get stumped and can't get it to working properly feel free to join us on IRC  @ irc.freenode.net  in the channel #linuxsociety. If you don't already have an IRC client check out our WebBased IRC interface at http://linuxsociety.org/cgi-bin/cgiirc-0.5.7/irc.cgi   

Written by ttyfscker on 09212006