Thursday, January 31, 2008

Multimedia/Internet Keyboards in GNU/Linux

As the resident Gnu/Linux guru, I sometimes help new users making transition from other OS’s.Over the years I’d ask anyone who installed Gnu/Linux about what hardware devices didn’t work for them,most often it is Multimedia/Internet keyboards. In this article, we’ll configure one such keyboard using Hotkeys.

Anthony Wong’s Hotkeys program is written to handle all those special keys provided by the multimedia/Internet keyboards and launch programs associated with them.Though there are numerous ways to configure these keyboards in Gnu/Linux,Hotkeys is easier to configure and its osd (on-screen display) is very simillar to those available on other OS’s.

You can visit Hotkeys site to download the latest version of the program as tarball or as a debian package.

The installation on Debian machine can be done using the apt-get.

$ apt-get install hotkeys

Configuration

Hotkeys starts a daemon process,usually started with xinit process,it uses a global configuration file /etc/hotkeys.conf and user configuration’s can be stored in $HOME/.hotkeysrc.

The hotkeys.conf configuration is well commentted, should not present any problems to new users.Its contains can be summed up as

1) Device Settings

Keyboard Type (kbd=”“) CD Drive (CDROM=”“)

The supported keyboards can be checked with ‘hotkeys -l’.

2) Key Behaviour

Tag = ‘command’ (Play = “xmms —play-pause”)

The complete list of tags can be found in /usr/share/doc/hotkeys/sample.xml file.The users can also create their own tags.

3) On-Screen Display Properties

Font (osd_font=”“) Color (osd_color=”“) Position (osd_position=”“)

#Sample /etc/hotkeys.conf file. #########################

  1. Global configuration for hotkeys # #########################

    1. These are the default values.
    2. A line starting with # is a comment.
    3. Specify the default keyboard (without the .def extension) so you
    4. don’t need to specify -t every time
      Kbd=hp5181
      CDROM=/dev/cdrom # use ‘none’ if don’t have a CDROM Drive PrevTrack=xmms —rew Play=xmms —play-pause Stop=xmms —stop Pause=xmms —pause NextTrack=xmms —fwd Rewind= WebBrowser=mozilla Email=mozilla -mail Calculator=xcalc FileManager=gmc MyComputer=gmc MyDocuments=gmc Favorites=gnome-moz-remote —remote=openBookmarks Transfer=gtp Record=grecord Shell=xterm -rv ScreenSaver=xscreensaver-command -activate NewsReader=mozilla -news Communities=mozilla -remote ‘openURL(http://slashdot.org)’ Search=mozilla -remote ‘openURL(http://google.com)’ Idea=mozilla -remote ‘openURL(http://sourceforge.net)’ Shopping=mozilla -remote ‘openURL(http://thinkgeek.com)’ Go=mozilla -remote ‘openURL(http://linux.com)’ Print=lpr Rotate=
      osd_font=-arphic-ar pl kaitim big5-bold-i-normal—0-250-0-0-c-0-*-*
    5. For the color, you can either use the strings in /etc/X11/rgb.txt,
    6. or use the RGB syntax #RRGGBB, e.g. ##A086FF
      osd_color=LawnGreen
      osd_timeout=3
    7. osd_position is either ‘top’ or ‘bottom’
      osd_position=bottom
      osd_offset=25

Configure Unsupported Multimedia/Internet keyboard

The Hotkeys program is still under development,you may not find your keyboard in the default list.To configure your keyboard, find out the keycodes of the all special keys on your keyboard.

Use the xev program to capture the keycodes and save it to file.Move your cursor to square on the xev window and press the special keys in a sequence.

$ xev 2>&1 >mykeys

Search the file for the keycodes.

$ grep ‘keycode’ mykeys | cut -d “ “ -f7,8 >mykeycodes

Check the file to see the keycodes.

