Archive for August, 2004

Sawfish functions for hotkeys and panel launchers

Monday, August 30th, 2004

One of my laptops has a series of hotkeys that send ACPI events, so I made a script to handle these events, which I later extended to be usable from the desktop or the panel too.

The various applications have different needs, and I use them in different ways. I only have one mail reader open, and its always in the same workspace, while I have many browser windows open in different workspaces. Others, like my calendar application, are used more like dialogs, where I show and hide them in the current workspace. Many require a close interaction with my window manager.

The core of the script looks like this:

case "$1" in
	case "$3" in
	    00000030) aumix -v+5;;
	    00000031) aumix -v-5;;
	    00000032) mute;;

	    00000040) xmms --rew & ;;
	    00000041) xmms --fwd & ;;
	    00000043) xmms --stop & ;;
	    00000045) xmms --play-pause & ;;

	    00000050) launch_mailer;;
	    00000051) launch_browser;;
	    00000052) launch_xchat;;
	    00000053) launch_calendar ;;

	    0000005c) show_hide_desktop ;;

    weblogs)	launch_web_logs;;
    xchat)	launch_xchat;;
    calendar)	launch_calendar;;
    mail)	launch_mailer;;
    vmware)	launch_vmware;;

When called by acpid the invokation is like this:

hotkey hotkey ATKD 00000052

and from a Gnome launcher in the panel or on the desktop:

hotkey calendar

Sound keys

The cd player keys and the volume controls are all software controlled, so if I don’t do anything, they won’t work. I usually play music with xmms and use aumix or setmixer for volume control, so they are the programs used in my scripts.

The volume up/down and play/rew/fwd/stop commands above are all self explanatory. Its all the in the manuals for xmms and aumix. There is no mute function in aumix, so I had to invent one, and it had to restore the correct volume after muting. After some attempts I came up with this:

function mute () {
    case "$(aumix -vq)" in
	"vol 0, 0")
	    (grep '^vol:' ~/.aumixrc-mute 2>/dev/null || echo 'vol:100:100:P') |
	    aumix -f /dev/stdin -L >/dev/null
            aumix -f ~/.aumixrc-mute -S -v0

It’ll mute and restore the volume at alternating invocations, perfect for a mute button.

Hide and show all windows

I think the button is intended to turn the wifi trasmitter on and off, but I use it for the desktop. The code is this:

