Older blog entries for hisham (starting at number 2)

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.


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!