$ cat mykeycodes
keycode 223
keycode 166
keycode 151
keycode 232
keycode 159
keycode 153
keycode 144
keycode 165
keycode 158
keycode 146
keycode 178
keycode 150
keycode 148
keycode 149
keycode 173
keycode 164
keycode 163
keycode 162
keycode 161
keycode 152
keycode 160
keycode 174
keycode 176
keycode 64

Hotkeys uses XML to define keycodes and their functionality.These are stored as ‘.def’ files in /usr/share/hotkeys directory.Let’s use the sample.xml file provided by the hotkeys to build a custom keyboard definition file.

$ cp /usr/share/doc/hotkeys/sample.xml /usr/share/hotkeys/custom.def

The hotkeys support various pre-defined ‘tags’ like Sleep, Search, Shopping andvarious CD/DVD player controls
(See /usr/share/doc/hotkeys/sample.xml). Each ‘tag’ has a behaviour assigned, Sleep uses APM to turn your computer into hibrnatio.Many other special function keys can also be configured.

For example the half-moon key on my keyboard is configured using ‘Sleep’ tag.

<Sleep keycode=“223”/>

And un-defined Shortcut key is set with.

<code>
<userdef keycode="232" command="xterm">Xterm</userdef>
</code>

Here is how the custom.def appears with the above examples.

<?xml version="1.0"?>
 <definition>
 <config model="My custom keyboard">
 <!-- Support Tags functions -->  
 <!-- half-moon key -->

 <Sleep  keycode="223"/> 
 <!-- User define functions -->
<userdef keycode="232" command="xterm">Xterm</userdef>
 </config>

<contributor>
<name>your-name</name>
<email>your-email</email>
 </contributor>
<definition>

Now test the custom.def by using it as your keyboard type.

$ hotkeys -t custom

A lot more keys can be set using the same custom.def file, a little effort pays off really well.If you have configured a new Multimedia/Internet keyboard using hotkeys, do take time to send it project developers, it would help many other users with same keyboards.

Web Resources

Hotkeys Help Forum

Hotkeys Project

Website file Uploads With lftp

Keeping your website updated is tedious job,especially when you have lot of files,which you edit quite often.And having to do the such work over ftp makes it worse.

