Linux Tidbits

In no particular order or importance, this web page describes the various tidbits about Linux configuration (mostly for Fedora) which I had a heck of a time discovering, so I'm putting them all in one place for whatever it is worth...

Printer Margin Adjustments

The Linux printer setup dialog can install zillions of drivers from the printer database and print nice test pages to verify the driver works, but what if it doesn't work? What if the margins are way off (or even only a little off, but you need to print labels or forms with exact alginment)? I recently replaced my ancient HP LaserJet 6L (which died after many years of service) with a Brother HL-2040, and the default alignment was pretty awful with the recommended driver, so I tried to recall how to use the alignmargins script I once used many years ago, and rediscovered how confusing the instructions were. What follows is a much more verbose set of instructions that I know I'll need if I ever need to do this again, and hopefully they will help someone else as well.

Squirreled away in the obscure Open Printing Downloads web site are two files which are handy for tweaking your printer driver. The align.ps file is a postscript file that prints obscure looking gibberish your eyes will never be able to focus on, yet is useful for printer alignment. The alignmargins file is a perl script to help a little in applying the information you dig up using the align.ps printouts.

To use these files, put them both in the same directory, then run the alignmargins script as root. Every time you run the script (and you will run it a lot), it prints a copy of the align.ps file to the printer you select.

The first copy of the file you get will be almost totally useless, but you can read the instructions that print with the other gibberish and realize you have no idea what it says. In any case, after generating the printout, the script will ask you for a bunch of numbers. This first time through, you want to tell it 0 (zero) for all the values.

The script will edit the /etc/cups/ppd/printer-name.ppd file and add a section at the end to tweak the margin definitions. By filling in all zeroes for the margin tweaking values, you will be able to run the script again and get a printout showing exactly how the page winds up when all the margin settings are zeroed out. This is the printout you'll use to make some measurements.

For general paranoia, I always restart the cups system service after each run of the alignmargins script. This may be too much work, but I don't know if it will re-read the modified file unless I do that, and since I already have a root terminal running, it is simple enough to type /etc/init.d/cups restart

Anyway, now that you have the new printout based on all zero margins, it is time to get the most accurate ruler you can find and measure the H and V values. There are arrows labeled H and V on the printout, but they can't show the actual length you need to measure because your printer probably cannot print all the way to the physical edge of the paper. The values you want to measure are the length in inches from the physical edge of the paper to the vertical line on the left (H) and the physical bottom of the paper to the horizontal line on the bottom (V). These values will be close to one inch, but the exact difference is the important part to get as accurately as possible.

Once you have measured H and V, the instructions printed near the top of the page give the formulae for computing x and y from the H and V values (expressed in inches). In my case, the formulae are:

x = (1 - H) * 1200.0, y = (V - 1) * 600.0

The actual numbers probably depend on the resolution of the printer.

The alignmargins script has been sitting around waiting for input while you've been doing all this measuring and computing, so now you can provide some new numbers. The 1st 4 numbers the script asks for are ml, mb, mr, mt and we still don't know those, so type in 0 for them again, but you can provide it with the x and y values you just computed. If you measured accurately, you souldn't need to ever change x and y again, you will always feed the script those same values for x and y.

Now you can run alignmargins one more time. This time the printout generated will use the x and y values computed above, and the 4 truncated arrows drawn at the 4 corners of the printout should, if you extend the lines into the margin with a ruler and a pencil wind up with the point of the arrow hitting the physical corner of the page.

At this point, you are ready to read off the ml, mb, mr, mt value, which you get by examining the funny looking printout. There are numbers and tick marks along the edge of the inner rotated rectangle that appears on the page. The edges of the rectangle are clipped somewhere as it runs into the margin. The numbers you want to read off for each edge is the number where the clip happens. Once again, you want to read these as accurately as possible. Maybe get out a magnifying glass and a ruler to estimate the exact fractional position of the place where the margins were clipped. The number you pick off the left margin is ml, the bottom margin is mb, the right margin is mr and the top margin is mt.

