Older blog entries for hisham (starting at number 4)

A silly little way to "watch" a semi-batch job

I'm running a compilation process that may take up to a few hours and that occasionally stops waiting for user input (yeah, I know, I'm working on it). I came up with a silly little way to let it run on background and not have to keep an eye on it... by keeping an ear on it. A little snippet of shell:

while true
do clear
   mv /tmp/last /tmp/old
   ls -l > /tmp/last
   if diff /tmp/old /tmp/last &> /dev/null
   then play /System/Links/Shared/sounds/KDE_Beep_ShortBeep.wav
   fi
   sleep 5
done

I ran this in a directory where the output of the compilation process is being logged, so the constant flow ensures ls -l is always changing... unless the compilation is stuck at a prompt. I used a little KDE beep to avoid disturbing my officemate (play is part of sox).

15 Mar 2006 (updated 15 Mar 2006 at 22:36 UTC) »
htop now on Subversion

After a few message exchanges with the sf.net bugtracking team, my development tree of htop is finally online on the Subversion repository. I never wanted to put it up there on CVS but now that sf.net supports SVN and I finally embraced the joys of revision control, I was motivated enough to do it.

Here's the web interface to the htop SVN repository. To fetch the sources, type:

svn checkout https://svn.sourceforge.net/svnroot/htop/trunk htop

(After checking out the sources, run sh autogen.sh to create the configure script and friends.)

A new release of htop is long overdue by now. It should follow shortly, I hope. I got a few new bug reports I need to nail down first.

BTW, this post reminds me of an old SVN-inspired parody I wrote a while ago. Check it out if you're a Rush fan. :-)

An intro to the software patents issue for non-programmers

I stumbled on an interesting article on software patents written by Richard Stallman. Nothing new, but it's written in a fairly non-technical language, so it's a good link to direct your non-programmer friends to. Found it through this pretty interesting blog on "intellectual property".

Once upon a time I published elsewhere (currently offline, sorry) a list of "cool ideas for software that I don't have the time or willingness to implement" (some of them I actually ended up implementing myself). Well, here's another one:

Incremental ldconfig

This one is not a full project, but rather adding a new option to an existing program, ldconfig (part of the Glibc package).

Motivation: when the libraries directory is not in the disk cache, ldconfig takes a long time. In GoboLinux, for instance, it's the longest step when installing a package after downloading and unpacking the tarball (sometimes even surpassing those, when the tarball is small enough). Ldconfig scans the entire libraries directory, opening each file. Here's an excerpt of strace:

lstat64("/System/Links/Libraries/libgettextsrc.so", {st_mode=S_IFLNK|0777, st_size=52, ...}) = 0 stat64("/System/Links/Libraries/libgettextsrc.so", {st_mode=S_IFREG|0755, st_size=191105, ...}) = 0 open("/System/Links/Libraries/libgettextsrc.so", O_RDONLY) = 4 fstat64(4, {st_mode=S_IFREG|0755, st_size=191105, ...}) = 0 old_mmap(NULL, 191105, PROT_READ, MAP_SHARED, 4, 0) = 0x40021000 munmap(0x40021000, 191105) = 0 close(4) = 0 lstat64("/System/Links/Libraries/libSDL_net.so", {st_mode=S_IFLNK|0777, st_size=51, ...}) = 0 stat64("/System/Links/Libraries/libSDL_net.so", {st_mode=S_IFREG|0755, st_size=15415, ...}) = 0 open("/System/Links/Libraries/libSDL_net.so", O_RDONLY) = 4 fstat64(4, {st_mode=S_IFREG|0755, st_size=15415, ...}) = 0 old_mmap(NULL, 15415, PROT_READ, MAP_SHARED, 4, 0) = 0x40021000 munmap(0x40021000, 15415) = 0 close(4) = 0

It repeats for all 2000+ files I have in my /System/Links/Libraries directory.

Instead of rescanning the entire directory, An incremental version of ldconfig would load the cache file, scan the files/directories given in the command line flags, add or replace the relevant entries in the in-memory copy of the cache file and then rewrite it to disk. Assuming this would be implemented as an "-i" flag, the package manager could then run something like

ldconfig -i /usr/lib/libalsa.*

when upgrading ALSA instead of going through every library.

Before writing this, I looked to see if something of this kind was already implemented somewhere. Didn't find it, but I did find others wishing for the same thing.

16 Feb 2006 (updated 16 Feb 2006 at 02:40 UTC) »
How to make any key become any other key in X

The vast majority of humanity does not use computers. From those who use computers, the vast majority does not use X (which is both a good and a bad thing). From those who use X, the vast majority will never have or want to tweak the settings of individual keys on their keyboard. But for those who do... here's how.

X has two nifty little programs: xev and xmodmap. The first tells you what is a key doing and the second allows you to tell it to do something else.

Say you want shift-4 to do pound signs instead of dollar signs. Run xev from a terminal. It will open a little window. Xev is an event dumper: whenever you do anything with that window (pass the mouse over it, move it around and, of course, press keys), xev will tell you what exactly the window is doing. For shift-4, xev reports:

KeyPress event, serial 30, synthetic NO, window 0x400001, root 0x60, subw 0x0, time 711922155, (165,-9), root:(171,43), state 0x11, keycode 13 (keysym 0x24, dollar), same_screen YES, XLookupString gives 1 bytes: (24) "$" XmbLookupString gives 1 bytes: (24) "$" XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x400001, root 0x60, subw 0x0, time 711922297, (165,-9), root:(171,43), state 0x11, keycode 13 (keysym 0x24, dollar), same_screen YES, XLookupString gives 1 bytes: (24) "$"

I put the key data in bold. With xmodmap, I can now do this:

xmodmap -e 'keycode 13 = 4 sterling'

And there you go: £10.25! The first entry, '4' stands for the standard key, the second entry, 'sterling' for the shifted key. Amusingly, I forgot to put the '4' the first time around and had to resort to the numeric keypad to get it back there when running the command again (so watch out not to bork your keyboard when messing with xmodmap).

To figure out the names of the keys, take a look at include/X11/keysymdef.h in your X distribution. Or just use the Tab key if you're a zsh user like me.

I configured my right Alt key (keycode 113) to be "Mode_switch". This is the magic key that allows you to give more than 2 signs to a key. Doing this:

xmodmap -e 'keycode 13 = 4 dollar sterling yen'

I can now type: £ 1.00 = US$ 1.74 = ¥ 203.81 = R$ 3,72. (Actually I don't know whether the UK and Japan use dots or commas.)

I used xmodmap extensively to make an internationalized version of Dvorak for my own use (standard Dvorak + accents on strategic Mode_shift positions). Xmodmap tricks are also great for disabling the Caps Lock key, or to turn it into an extra Control key (one can never have too many of those).

[Ok, and now I promise I'll get back to working on my dissertation proposal!]

24 Jan 2006 (updated 24 Jan 2006 at 14:25 UTC) »

Hi there! I stumbled on this place a number of times over the years but I never got atround to create an account... but now I think it's about time.

Always nice to keep in touch with the free software community; hope to keep you posted about the projects I'm involved with (mainly GoboLinux and htop) and learn about what you people are up to.

Cheers!

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!