<<

KNOW-HOW ReMoot

Activating your multimedia keys with ReMoot

PLAYBACK www.sxc.hu

If your laptop multimedia keys aren’t working in , the fix could be root 0x4c, subw 0x0, time U 1349394, (173,-13), U easier than you think. We’ll show you how to manage multimedia appli- root:(922,5), state 0x0, keycode 176 U cations from the keyboard using ReMoot. BY FEDERICO KEREKI (keysym 0x0, NoSymbol), U same_screen YES, rom this article, you will learn how to activate keyboard and laptop XLookupString gives 0 bytes: how to make Linux (with KDE) multimedia keys with ReMoot. XFilterEvent returns: False Frecognize special-function keys and how to make them function with all The Solution The important feature of this output is your favorite multimedia applications. The first is getting the keys to work. the number after “keycode,” which is Many contemporary desktop and lap- If you want to go to the effort, you can the desired scancode value; in this case, top keyboards include multimedia keys define your own keyboard map and use the “Volume Up” key generates a 176. (for “Play,” “Mute,” “Volume Up,” and a tool such as Lineak [1] to configure For each multimedia key on your laptop, so on), but often these special keys don’t special keys, but the xmodmap program you will have to go through this process, work well with Linux. Recently, I de- offers a simpler approach. and don’t forget to use modifiers (Shift, cided it was high time to get the multi- For each key you want to use, first Control, Alt); you will discover that you media keys on my laptop to work. identify its scancode (what the key pro- have many more possibilities available duces when you press it). To identify the than you imagined. The Key Problem scancode, open a command window and I needed to solve two problems. The first key in xev. Table 1: ReMoot Commands was getting Linux to recognize the (po- You’ll see lots (I mean lots!) of mes- remoot play start playing tentially non-standard) keys; the second sages in the command window. Press remoot playpause pause if playing; restart was getting each key to perform the nec- any of the multimedia keys and watch if paused essary multimedia function. Fortunately, the output. In my case, when I press the remoot stop stop playback KDE lets you easily associate keyboard “Volume Up” key I get: remoot next change to next track actions with commands, and a tool remoot prev change to previous track called ReMoot provides the necessary KeyRelease event, serial 31, U remoot mute mutes/ unmutes sound command set for accessing multimedia synthetic NO, window U remoot volup volume up a notch applications. In this article, I describe 0x2a00001, remoot voldown volume down a notch

56 ISSUE 85 DECEMBER 2007 ReMoot KNOW-HOW

Figure 1: Defining a new group for the multimedia keys. Figure 2: Creating a new action for the “Next Song” key.

Other behaviors might be noted. For that match your keys. (By the way, the have to modify this file to suit your own example, I found out that the “Bright- path for this file can vary among distri- machine: ness Up” and “Brightness Down” keys butions; if you cannot find it, use the weren’t recognized by xev, so I couldn’t find / -name XkeysymDB command to keycode 144 = XF86AudioPrev configure them with this technique. locate it.) keycode 153 = XF86AudioNext Now you know your keys, but Linux After getting all scancodes and decid- keycode 164 = XF86AudioStop still doesn’t, so you must assign a spe- ing the corresponding keycodes, I cre- keycode 174 = XF86AudioLowerVolume cific keycode to each key. To get the pos- ated in my home path a file named keycode 176 = XF86AudioRaiseVolume sible keycodes, examine the /usr/X11R6/ .Xmodmap (note the initial period; the lib/X11/XKeysymDB file near the bottom: period makes the file hidden) with the The format of the file is quite simple: you want the lines starting with XF86 following contents; of course, you will Each scancode has a line (those I found

DECEMBER 2007 ISSUE 85 57 KNOW-HOW ReMoot

Figure 3: Assigning a keyboard shortcut to “Next Song.” Figure 4: Specifying the remoot command for “Next Song.” with xev) relating it to a keycode. Finally, $ tar zxf remoot-0.9.tar.gz Actions option. Then, add a group with I added a short script, keys.sh (the name $ cd remoot-0.9/ the New Group command and name it doesn’t matter), under my home direc- $ chmod +x *moo* something like Multimedia Keys (see Fig- tory at ./Autostart/ with two lines: $ cp *moo* /usr/bin ure 1). Then, for each key: • add a new action to the group (see #!/bin/sh ReMoot comprises three related pack- Figure 2); xmodmap .Xmodmap ages: The ReMoot application itself; dae- • go to the General tab and fill the moot, which is used by ReMoot; and re- Action name field; It runs automatically whenever you start moot-remote, a graphical front-end. (A • set the Action type to Keyboard Short- a session; don’t forget to make this script separate package, Rewww00t, lets you cut -> Command/ URL (simple); executable with chmod +x keys.sh. use a Palm Pilot or Nokia N800 as a re- • go to the Keyboard Shortcut tab, click mote for ReMoot.) In this case, ReMoot on the button, and press the special Installing ReMoot is enough, but feel free to experiment key you want to link to this action – Now that Linux recognizes the multime- with the other tools; you’ll find more in- remember, you can also use the Shift, keys, you have to specify what you formation at the ReMoot wiki [3]. If you Control, and Alt modifiers if they work want the keys to do. For starters, go to don’t have Perl, use your favorite pack- with the key (see Figure 3); then the ReMoot website [2] and click on age manager to install it. • go to the Command/ URL Settings tab Source Download to get the latest version To see whether ReMoot is working, and type a ReMoot command you of ReMoot (v0.9). open any program and start play- want to execute whenever you press ReMoot is a Perl script. After the ing something ( and some jazz the key (e.g., for the “Volume Up” key, download (which should be over quickly works for me!), then try raising or lower- I specified the remoot volup com- for the 12KB file), go to the directory ing the volume with the commands mand) (see Figure 4). from which you downloaded it, su to shown in Table 1. remoot mute should If all goes well, these steps will map the root, and enter: immediately mute the sound; key in the multimedia keys to the necessary Re- same command again, and you will get Moot commands. Programs Supported the sound back. by ReMoot What’s great about ReMoot is that it Success amarok mpd supports many programs: If you are run- Getting the multimedia keys to work ning Amarok, then remoot playpause wasn’t as complicated as I first imag- will pause the playback, and if you are ined. KDE lets you associate commands noatun running , the result is the same. with keyboard actions, and ReMoot pytone As long as you are running a program makes it easy to control multimedia ap- bmp quark known to ReMoot (see the box “Pro- plications from the command line. ■ quodlibet grams Supported by ReMoot”), you will gmusicbrowser get consistent results; the multimedia INFO keys will work no matter what program [1] Lineak site: kaffeine totem you are using to listen or view media. http:// lineak. . net/ vlc Once you install ReMoot, all that’s left [2] The ReMoot website: kscd is to associate ReMoot commands with http:// www. kde-apps. org/ content/ the multimedia keys. If you use KDE, show. php/ ReMoot?content=63140 listen open the Control Center, and in the Re- [3] The ReMoot wiki site: moc gional & Accessibility tab, pick the Input http:// remoot. wiki. sourceforge. net/

58 ISSUE 85 DECEMBER 2007