LXF62.tut begin.pdf
From LXF Wiki
| Table of contents |
First Steps: Multimedia keyboards
HOW TO MAKE THOSE EXTRA KEYS WORK FOR YOU
First Steps with multimedia keyboards
Multimedia keyboards can be more than just a pretty, geeky toy. There is some genuine usefulness in there. Andy Channelle demonstrates one solution for the perennial problem of dead keys.
Anyone who has visited their local PC World to buy a keyboard will understand the difficulty involved in finding something that does not come complete with a large collection of extra keys, scroll wheels, odd ribbon controllers, gamepad keys and trackpads. The problem is that these multimedia extravaganzas typically ship with a driver disk for Windows XP and, occasionally with USB keyboards, for Mac OS X. Users of earlier versions of these operating systems only have access to the standard keys – at twice the cost of an ordinary keyboard. Fortunately Linux users have the abilities and passions of thousands of technically adept individuals to call on, and while getting these monsters to work out of the box isn’t always trivial, there should be no reason to suffer with dead keys. We’re going to look at a couple of different ways to get multimedia keyboards working adequately. Some are easier than others but it is worth covering the manual method in order to avoid alienating those users who may not have done their homework before splashing out on an ‘unsupported’ keyboard. It is worth noting that both Gnome and KDE have elements of LinEAK (see below) built into them, but this method provides the most complete access to your multimedia keyboard, especially if it’s not one of the popular ones. Don’t fret if you have bought some obscure thing. If a key sends a signal to the computer, the chances are that it can be configured to do something useful – even the usually redundant ‘Windows’ key usually ensconced between <Alt> and <Ctrl>. There are two systems for configuring keyboards: LinEAK (which stands for Linux Easy Access to Keyboards) and Hotkeys. Both work on the same principle of using a configuration file to define individual keys on the keyboard, and then do the same for the actions that need to be performed. Therefore, unusually for this series, we may stray into a little text editing. But this should only be fine tuning, because the application I’ve chosen to focus on has a pretty good graphical frontend. The first job is picking up the software. The latest version available at the project’s website (http://lineak.sourceforge.net/) is 0.8.1 and it is available in both binary and source form. It would be wise, however, to check to see if the application is available on your distribution. It’s not particularly heavy on dependencies, but this is always the easier route. There are two core componants and a number of option bits. The main parts are the daemon itself, called lineakd, and the configuration interface – this again is available in two flavours, lineakconfig (for general use) and klineakconfig (for KDE users). If you are using KDE, stick with the latter, because it has an extra element to the front end that makes setting up ‘unsupported’ keyboards a lot easier. Users who do venture into the configuration files won’t find anything too frightening. There are also a couple of plug-in packages (default and KDE) that offer predefined macros to do things such as evoke the screensaver, alter the volume of media playback, mute speakers and so on. I would advise installing everything apart from the ‘devel’ packages (which are aimed at developers).
The manual approach
I’m going to kick off by running through the process of manually setting up a supported keyboard first. The list of supported boards is already impressive (see boxout page 78) and is growing with every release. However, getting things working (even with the most popular keyboard in the world) is not as simple as plug and play. Once the application/daemon is installed, launch a terminal and type:
lineakd -l
This will simply list all of the currently supported keyboards. Find the one to be configured, and make a note of its ‘name’. For example, I have a Logitech Internet Navigator Keyboard (Special Edition) which has the name ‘LTINKSE’. The next command to type is:
lineakd -c LTINKSE
This will create a blank configuration file for the selected keyboard in /home/username/.lineak/lineak.config. Remember that an initial period (.) in front of a directory name signifies that it is hidden, so go into the view menu of Nautilus or Konqueror and make sure ‘hidden files’ is selected. A blank document is just a text file that contains a description of the extra keys contained on the keyboard, with empty sections waiting for commands to tell the daemon what each key should do. The format used is:
#specific keys keyname = “ “
In these things, anything prefixed with a hash key (#) is not executed by the system, so it can be used for commenting (leaving notes for yourself) on the configuration. The most timeconsuming task is filling in the various options for each key, but fortunately this is a one-time job – just remember to make a backup of the lineak.config file in case of disaster. And now a small digression: Linux, as an operating system, is built around the concept of a command line. Desktop environments such as KDE and Gnome simply sit atop this command line interface (CLI), and mouse events such as clicking an icon invoke a CLI command. Clicking on an icon for amaroK, for example, sends the system the command amarok, which starts the application. Some applications will be in the system’s ‘PATH’, meaning the OS knows where it is in the file system, and the user could just type its name in a terminal – for example konqueror – to launch it. Some, however, are not in the PATH and can only be invoked using a fully qualified path. For instance, my installation of Firefox is in ‘/home/andy/firefox/firefox’. Many Linux applications could be wholly controlled by the command line. For example, it is possible to launch Konqueror from the command line at a specific URL by typing:
konqueror “[uniform resource locator]”
where [uniform resource locator] is the URL of a website. The importance of these ideas will be more apparent when you realise that the empty spaces associated with each key merely contain a CLI instruction. My keyboard has a media button that, on WindowsXP, will launch the default media player. In the lineak.config file, I locate the media entry and add amarok between the quote marks. ‘amarok’ is in my path, so hitting the media key should launch amaroK. Of course it could just as easily be ‘juk’, ‘xmms’ or anything else. Now the interesting thing about this keyboard is that, in addition to a media key, it has a full complement of transport keys for controlling the media player. I’ve chosen amaroK for this tutorial not just because it is my favourite media player, but also because its CLI commands are really easy to use and fully documented at the project’s website. This is the section for the ‘media player’ element of the Logitech keyboard. The first part of each line is the key press, the second part the command that is sent.
Previous = “amarok --previous” Next = “amarok --next” Play|Pause = “amarok --play | amarok --pause” Stop = “amarok --stop” Media = “amarok” Mute = “EAK_MUTE” VolumeUp = “EAK_VOLUP” VolumeDown = “EAK_VOLDOWN”
There are a number of interesting things going on here, not least the third entry in the list, which does, in fact, contain two commands. The Logitech keyboard (perhaps inspired by the Gnome Human Interface Guidelines?) has grouped the ‘play’ and ‘pause’ controls on to one key. LinEAK calls this a ‘toggle key’. Toggle keys are ‘state dependent’, which means that if, in this case, amaroK is playing a song, a button press will send a pause command. But if the song is paused it will send a play command. The two elements of the line are separated by a ‘bar’ (|) symbol. The final three lines in this section consist of LinEAK commands, which will work regardless of which media player or desktop is being used. These are part of the LinEAK plug-in architecture, of which more later. Users simply need to insert the appropriate command for the job at hand.
- This page has a broken link to an image. Please fix it if you can, or find an alternative ‘lineak -l’ lists supported keyboards.
- This page has a broken link to an image. Please fix it if you can, or find an alternative The configuration file before changing keycode values.
- This page has a broken link to an image. Please fix it if you can, or find an alternative Klineakconfig makes the keycode discovery process easy.
- This page has a broken link to an image. Please fix it if you can, or find an alternative Once a keyboard is defined, it’s time to configure it.
Unsupported keyboards
Budgets and circumstance sometimes mean it is not possible to pick up one of the more popular keyboards, so to test LinEAK’s ability with more ‘generic’ fare, I picked up an iConcept multimedia keyboard for a tenner. This has 18 extra keys arrayed across the top of the unit as well as the usual Power, Sleep and Wakeup keys. There is no entry for this board in the LinEAK config files, so I will have to make one from scratch. This is a three-stage process. I need to first discover the keycodes sent by each press, then add these values to the lineakkb.def file, and then finally associate actions to each keypress. The first job can be accomplished in two ways. The first is to open a terminal and type xev. This outputs to the screen all the input data received via the mouse or keyboard. Pressing a key should output something like this:
KeyPress event, serial 27, synthetic NO, window 0x4000001, root 0x8f, subw 0x0, time 674063, (-288,776), root:(361,827), state 0x10, keycode 41 (keysym 0x66, f), same_screen YES, XLookupString gives 1 bytes: (66) “f” XmbLookupString gives 1 bytes: (66) “f” XFilterEvent returns: False
The important part here is keycode 41, which corresponds to the ‘f’ key. Hit each of the multimedia keys in turn and write down its name and the keycode it generates. Users of klineakconfig have it even easier. They can just right-click on the system tray icon for LinEAK (once it has been started) and select ‘Configure Keyboard’. The resulting dialog has a space that shows the keycodes of depressed keys. These will go into a new entry in the application’s keyboard definition file (/etc/lineakkb.def – you’ll need to edit this as root). The easiest way to get started here is to copy an existing entry and then paste it into the file – in the correct alphabetical space – and then adjust the key names and codes to fit your particular keyboard. And if you are feeling community minded, you could email the configuration to Mark Smulders, the original project owner, for inclusion in an upcoming version of the software. The email address is at the project’s website. The section of this file for my new keyboard looks like this:
# Contributed by Andy Channelle [Direct Access] brandname = “iConcept” modelname = “Direct Access” [KEYS] Back = 234 Forward = 233 Stop = 232 Refresh = 231 Search = 229 Favourites = 230 Web/Home = 178 Mail = 236 Media = 237 Mute = 160 Previous = 144 Play|Pause = 162 Stop = 164 Next = 153 VolumeDown = 174 VolumeUp = 176 MyComputer = 235 Calculator = 161 Power = 222 Sleep = 223 WakeUp = 227 [END KEYS] [END Direct Access] # end User Defined Keyboard iConcept Direct Access
- This page has a broken link to an image. Please fix it if you can, or find an alternative This ensures the daemon keeps running after the configuration application quits.
Supported Keyboards
LinEAK supports a number of common and not-so-common keyboards out of the box, including:
- Acer AirKey V (12 keys)
- BTC 5113RF MultiMedia
- BTC 9110
- Cherry Blue Line CyBo@rd
- Cherry Blue Line CyBo@rd (alternate option)
- Laptop/notebook Compaq (eg. Armada) Laptop Keyboard (4 keys)
- Propeller Voyager (KTEZ-1000)
- KeyTronic KTMPS202BI
- Logitech Access Keyboard
- Logitech Access
- Logitech Cordless Desktop
- Logitech Cordless Desktop Navigator Optical
- Logitech Cordless Desktop iTouch
- Logitech Internet Navigator Keyboard Special Edition
- Compaq Easy Access Keyboard (8 keys)
- Compaq Internet Keyboard (13 keys)
- Chicony KB-9810
- Dexxa Internet Keyboard (23 keys, model Y-SH16)
- Dexxa Wireless Desktop Keyboard (9 keys)
- Dell RT7D00
- DTK 006
- Genius MM Keyboard KWD-910 (16 keys)
- Hewlett-Packard SK-2501 MultiMedia Keyboard (13 keys)
- Hewlett-Packard SK-2505 Internet Keyboard (14 keys)
- IBM Rapid Access II
- Oretec MCK-800 MM/Internet keyboard
- Microsoft Internet Keyboard
- Microsoft Multimedia Keyboard
- Microsoft Multimedia Natural keyboard
- Memorex MX1998
- Symplon PaceBook (tablet PC)
- Trust 370B Easy Scroll Wireless Deskset (User Defined)
- Trust Wireless Keyboard Classic
- Yahoo! Internet Keyboard
The application is also a good choice for laptop users with seemingly dead media keys.
The final phase is to associate commands with each of these keys. Again there are two ways to do this. The most userfriendly way is to launch either ‘klineakconfig’ or ‘lineakconfig’, select the appropriate keyboard brand and model (yours should be in the list once the lineakkb.conf is saved), select each key and insert the command in the vacant slot. This has the advantage of highlighting the available ‘plugin’ options. It is also possible to edit the file directly, and to do this we need to once again open the lineak.config file in /home/ username/.lineak/ and add commands to the text. In the quest for an easy life, I will be using klineakconfig alongside KDE’s Kpanel menu editor to set up the board. The menu editing screen offers easy access to the commands needed to start various applications. For instance, we could easily set up the ‘Web/Home’ key to open Konqueror by adding the command konqueror to it. However, it is far more effective to use the command string attached to the ‘Home’ icon, which is kfmclient openProfile filemanagement, as this opens up the application in ‘file browser’ mode and in the right location. To change this button so it activate Konqueror in web mode, the command would be kfmclient openProfile webbrowsing. Here are a few other possible options. The ‘Search’ button could either lead to a web search or a local file search. To do the former, insert a command to your web browser followed by the search engine of choice in quotation marks. /home/andy/firefox/firefox “www.google.co.uk/linux” Hitting this button would launch Firefox and take me straight to the Linux specific page of Google’s search engine. For a local search in KDE the command would be: kfind %f This keyboard has a ‘Power’ button, which I’ll use to log out of a session. The command for this, in KDE, is: dcop kdesktop default logout In Gnome, you can add this: gnome-session-save --kill The ‘Mail’ button could start either a local mail client, in which case it is possible to cut and paste the needed command from the application’s launch icon ( kmail or evolution will do the job), or open a browser window at the home of a specific web mail service (firefox “gmail.google.com”). Remember that any command can be attached to any key – even fairly complex scripts. Experiment and have fun.
Gnome users have the easiest job here. Under the ‘Desktop Preferences’ menu, select ‘Sessions’ and go to the ‘Startup Programs’ tab. Hit the ‘Add’ button and type the command lineakd. Next time your restart the Gnome session, the daemon will be automatically loaded. KDE’s AutoStart function is hidden a little better, but it is there. First we right-click on the desktop and select ‘Create New > File > Link to application’. In the dialog box, give the link a name and then go to the ‘Application’ tab. In the ‘Command’ space, type lineakd and hit the ‘OK’ button. Open Konqueror and, once again, make sure it’s set to view hidden files. Now navigate to ‘/home/ username/.kde/Autostart’ and drag the previously made link into this folder. Now the lineak daemon will start automatically when KDE starts. It is possible to add the daemon to an rc.d script but this is by far the easiest way to autorun the application.
- This page has a broken link to an image. Please fix it if you can, or find an alternative A desktop link to the daemon is the first step in running it automatically.
The Windows key
Unless you’ve recently taken delivery of one of those swish new Cherry Linux keyboards, you will probably notice a key with a Windows symbol on it. Many distributions leave this untouched, but it makes sense – if you’re even a moderately fast typist – to move a lot of stuff on to the keyboard and reduce the risk of mouse induced repetitive strain injury. After all, those <Ctrl> + <c> and <v> moves become second nature quite quickly, and using <Win> + <Esc> is a lot easier to deal with than <Ctrl> + <Alt> + <Esc> when you need to kill a truculent window. In KDE, the resources to change these settings are available in the Control Centre under the ‘Regional and Accessibility’ tab. There are a number of options available here, including selecting from a range of ‘keyboard schemes’ such as Windows and Mac style, for users migrating from other platforms, and more elaborate schemes suitable for keyboards with three or four modifier keys. Once selected, all of the predefined schemes are editable, so add your own combinations if there is a need. You wil find most actions are not associated with a ‘keybinding’. To do this, select an Action, then click on the ‘short cut’ key at the bottom of the window and, when the dialog box appears, hit the appropriate keys. Remember, once you’ve finished working here, to save your configuration and give it a sensible name. In Gnome the same task can be achieved by going into the Desktop Preferences menu and selecting ‘Keyboard Shortcuts’. In keeping with the Gnome ethos, this is a much more sparse interface, but still does essentially the same job. Select an action and then input the associated keyboard short cut. Workaholics are well catered for in Gnome. Check out the keyboard break tool, which, at predefined intervals, will lock up the screen and keyboard for a short time in order to force overly-dedicated tappers to take a break. This too is under the Keyboard Shortcuts menu. LXF
- This page has a broken link to an image. Please fix it if you can, or find an alternative The Gnome keyboard configuration tool is blessedly simple.
The launch
Once the keyboard has been set up, the moment of truth arrives. Those using klineakconfig, should right-click the icon and select preferences. Ensure that ‘continue to run lineakd after quitting’ is selected and hit ‘Okay’. Then right-click the icon again and select ‘Start Lineakd’. This will launch the daemon and the keys should then be active. It is possible, of course, to keep refining the key commands until you have the perfect setup. Just remember to ‘apply’ the changes in either lineakconfig or klineakconfig. There is no need to restart the daemon. At the command line, the daemon can be run by typing: lineakd You can send the daemon to sleep with lineakd -z which just stops the OS from responding to keypresses, and ‘reawaken’ it with lineakd -k. Shutting down the daemon completely can be achieved with lineak -x. After making extensive manual changes to either of the configuration files, they will need to be reloaded with lineakd -r. The final job for LinEAK is making sure the daemon gets started on subsequent bootups so we don’t have to worry about manually starting it up every morning – this is about convenience after all!
LXF62 JANUARY 2005
LXF62.tut_begin 79
1/12/04 1:29:09 pm