Plug these new values in for the 1st 4 numbers, and the same values for x and y you computed above, and you should now have your .ppd file tweaked properly to print correctly.

Note that if you run alignmargins again, it will still look just as screwy as always. Nothing much happens to improve your eye's ability to focus on it, even with the printer fully adjusted. You can probably go back to the system printer config dialog and print a better looking test page now, with no clipping of anything around the edges, so that test may improve.

Hide Backup Disk

I've got a usb disk on my system I use for backups. I don't want it corrupted if I can help it, so I don't want it automounted in every gnome session (which gnome really wants to do).

With help from the folks on the hal mailing list I was able to construct the /etc/hal/fdi/policy/10-stop-hal-stop.fdi file which I use to recognize the volume label I happen to know is on this disk (the highly original label BACKUP :-) and tell hal to ignore that particular disk.

Now it only gets mounted when I want it to get mounted (in the cron script which does my nightly backups).

On a similar note, Fedora 8 changed the way hal is configured so that all fixed disk partitions get mounted by default (even partitions you deliberately left out of the /etc/fstab file because you didn't want people fooling with them). The /etc/hal/fdi/policy/10-no-fixed-drives.fdi can be installed to put back the policy removed in Fedora 8 and once again hide the fixed drives.

De-Gnome your computer

In the war between Gnome and KDE, I choose to despise them both. As a result, I spend most of my time in a simple and uncluttered X session and I use the fvwm window manager (which does what I tell it to, not what Gnome or KDE thinks is best for me).

Naturally, I still need to sometimes run apps from the Gnome or KDE world, so I can't completely ignore all of the cruft they require.

What follows are some choice excerpts from the ~/.xsession file I use to start my fvwm session.

killall -9 gnome-keyring-daemon

New in Fedora 8, the gnome-keyring-daemon is apparently started on login by gdm. I spent a little while trying to find out if there was a way to make it stop, then gave up, and I just kill it off as almost the first thing in my session startup.

if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]
then
   echo .xsession starting dbus
   eval `dbus-launch --sh-syntax --exit-with-session`
else
   echo dbus already started
fi

There is no way you can run anything of note these days without a dbus daemon already going. The above code gets dbus started if it isn't already running.

/usr/libexec/gnome-settings-daemon &
sleep 5
xrdb -all -remove
xrdb -load $HOME/.Xdefaults

It is an annoying fact that no GTK programs will render fonts readably unless they have access to the custom font settings you can establish by running gnome-appearance-properties (in Fedora 8) or gnome-font-properties (in earlier Fedora versions). Unfortunately they can't just read these settings from some file, apparently they must make contact with the gnome-settings-daemon to operate properly, so it is essential to get it started.

KDE apps aren't as picky about fonts. You can run kcontrol to bring up the KDE control center, and make font settings, and they will stick in KDE apps without needing to manually startup a session wide daemon first.

Unfortunately, the gnome-settings-daemon doesn't stop at providing font rendering info. It also does things like load annoying X resources into your server's resource database. This makes all old legacy Xt and Motif apps look like hell, so the above code gives the daemon a few seconds to get started, then flushes the crap it just loaded into the resource database and loads my own resources (which I actually want) instead.

The gnome-settings-daemon will also start the screen saver nonsense unless you run gconf-editor and disable the screen saver startup.

Another good thing to do in gconf-editor is disable the drawing of the desktop, otherwise whatever you do in your own startup script to set the background will be overwritten when gnome-settings-daemon starts up.

The pulseaudio disaster

No doubt pulseaudio comes with good intentions and may some day be useful. That day is not today. In no time after installing Fedora 8, I discovered endless audio problems. All these problems were solved with a couple of simple changes to the system:

yum erase alsa-plugins-pulseaudio

That essentially disables pulseaudio completely and make my sound work the way it always did.

unset SDL_AUDIODRIVER

Adding the above line to ~/.bashrc fixes a leftover problem by removing the hack that SDL programs needed to use pulseaudio. Since I'm not using pulseaudio, I no longer need the hack either.

Page last modified Mon Mar 17 21:42:23 2008