In this article we’ll use a command line based file transfer program lftp(http://lftp.yar.ru/) written by Alexander .V. Lukyanov to do website file uploads.Though there are many other ftp clients,lftp is simpler to use,feature rich,can upload several files in parallel and it comes bundled up with most Gnu/Linux distributions. lftp is a powerful tool, its built-in mirror facility is suitable for keeping your website updated and secure by replicating permissions on the uploaded files.It checks for modified files by checking the file sizes and file modification times.

Using lftp on Command Line

Now you have a local directory on your computer where you keep all your website files(/home/joe/site_files).Let upload these files to your remote webserver directory using lftp on command line.First lets connect to your hosting service providers webserver with username and password.

$ lftp -u username ftp.hostingcompany.net
Password:

The lftp program will prompt for the password,type your secret password and you will be logged in.

Now issue the ‘lcd’ command to change directory to local directory where your all website files reside.

lftp username@ftp.hostingcompany.net:~> lcd /home/joe/site_files
lcd ok, local cwd=/home/joe/site_files

Now use the lftp mirror built-in’s reverse option (-R) of lftp to
upload all files local files into remote directory on the webserver.

lftp username@ftp.hostingcompany.net:~> mirror -R
Total: 12 directories, 36 files, 0 symlinks
Modified: 13 files, 0 symlinks

You can use “ mirror -R —only-newer “ command if you want only new files to uploaded.Once the upload is finished lftp will print out a report.Now you can end the connection by typing quit.

lftp username@ftp.hostingcompany.net:~> quit

Running lftp in a Script

Now that we have seen lftp in action.Let run all the commands from script instead.Luke Vanderfluit provides this nice little script.

lftp -u username,password ftp.hostingcompany.net <<EOF
cd / # remote directory on webserver
lcd /home/joe/site_files # local directory on your computer
mirror -R # Upload the files to remote directory
quit 0 # Drop the connection
EOF

Save all the commands in a file ‘upload_mysite’ and make it executable with ‘chmod +x upload_mysite’.Run the script by typing ‘./upload_mysite’ on the command line.As your username and password are stored it file,its a better not let anyone else to view it.Changing file permissions with ‘chmod go-rwx upload_mysite’.

Maintaining Multiple Websites

Running lftp from script is not a good idea if you have to maintain multiple sites.Instead you can use lftp’s ‘-f’ option.You can store settings of different websites into separate files.Suppose you have two websites site1 and site2.

The settings of the both the sites are stored in files ‘mysite1.lftp’ and ‘mysite2.lftp.

#####mysite1.lftp#######################
open ftp.myisp.net
user username password
lcd /usr/joe/site1_files
mirror -R
exit #########################################

#####mysite2.lftp#######################
open ftp.hostingcompany.com
user username password
lcd /usr/local_site_location
mirror -R
exit #########################################

To update site1, we will run lftp with ‘-f’ option.

$ lftp -f mysite1.lftp

And to update the next website.

$ lftp -f mysite2.lftp

Some other usefull features provided by ‘mirror’ built-in are the —parallel = N where in it will use N simultaneous connections to upload the files,this speeds up the upload considerably.If you want to exclude some files from being uploaded use (- x , – X) . And —delete to remove those files which are not present in local directory.

lftp can also be run as a cron job . Jani Reinikainen shows an interesting use of lftp to periodically mirroring a directory to a remote computer.

References

lftp manual page [http://lftp.yar.ru/lftp-man.html ]
lftp FAQ [http://lftp.yar.ru/FAQ ]
lftp Download page [http://lftp.yar.ru/get.html ]

GNU GPL version 3 released ( GPLv3 )

Fresh off the press, FSF has announced the release of GNU GPL version 3 released ( GPLv3 ). Here is full transcript of the announcement.

On Friday, June 29, at 12 noon (EDT), the Free Software Foundation will officially release the GNU GPL version 3. Please join us in celebration as we bring to a close eighteen months of public outreach and comment, in revision of the world’s most popular free software license.

Beyond the creation of an improved license, the process of drafting
version 3 has helped highlight vital issues for the community of free
software users. This is a moment to thank the thousands who participated by commenting on the license, and those that represented stakeholders through the GPLv3 committee process.

Now with the release of GPLv3, we will see new defenses extended to free software. These defenses will continue the long history of fighting all efforts to make free software proprietary.

Please join us as we stream live footage of Richard Stallman announcing GPLv3 from Noon (EDT) at www.fsf.org .

If you are in the Boston area you can also join us at the FSF offices
from 11:30am. Please let us know at >info@fsf.org< if you would like to
attend.


Peter T. Brown
Executive Director
Free Software Foundation
51 Franklin St. 5th Floor
Boston, MA 02110-1301 USA

Media contact for this event:
Brett Smith
617-542-5942
brett@fsf.org

About the FSF

The Free Software Foundation, founded in 1985, is dedicated to promoting computer users’ right to use, study, copy, modify, and redistribute computer programs. The FSF promotes the development and use of free (as in freedom) software—particularly the GNU operating system and its GNU/Linux variants—and free documentation for free software. The FSF also helps to spread awareness of the ethical and political issues of freedom in the use of software. Their Web site, located at www.fsf.org, is an important source of information about GNU/Linux. Donations to support their work can be made at http://donate.fsf.org . Their headquarters are in Boston, MA, USA.

Yahoo! India maps now offers Geocoding service

This mornings paper had Anand Parthasarathy covering the launch of Yahoo! India Maps and Yahoo! India Our City service, it offers map data of Indian cities, as well as Geocoding service for some of our cities (Ahmedabad, Bangalore, Bhopal, Bubhaneswar,Chandigarh, Chennai, Coimbatore, Delhi, Hyderabad, Jaipur, Kochi, Kolkata, Lucknow, Madurai, Mangalore, Mumbai, Mysore, Pune, Shimla, Thiruvananthapuram). Interestingly, Anand Parthasarathy lauds this achievement of India-based engineers instead of observing that offering such a service make a good business sense,

Just eight months after David Filo challenged his India-based engineers to come up with compelling Web applications for the world, the co-founder of the Web’s biggest portal, Yahoo, is back here to announce that two of them have been converted into working solutions. On Wednesday he lanuched Our City , a new Net resource which aggregates city specific information including, news, travel and tourism, weather, local business as well as user contributed blogs, photos and videos, for 20 Indian tier-1 and tier-2 towns.Content in the local language of the region is also linked. (http://in.ourcity.yahoo.com)

The site is linked to the other resource launched here: ‘India Maps’ consolidates satellite imagery and street maps for 170 Indian cities, 4,785 towns and over 2.20 lakh villages — arguably the largest India-specific cartographic service available on the Internet.

The map data have been provided in collaboration with the India-based CE Info Systems — and Yahoo spokespersons were quick to point out that all imagery was compliant with Indian government guidelines. Users could merge street maps with satellite pictures to create hybrid maps of their own. (http://in.maps.yahoo.com/)

Offering local business information merged with maps and search features does brings a tidy chunk of revenue for both provider and the business listed which is a very good thing. And (Yahoo!) members able to write reviews and comment on various services provided by the business add’s spice to the lot. Perhaps very soon we can expect other players (Google , MSN et al) to provide these services for Indian sub-continent.

BitTorrent "INFO : duplicate connection (id collision) " log messages

BitTorrent 4.20.x (and later) now logs all its messages and errors to its logs1. Here is one log message that mystified me.

[4.20.4 2006-09-01 04:10:39] INFO : duplicate connection (id collision)
[4.20.4 2006-09-01 04:10:48] INFO : duplicate connection (id collision)
[4.20.4 2006-09-01 04:10:52] INFO : duplicate connection (id collision)
[4.20.4 2006-09-01 04:11:03] INFO : duplicate connection (id

BitTorrrent Support provides a clear answer.

This message is harmless and can be ignored. It means that a request for data was sent to a peer you are already connected to. This is most common when there are few peers in the swarm for a given torrent. It does not affect your down or upload speed in any way.

1 Bittorrents logs file under UNIX, GNU/Linux operating systems are found under $HOME/.bittorrent/bittorrent-{cosole,curses}.log

Its party time for Debian camp

Debian Etch is now released. Its party time for Debian camp, the nearest party spot here in India seems to be BMS College in Bangalore. Party on and do remember to avoid spelling and grammar mistakes in your package(s) descriptions fellows.

Not all of us are native English langauge speakers but as Debian Developer’s Reference recommends in its 6 Best Packaging Practices section of the manual, we can remedy this with a little effort.

Be careful to avoid spelling and grammar mistakes. Ensure that you spell-check it. Both ispell and aspell have special modes for checking debian/control files:
ispell -d american -g debian/control
aspell -d en -D -c debian/control

As usual I expect magnanimous Debian users would lend a hand by reporting these bugs.

libTorrent / rTorrent 0.7.0 debian packages available

UPDATE: Never version of rTorrent made into Debian (Sid) since this entry was first posted.

Rakshasa’s libTorrent and rTorrent Unstable Release (0.7.0) Debian packages are now available

The Debian Sid/unstable rtorrent package is still stable release (0.6.4.x). A wishlist was posted and you can use this repo until the main debian packages are upgraded.

You can add this line to your sources.list and apt-get the packages.
deb http://repos.ghostbar.ath.cx/debian sid main

Or grab the packages directly from http://debian.ghostbar.ath.cx/

The adding of public keys for this repo however didn’t work. Perhaps am missing something here.

gpg --keyserver pgp.mit.edu --recv 0xCACAB118 && gpg --export 0xCACAB118 | sudo apt-key add -

[OR]

wget http://pub.ghostbar.ath.cx/pubkey-ghostbar.gpg sudo apt-key add pubkey-ghostbar.gpg

Popular Posts