Nobody thought to check for this?

I finally got the check-as-you-type spell checker in Konqueror to work in Kubuntu. I probably would have fixed it sooner if I had stayed with my original plan and tried to migrate from Opera to Konqueror, but that didn't work out. Opera just has too many handy features and Konqueror is a little schizophrenic, owing to the fact that it tries to be both a web browser and a file manager. I love it as a file manager, but in terms of user interface, Konqueror can't compare to Opera as a web browser.

Anyway, all I had to do was install ispell and spell checking started working. It occurred to me because I knew that I needed to install aspell for Opera and I remembered having ispell in Slackware, so I figured I'd give it a try. It seems strange to me that they didn't think to include ispell in the default installation. After all, Konqueror is the only web browser by default and the inline spell checking is the single best feature it has, so it seems like a natural.

My first UserJS

As you've probably heard by now, my favorite browser is now free as in beer. The new version of Opera has had the banner ads and registration code removed and is now completely free of cost. I'm not sure what the reasoning behind this chage is, but I'm hoping it will increase Opera's market share. While Firefox has been getting huge amounts of buzz in the media, Opera has been languishing in relative obscurity, despite the fact that it is a superior program in many respects.

This news prompted me to do something I've been meaning to do for a long time: try out User JavaScript. If you haven't heard about it, User JavaScript is a feature of Opera 8 whereby you can write (or download) your own JavaScript files to be run Opera loads a page. If you have enough JavaScript know-how, this gives you almost unlimited power to change anything in the page. You can do everything from disabling annoying scripts a particular site tries to foist on you to adding your own custom content to a page.

My personal foray into this was a fairly simple content addition: add a link to the Google results page to go straight to the "cached text only" page. Call me paranoid, but I like to use the Google cache at work to make some of my surfing harder to track. The normal Google cache link attempts to load external references, so I often prefer to go straight to the text-only page. To do this, I wrote the following: if ( location.href.match(/^http://www.google.com/search/) ) { document.addEventListener( 'load', function (e) { var anchors = document.getElementsByTagName("a"); for(i=0; i<anchors.length; i++) { if (anchors[i].innerHTML == "Cached") { old_href = anchors[i].href; anchors[i].innerHTML = 'Cached</a> - <a href="'+ old_href+"&lr=&strip=1">Cached text only'; } } return true; }, false ); }

It still needs some work. For one thing, the idea of setting the innerHTML doesn't really work, as the dash in the middle ends up as part of the original link. However, it seems that insering an element into the [ac=Document Object Model]DOM[/ac] using JavaScript is only doable if you have a reference to the parent element, which I don't really know how to get. I guess I'll finally have to learn some real JavaScript.

Auto-run the good way

Well, I've finally gotten around to setting up some autorun functionality on my new Kubuntu desktop. If you follow this page regularly, you may recall that I did this with Slackware not too long ago, using a CD monitoring program and a udev script. However, now that I'm using Kubuntu, I can do it the right way.

Both D-BUS and HAL are part of a standard Ubuntu installation. I'll spare you the gory details, but the short version is that D-BUS is a libary/protocol for communicating between programs and HAL is a package that builds on this to create a standard format for listing hardware attached to the system. So, to make a long story short, you can run D-BUS and HAL daemons keep an updates list of what hardware are attached to the system (including individual CDs) and run another program to check when the list is changed. In GNOME, this is the GNOME Volume Manager, which prompts you for the desired action when it detects a new kind of media.

However, KDE doesn't have a volume manager. All it has is the media:/ IOSlave, which, to be perfectly frank, kinda sucks. It is totally non-configurable and pretty much just shows you a list of detected volumes and lets you open them. It's a little like "My Computer" in Windows, except less useful because it also shows you the mounted volumes that you don't care about. Apparently there's a proper volume manager coming in KDE 3.5, but that doesn't help me now.

My solution was to install ivman, which is a simple, a desktop-independent volume manager. It has no GUI, but is configured through several XML files, which it reads ever time a HAL event is detected. The XML files contain (possibly nested) rules that match HAL events, which allow you to execute an action only when the new device matches a specific set of events.

For my own system, I uncommented a couple of the example rules (for playing CDs and DVDs) and added one of my own. It looks like this:
<ivm:Match name="ivm.mountable" value="true">
<ivm:Option name="exec" value="$HOME/.ivman/autofsrun.sh '$hal.info.udi$'" />
</ivm:Match>

This rule matches pretty much anything that can be mounted and passes its HAL UDI to the autofsrun.sh script. This script, which you can download here in its initial form, uses the hal-get-property and udevinfo commands to retreive the name of the device and any symlinks to it. It then uses this information to search for the device in any sctive autofs map files. If the device is found, it gets the full path to the mount point and opens it in the file manager.

I plan to update this script a bit more. In particular, I'd like to add support for autofs program maps as well as a facility to automatically add desktop shortcuts to the autofs mount points. When and if I get around to that, I'll post it as a permanent article.