function show_hide_desktop () {
    exec sawfish-client -- << EOF
(if (showing-desktop-p)

Only one application instance open

For some applications I only want one instance open at a given time. It can be my mail reader, vmware, my irc client or any other applications where several instances can be confusing or harmful.

I use the window manager to decide what to do, for example for the mail client:

function launch_mailer () {
    exec sawfish-client -- << EOF
(let ((window (or (get-window-by-name-re "^Mutt")
		  (get-window-by-name-re " - Ximian Evolution$")
		  (get-window-by-name-re "Mozilla Thunderbird$"))))
  (if window
      (display-window window)
    (select-workspace (cdr (workspace-limits )))
    (start-process nil "mozilla-thunderbird")

This function will check for an open mail reader, and if found switch to that window (changing workspace if necessary), and if not found, it will move to the last workspace and launch Mozilla Thunderbird.

Dialog-type application

This is a bit more complicated. I want my calendar to always be around when I need it, but not get in the way when I don’t need it.

I do this by always keeping it in the current workspace, but iconified. This function does it all:

function launch_calendar () {
    exec sawfish-client -- << EOF
(let ((window (or (get-window-by-name "Mozilla Sunbird")
                  (get-window-by-name "Mozilla Calendar"))))
  (if window
      (if (and (window-in-workspace-p window current-workspace)
	       (not (window-iconified-p window))
	       (eq (window-visibility window) 'unobscured))
	  (iconify-window window)
	(move-window-to-workspace window (car (window-workspaces window)) current-workspace)
	(display-window window))
    (start-process nil "sunbird")

If the calendar application is already started, it will check if it is in the current workspace and fully visible. If it is it is iconified, otherwise it is moved into the current workspace, de-iconified and brought to the front. If the calendar is not running, it is started.

The overall effect of this is that alternately display and hide the calendar, regardless of where it was left the last time. One click opens the calendar, the next click closes it.

None of this is quite rocket science, but they are some of those little things that makes day to day work move a bit swifter.

Problems with packages in Debian Testing

Monday, August 30th, 2004

There are currently some bugs in gcc related packages in Debian testing. They won’t install because they contain files owned by other packages too.

The errors are:

(Reading database ... 77290 files and directories currently installed.)
Preparing to replace gcc-3.3-base 1:3.3.4-6sarge1.1 (using .../gcc-3.3-base_1%3a3.3.4-6sarge1.2_i386.deb) ...
Unpacking replacement gcc-3.3-base ...
dpkg: error processing /var/cache/apt/archives/gcc-3.3-base_1%3a3.3.4-6sarge1.2_i386.deb (--unpack):
 trying to overwrite `/usr/share/doc/gcc-3.3-base/changelog.Debian.gz', which is also in package g++-3.3
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Preparing to replace libstdc++5 1:3.3.4-6sarge1.1 (using .../libstdc++5_1%3a3.3.4-6sarge1.2_i386.deb) ...
Unpacking replacement libstdc++5 ...
dpkg: error processing /var/cache/apt/archives/libstdc++5_1%3a3.3.4-6sarge1.2_i386.deb (--unpack):
 trying to overwrite `/usr/share/doc/libstdc++5/changelog.Debian.gz', which is also in package libstdc++5-3.3-dev
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:

The solution is very simple, once you have figured it out:

# dpkg -i --force-overwrite

It might affect other packages too, such as g++-3.3.

Nautilus: where do you want to go today?

Monday, August 23rd, 2004

Nautilus error messageThe new spatial nautilus is generally nice, but sometimes the mime type detection messes up.

This time I had an sftp: location open, where I have a symlink to another folder on the remote server. First the symlink is shown as a file of an unknown type, but when I double click on it to open the folder, I get an error message that, to say the least, is not very helpful.

What is exactly the correct extension for “Folder” and if I open the “Open with” menu, there nothing there.

What am I supposed to do?

Is there really no way I open the remote folder?

UPDATE: the bug report is here, so I’m not alone.

Tex font metricsUPDATE 2: I have another file, a Gnumeric file, which is regularly, but not always, recognised as a “TeX font metrics” file. I have no idea why, but it must be some pattern of bytes in its content that triggers this faulty identification. At least in this case I can open it via the “Open with” menu.

SWSUSP2 woes

Friday, August 20th, 2004

I have never really used the suspend options on my laptops but since it might be handy I tried to install Software Suspend 2 on my Asus M2N laptop.

SWSUSP2 was already supported in the kernel I recently installed, so it should be very easy, but no.

At boot I give the kernel the resume2=swap:/dev/hda5 which is my swap partition, and afterwards I can suspend using a hibernate script I downloaded here.

The problem is resuming. The resume process starts fine, restoring kernel and process data, but then freezes. There is no progress and no disk activity. In the end there is no other way out than to turn off power and boot with the noresume2 from the lilo prompt.

Its a bit of a bummer.

Looking around a bit didn’t help much. There seem to be some issues with DRI and possibly the agpgart and i830 kernel modules, but currently there is little I can do about that, since I have compiled them statically in the kernel.


Kernel 2.4.26 on the Soltek Qbic

Tuesday, August 17th, 2004

My kernel upgrade rampage has hit my home server to day. It was still running the kernel installed by the debian netinstall cdroms I had used, so the amount of available modules were rather scarce.

Most of the motherboard is based on the Intel ICH5 chipset, not that different than the Intel ICH4 chipset on my Asus M2N laptop, so much of the same should hold.

The kernel from the install cdrom didn’t have the i810_audio module and other related modules, so I installed Debian kernel-image-2.4.26-1-686. Everything is in there.

The machine uses grub for bootloader, and the kernel install just updated /boot/grub/menu.lst. I had to add acpi=on to the kernel lines to get ACPI enabled, otherwise it is just used during boot and then disabled.

On bootup the system tried to load all sorts of modules for stuff there wasn’t there, and it switched the console display to a higher resolution automatically, removing the possibility to scroll backwards with Shift-PgUp. As a consequence I removed both the hotplug and discover1 packaged that had made the first installation so simple. I can understand the use of such packages on many systems, and during first installes, but I prefer have more controll, so they went.

The system boots on the default initrd image, so I have made no changes to /etc/mkinitrd/modules.

I have to load the following modules through /etc/modules to get everything up and running:

# IDE detection
# Network card - Realtek RTL-8100B/8139D
# Intel ICH5 audio
# Supported ACPI modules
# USB controller and devices

I listen to internet radio on the computer, so I need sound configured. The ICH5 chipset is supported by the i810_audio module:

Intel 810 + AC97 Audio, version 0.24, 13:12:23 Jul 22 2004
PCI: Setting latency timer of device 00:1f.5 to 64
i810: Intel ICH5 found at IO 0xd400 and 0xd800, MEM 0xfe77b800 and 0xfe77b400, IRQ 17
i810: Intel ICH5 mmio at 0xde918800 and 0xde91a400
i810_audio: Primary codec has ID 2
i810_audio: Audio Controller supports 6 channels.
i810_audio: Defaulting to base 2 channel mode.
i810_audio: Resetting connection 0
i810_audio: Connection 0 with codec id 2
ac97_codec: AC97 Audio codec, id: ALG32 (ALC650)
i810_audio: AC'97 codec 2, new EID value = 0x05c7
i810_audio: AC'97 codec 2, DAC map configured, total channels = 6

Not everything is perfect, though, as some wav files sound weird, but mplayer plays windows media streams just fine and that is what I need.

ACPI support in the Soltek Qbic is rather limited. The button module controls the power button on the front only, and the thermal which gives a little information on the CPU.

ACPI: Power Button (FF) [PWRF]
ACPI: Processor [CPU1] (supports C1)
ACPI: Processor [CPU2] (supports C1)

It reports two CPUs! Not quite sure why, though. Something to investigate, I guess.

I don’t use this machine as a desktop computer, but playing a little around with a few modules, I get this:

# modprobe agpgart
Linux agpgart interface v0.99 (c) Jeff Hartmann
agpgart: Maximum main memory to use for agp memory: 409M
agpgart: Detected an Intel(R) 865G Chipset.
agpgart: Detected 32636K stolen memory.
agpgart: AGP aperture is 128M @ 0xf0000000
# modprobe i830
[drm] AGP 0.99 Aperture @ 0xf0000000 128MB
[drm] Initialized i830 1.3.2 20021108 on minor 0

I guess I’ll have to install X one day, just to try.

The complete boot log is here.

Intel PRO/Wireless 2100 mini-pci network card

Sunday, August 15th, 2004

The Asus M2N series of laptops have an integrated wireless network card. It is an Intel PRO/Wireless 2100 mini-pci card, which supports 802.11b at 11Mbps.

Initially I used an ndiswrapper type driver from, which I even paid for. I think it is the first time in many many years I have paid for a piece of software :-) It served me well, though, until I bought a 802.11g PCMCIA card.

There’s also a free ndiswrapper driver, which I haven’t tried.

Anyway, at some point in time Intel finally got around releasing a free native Linux driver for the PRO/Wireless 2100 card.

Besides following the instructions, I only had to make one change. My kernel doesn’t have some code to download firmware to the wifi card, so I had to edit the Makefile and uncomment the line


After a “make” and a “make install” I could load the driver with

modprobe ipw2100

which gave me this in my kernel log:

ieee80211_crypt: registered algorithm 'NULL'
ieee80211: loading with WEP enabled.
ipw2100: Intel(R) PRO/Wireless 2100 Network Driver, 0.51
ipw2100: Copyright(c) 2003-2004 Intel Corporation
ipw2100: Compiled with LEGACY FW load.
ipw2100: 01:05.0: Detected at mem: 0xFF7FF000-0xFF7FFFFF -> e01bc000, irq: 5
eth1: Using legacy firmware load.
eth1: Bound to 01:05.0

The driver automatically associates with the nearest access point, but in understands the commands of the wireless extensions, so it can be configured with iwconfig.

Getting a Debian kernel source tree for driver compilation

Sunday, August 15th, 2004

I have stumbled into this a few times, so I’d better write it down. Here is how you get a kernel source tree setup for compilation of drivers under Debian, assuming you’re using a Debian provided kernel package.

The information is shamelessly stolen from Martin List-Petersen:

Lets assume you’ve installed kernel-image-2.x.y-z-arch. It could be kernel-image-2.4.25-1-386 in which case x=4, y=25, z=1, arch=386. These numbers are need in the following.

The procedure is this:

Download the kernel source package:

apt-get install kernel-source-2.x.y

Unpack it:

cd /usr/src
tar -xjvf kernel-source-2.x.y.tar.bz2

Install the correct config-file:

cd kernel-source-2.x.y
cp /boot/config-2.x.y-z-arch .config

Generate dependencies and Makefiles:

make-kpkg --append-to-version "-z-arch" --revision 2.x.y-z --config old configure

Check build link:

rm -f /lib/modules/2.x.y-z-arch/build
ln -s /usr/src/kernel-source-2.x.y /lib/modules/2.x.y-z-arch/build

Most drivers will use the build link to find the correct kernel source tree for include files and Makefiles.

With this in place many drivers can be installed with a simple “make install”.

Linux 2.4.24 on an Asus M2400N laptop

Sunday, August 15th, 2004

My Asus M2400N has been running 2.4.22 since I bought it. It came preinstalled with Debian stable and Linux 2.4.22, patched for Asus ACPI, cpufreq and swsusp, and I left it there because it was too much work upgrading.

Recently I have noticed that display updates were noticably slower than before, and after a bit of research I found that XFree86 wanted a newer version of the i830 drm module than was included in Linux 2.4.22. After a while the pain was too much and I set out to upgrade my kernel.

First observation: a standard Debian kernel doesn’t boot on an Asus M2N unless ACPI is disabled, which isn’t very practical, so there was no other option than building my own kernel.

I first tried a 2.6.2 as described at the time on TuxMobil, but the resulting kernel never got further than the first ACPI line.

Later I tried a 2.6.7 kernel downloaded as debs from tuxmobil, again with little success.

In the end I settled for 2.4.24. Always at TuxMobil I found a config-file and a patch, so I downloaded the kernel sources, copied the config file to .config, patched everything and compiled a kernel image deb. Luckily Xtops.DE had given me a nice script to do the compilation, so I didn’t have to read up on make-kpkg and associated magic.

The kernel booted and everything was nice. Except it still didn’t have the correct version of i830.o. It wasn’t configured. I added CONFIG_AGP_I810=y and CONFIG_DRM_I830=y which solved the problem.

Instead of using the Alsa driver for the sound card, I configured CONFIG_SOUND_ICH=m which works perfectly with the integrated soundcard. The module to load is i810_audio.

Here is the final kernel config file which include a few other less relevant changes, mostly about which filesystems to use.

Most of the drivers are compiled directly into the kernel, including drivers for USB, PCMCIA, SpeedStep, ACPI, the RealTek RTL-8101 nic, agpgart and DRM.

I load a few as modules: NFS, sound, Wifi cards and parport.

Here’s the entire boot log.

HP Color LaserJet 2550L

Saturday, August 14th, 2004

HP Color LaserJet 2550LMy old laser printer died, and a few days later I stumbled over a good offer on a Hewland-Packard HP Color LaserJet 2550L, which I promptly bought. I got it for around $440 plus VAT.

It is a colour laser printer, with four separate toner cartridges mounted on a carousel, and as the sites says, it works perfectly with Linux. The printer supports both PCL6 and PostScript Level 2.

My model is the smallest of the series. It has USB 2.0 and parallel port interfaces and a 125 sheet paper tray that opens on the side of the printer. Other models have an internal HP JetDirect print server, and a extra 250 sheet paper tray that is mounted below the printer.

I downloaded HP’s PPD file for it to get all the available options. The PPD file has to be copied to /usr/share/cups/model/ and CUPS restarted before the printer is setup. Otherwise the model won’t appear in the list. The printer can also be configured as a “HP Color LaserJet PCL6″ printer, but that won’t give you all the possible printing options.

The first message CUPS displayed for the printer was “Starting ESP Ghostscript…” which baffled me a bit, since CUPS shouldn’t need to use ghostscript to process the print jobs, since it is a PostScript printer. The answer is that the internal PostScript engine in the printer is ghostscript, and that was the startup message that appeared.

I have only two grievances about this printer: its size and the noise. The printer is absolutely huge, requiring a space of at least 50x70cm with some extra space around it for cooling. It is not a printer you can put on a shelf. It requires a table. I was surprised at first, but the internal space in the printer is entirely taken up by the carousel with the four CMYK cartridges and the imaging drum, so it couldn’t really be much smaller.

The noise is a result of the cartridge carousel. There is an initial noisy phase for any print job, where the carousel is turned to bring the correct cartridge into place, and if it is a colour print job, the noise continues throughout the printing phase, as the printer changes between the four cartridges several times for each pages. There is an option in the PPD file for “Print Color as Gray”, and that will not only print faster, save wear and tear on the printer, but also lower the noise level quite a bit.
(more…) won’t print with CUPS anymore

Friday, August 13th, 2004

For some reason oowriter has decided it doesn’t want to print with CUPS anymore.

I had set up CUPS_SERVER to point to my home server, so I wouldn’t need to maintain a print setup on our laptops, and every other application prints nicely, but OOo.

In the print dialog the two CUPS printers are there, as expected, and when I print something, the progress dialog flashes briefly on the screen saying the job is being sent.

On the print server nothing ever arrives. There isn’t the slightest trace of any incoming print job.

The CUPS interface in Openoffice appears to be a Debian addition, so I have reported the bug there.

Currently, my workaround involves adding the line


to the start of /usr/lib/openoffice/program/soffice and not having a local CUPS server running.

If the environment variable CUPS_SERVER is set, OpenOffice will use that, otherwise if there is a CUPS server on the local computer, that will be used. By removing both options from OpenOffice, it will fall back to a generic PostScript printer interface. The only thing I have done there is to use oopadmin to set the correct command to send the job to my preferred printer.

I tried setting CUPS_SERVER to point to a non-existant host, but that caused OOo to hang during startup.

With the above workaround (I’m a bit loathe to call it a solution to the problem) I can print to my preferred printer, but I do not get any of the printer specific options, such as resolution, paper type or size, or whatever else the printer PPD might define.