Chapter 3. Multimedia keys

Table of Contents

play
stop
forward
rewind

I've got a Logitech Internet Keyboard on my SuSE PC, and there are some multimedia keys like play, forward and so.

First I had to activate them by using my own Xmodmap

Example 3.1. /home/cweiske/.Xmodmap for the Logitech Internet Keyboard

keycode 160 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 162 = XF86AudioPlay
keycode 164 = XF86AudioStop
keycode 144 = XF86AudioPrev
keycode 153 = XF86AudioNext
keycode 236 = XF86Mail
keycode 229 = XF86Search
keycode 230 = XF86Go
keycode 178 = XF86HomePage
keycode 223 = XF86Sleep

Now the keys were automatically loaded on my SuSE system, but not on my gentoo; I had to find a way that the modmap is started when X is started. I changed the file $KDEDIR/share/config/kdm/Xsession and inserted the following code after the shebang (#!/bin/sh):

Example 3.2. $KDEDIR/share/config/kdm/Xsession

...
if [ -f $HOME/.Xmodmap ]; then
    /usr/X11R6/bin/xmodmap $HOME/.Xmodmap
fi
...

Now the Xmodmap should be loaded everytime you log into your KDE.

As I use several programs to play videos, music and TV I made some scripts which control every program - but not at the same time, only the one which is active. All of the scripts are activated by the KHotkeys daemon from KDE.

play

Example 3.3. /home/cweiske/scripts/play

#!/bin/sh
#check if kaffeine is running
kaffeine=`dcop | grep kaffeine -c`
if [ $kaffeine = '1' ]; then
    #kaffeine is running, control it
    dcop kaffeine Kaffeine togglePlayPause
elif [ `pgrep tvtime` ]
then
    #tvtime
    tvtime-command TOGGLE_PAUSE
    tvtime-command TOGGLE_MUTE
else
    #no kaffeine, no tvtime
    #xmms play-pause
   xmms -t
fi

This code does the following: - if Kaffeine (KDE video player) is running, a play/pause signal is sent to it - if tvtime (TV application) is running (but not kaffeine), the picture is paused and the sound is muted in tvtime - if none of the above, XMMS shall play/pause.