[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Wednesday, 23 May 2001 | Author: William Lynch |
Published to: enhance_articles_desktops/General | Page: 1/1 - [Std View] |
Using Internet Keyboards with KDE
Dead keyboard? Want a new one anyway? Linux.com contributor William Lynch shows you the quickest way to get the new multimedia-enhanced keyboards working with Linux and your favorite applications.
|
One of the last fading PC legacies is the 101-key keyboard, which is ever so gradually being replaced by the multimedia-enhanced keyboards known as "Internet Keyboards". Most major vendors of console hardware have copied this keyboard, which was initially popularized by Microsoft. The primary function of the Internet keyboards is to provide extra buttons for one-touch Internet applications and multimedia controls.
While many of the Internet features might be seen as nothing more than fluff, some of these additional buttons can be quite useful. For example, the author enjoys having a one-touch "mute" button for XMMS when answering the telephone. Similarly, the author has grown fond of the convenience provided by one-touch access to Google, especially when no web browsers are currently open.
The extra buttons afforded Internet keyboards work just like additional keys on the keyboard. The kernel keyboard driver picks these up just the same as any other keys. While it's an involved process, one could modify xmodmap for these keyboards and assign special events to each of the Internet buttons. However, thanks to a package called HotKeys by Anthony Wong, configuration of these extra keys is much easier. HotKeys is simply a system daemon that intercepts the scancodes of the extended buttons on these Internet keyboards and maps them to an event or application.
Hotkeys is an easy to install and somewhat straightforward to configure software package. Aside from a few quirks it also seems remarkably stable. This section will detail how to install and configure the HotKeys package for KDE.
Identifying Supported Keyboards
The following output from hotkeys identifies which keyboards are supported by the HotKeys software package:
[fwl@laptop fwl]$ hotkeys -l Supported keyboards: (with corresponding options to --kbd-list or -l) acerwl - Acer Wireless Keyboard btc9000 - BTC 9000 itouch - Logitech Cordless iTouch/Internet/Cordless Desktop kb9963 - Compaq KB-9963 keyboard kbp8993 - Chicony KBP-8993 keyboard mck800 - Process MCK-800 msnatpro - Microsoft Natural Keyboard Pro msnet - Microsoft Internet Keyboard msnetpro - Microsoft Internet Pro Keyboard mx1998 - Memorex MX1998 Keyboard mx2500 - Memorex MX2500 Keyboard mx3000 - Memorex MX3000 Keyboard polypix - Polypix Keyboard sk2500 - Fujitsu/Logitech/Trust SK2500 Keyboard / Liteon-ak2500 sk2501a - Silitek SK5210A Keyboard sk2505 - SK-2505 Keyboard sk2800c - SK-2800C sk7100 - Silitek SK7100 Keyboard sk9925 - Silitek SK-9925 USB Keyboard [fwl@laptop fwl]$Note: The author is using the Logitech Internet Keyboard (itouch).
Package Dependencies
HotKeys requires only two packages to operate, libdb2 (maintained by Sleepycat Software and libxml ( the Gnome XML C Library). While libxml is available in binary form for most of the major Linux distributions, the source is also available. Since libxml is likely already installed on most Desktops, installation of this library will not be detailed here.
However, libdb2 needs to be of a specific version, 2.7.7, which may not be so widely available. The Debian distribution contains the original source code for this package which should compile on any distribution. The libdb2 package does not follow the standard installation method exactly, and it must be compiled in a specific manner. After unpacking and expanding the archive, perform the following steps:
[fwl@laptop db-2.7.7]$ ls LICENSE cxx/ db_printlog/ hash/ os/ README db/ db_recover/ hsearch/ os_win16/ btree/ db185/ db_stat/ include/ os_win32/ build_unix/ db_archive/ dbm/ java/ test/ build_vms/ db_checkpoint/ dist/ libdb_java/ txn/ build_win16/ db_deadlock/ docs/ lock/ xa/ build_win32/ db_dump/ examples/ log/ clib/ db_dump185/ examples_cxx/ mp/ common/ db_load/ examples_java@ mutex/ [fwl@laptop db-2.7.7]$ cd build_unix/ [fwl@laptop build_unix]$ ../dist/configure <output omitted> [fwl@laptop build_unix]$ make [fwl@laptop build_unix]$ su Password: <not echoed> [root@laptop build_unix]# make installOptional Features
HotKeys Installation
Now, the HotKeys package can be installed. Once the archive is unpacked, it follows the standard "configure, make, make install" procedure, except that the libdb2 installation directory may need to be specified with "--with-db2-inc=DIR" and "--with-db2-lib=DIR" where DIR is the directory where libdb2 has been installed.
To configure HotKeys for KDE, the following changes must be made to the /usr/local/etc/hotkeys.conf
file.
Kbd=itouch WebBrowser=kfmclient exec /home/fwl Email=kmail Search=kfmclient openURL http://www.google.comNote that the setting for Kbd may vary depending on the sort of keyboard in use, as showed in the previous section. The author uses the Logitech iTouch Internet Keyboard for this example. The other lines will open a file browser in the author's home directory, the kmail client and the Google search engine, respectively. The author's home directory needs to be explicitly specified because the HotKeys software lacks the ability to expand either the "~" or the "$HOME" shortcuts.
Next, it may be desirable to modify the keyboard definition for the keyboard in use. Be sure to backup the original keyboard configuration first. Then, edit /usr/local/share/hotkeys/Kbd.def
. The author made the following modifications to the itouch.def file:
<VolUp keycode="176" adj="1"/> <VolDown keycode="174" adj="1"/> <userdef keycode="230" command="konsole %i %m">Konsole</userdef>
The author modified the value of "adj" to "1" to allow for a finer grained control for the volume settings. Also, the "Go To URL" button, signified by a running man on the author's keyboard, is redefined to its new action in this section, rather that in the hotkeys.conf file. The author has configured this key to open a Konsole terminal window when pressed.
Unfortunately, Netscape does not lend itself towards HotKey's use as easily as Konqueror and KMail, partially due to bugs in KDE and partially due to the way the Navigator application functions. There are some workarounds for these shortcomings but integration is not as tight as it could be.
KDE Bug #21043
The KDE window manager kwin in KDE 2.1 has difficulties in communicating with the Netscape browser in the browser's "remote" mode. The "remote" mode allows a user to send input (such as a URL) to the currently running version of Netscape. In normal functionality, Netscape should be a able to identify the window ID of its current process, but kwin does not properly report this ID back to Netscape, resulting in the error message netscape: root window has no children on display :0.0. More information on this particular bug is available in the KDE bug report.
As a workaround, the ID of the current Netscape process needs to be sent to the Netscape command line when issuing remote requests. There is a diff to the /usr/bin/netscape
start script located in the KDE bug report but it's malformatted due to word wrapping and may not work if there are vendor modifications to the /usr/bin/netscape
script. As an alternative, one can create a quick wrapper script for the Netscape start script that will determine the window ID and pass it along to the Netscape remote command line. Copy the following script to /usr/bin/netscape-wrap.sh
and change the permissions to 755.
#!/bin/bash # A wrapper script for Netscape that passes the window ID to netscape # Written 05.15.01 by FWL ID=`xwininfo -root -all | grep Navigator | awk '{ print $1 }' | sort -r | head - # Use the ID if netscape is already running if [[ -n $ID ]]; then netscape -id $ID $@ else netscape fi exit 0Additionally, since there is no way to start a Netscape mail client session from the command line, at least not as specified in the Netscape documentation, there is no clean way to start Netscape Mail without starting a new message composition. As a result, if the "Mail" key in the Internet keyboard is used with a running Netscape session, a lock error will occur. Similarly, if a Netscape Mail session is already running and the "search" or "homepage" keys are pressed, the Netscape Mail client will exit and a new instance of the browser will be launched.
Netscape Configuration
To configure HotKeys for Netscape, only the /usr/local/etc/hotkeys.conf
file will need to be modified. After creating the /usr/local/netscape-wrap.sh
script as described above, make the following changes to the /usr/local/etc/hotkeys.conf
file:
WebBrowser=netscape-wrap.sh -remote 'openURL(http://www.yahoo.com)' Email=netscape -mail Search=netscape-wrap.sh -remote 'openURL(http://google.com)'Note:The URL specified in the "openURL" can be any URL, though it should probably be configured identically to the browser's start page.
While the added functionality of an Internet keyboard may not be sufficient to warrant its own purchase, these keyboards are handy enough to warrant purchase when replacing a failed keyboard. Clearly, with the help of Anthony Wong's HotKeys software, the KDE desktop can take advantage of these extra Internet and multimedia keys.
About the Author
William Lynch is a technology consultant for Crave Technology in Denver, CO. He spends every waking hour either in
front of a computer, practicing martial arts or watching hockey.