Sam Morar's blog
Using multimedia keys in GDM
Sam Morar — Sun, 11/01/2009 - 21:31

I currently use MPD as my preferred media player, as it runs on my central machine, and I can easily control it from any other machine on our home network.
Now, occasionally, one wishes to just turn on the computer, and without logging in and doing all that admin, get some music playing / skip a song or two and adjust the volume to the correct settings.
The problem is that the first thing that loads up is GDM, which does not know what to do when you press one of the multimedia key on a multimedia keyboard.
Fortunately, this can be fixed easily using the accessibility framework built into GDM.
Edit the following lines in /etc/gdm/gdm.conf:
AddGtkModules=true
GtkModulesList=/usr/lib/gtk-2.0/modules/libkeymouselistener
Next, you need to add entries for each of your multimedia keys in /etc/gdm/modules/AccessKeyMouseEvents.
The entry format is as follows:
keycode num_keypresses keypress_duration timeout command command_args
Where, the command with it's arguments is executed when the key given by keycode is depressed as many times as specified by the number of keypresses for longer than the keypress duration. Note, the command will be run as root, so be sure that it can't do anything destructive!!
For example, my configuration which uses the mpc command to control the mpd daemon is as follows:
XF86AudioNext 1 0 1000 /usr/bin/mpc next
XF86AudioPrev 1 0 1000 /usr/bin/mpc prev
XF86AudioStop 1 0 1000 /usr/bin/mpc stop
XF86AudioPlay 1 0 1000 /usr/bin/mpc toggle
XF86AudioLowerVolume 1 0 1000 /usr/bin/mpc volume -2
XF86AudioRaiseVolume 1 0 1000 /usr/bin/mpc volume +2
XF86AudioMute 1 0 1000 /usr/bin/mpc volume 0
Then restart gdm by executing /etc/init.d/gdm restart
Voila, your multimedia keys should work in GDM!!
- Login to post comments
Say it isn't so
Sam Morar — Mon, 30/06/2008 - 14:57

Every two weeks, for the past 4 years, the award winning LugRadio team put out a podcast talking about the latest linux / oss news and having very colourful discussions about their very polarised views on all things linux.
They have even had live weekend events, which, at the time I wished I was able to attend, and am now very sad that I didn't.
Guys, the OSS community is going to miss you.












Recent comments
12 hours 17 min ago
16 hours 20 min ago
20 hours 17 min ago
1 week 3 days ago
1 week 4 days ago
1 week 6 days ago
2 weeks 58 min ago
2 weeks 1 hour ago
2 weeks 4 days ago
2 weeks 4 days ago