bloovis.com

03/16/2010 (4:16 am)

Replacing postfix and procmail with maildrop

Filed under: linux, linux mint, software, ubuntu ::

In the previous post, I wrote about how I solved a problem with fetchmail connecting to the postfix mail server. I also have postfix configured to transfer mail to procmail, which does some filtering for me using some rules I’ve written in ~/.procmailrc. But postfix+procmail is really overkill for a laptop or any other machine that is not going to be used as a mail server. Both of these programs can be replaced by maildrop, which delivers mail to your local mailbox or maildir, and which has a much more readable filtering language than procmail.

To get started with maildrop on Linux Mint or Ubuntu, install the maildrop and courier-authdaemon packages. It’s not strictly necessary, but for safety you can also disable postfix by doing this:

sudo service postfix stop
sudo chkconfig postfix off

Now you need to configure fetchmail to use maildrop. Simply add the following line to your ~.fetchmailrc:

mda "/usr/bin/maildrop"

The quotes aren’t necessary; I had them there because I had been experimenting with passing options to maildrop. The fetchmail man page recommends the options “-d %T”, but these aren’t required in this simple, single-user setup.

The next step is to write some mail filtering rules for maildrop. These go into the file ~/.mailfilter. The mailfilter man page describes the filtering language, but doesn’t give many examples. Here’s my ~/.mailfilter (with a bogus address replacing a real one):

DEFAULT="$HOME/Maildir/inbox"
LINUS="$HOME/Maildir/linus"
WOTD="$HOME/Maildir/wotd"

logfile "$HOME/maildrop.log"

if (/^From:.*torvalds@linux\.com/)
{
  to $LINUS
}

if (/^From:.*word@m-w\.com/)
{
  to $WOTD
}

to $DEFAULT

In this example, I’m filtering mail to three different maildir directories; all messages that aren’t caught by the two filters get delivered to the default maildir. If these directories didn’t already exist, they would need to be created with the maildirmake program. maildrop also allows delivering mail to mbox files, but I consider mbox evil and don’t use it any more.

Now whenever you run fetchmail, it should hand off the mail to maildrop for delivery. Check the log file, ~/maildrop.log, to make sure your filtering works as expected.

03/14/2010 (5:30 pm)

Fixing “connection refused” error in fetchmail on Ubuntu Jaunty / Linux Mint 7

Filed under: linux, linux mint, software, ubuntu ::

Today I installed fetchmail on Linux Mint 7, which also brought in postfix as the mail transfer agent. I’d used this combination on Linux Mint 6 with no problems, but on Mint 7 (which is based on Ubuntu Jaunty), fetchmail printed this error message:

fetchmail: connection to localhost:smtp [::1/25] failed: Connection refused.

The error was caused by fetchmail attempting to make an IPV6 connection to postfix on the local machine. Postfix refused the connection, so fetchmail then attempted an IPV4 connection, which was successful. The mail was delivered, but the error message was annoying.

As usual, I tried several solutions I found with Google, including an attempt to disable IPV6 on a system-wide basis. The thing that finally worked was to comment out the following line in /etc/hosts:

#::1 localhost ip6-localhost ip6-loopback

02/04/2010 (6:33 am)

The iPad is not a Kindle killer

Filed under: hardware, kindle, rants ::

The blogosphere is now full of ecstatic praise for the still-unavailable Apple iPad. Much of the commentary follows this pattern: a recitation of the known facts about the iPad (fast, multipurpose, “cool”), followed by the unwarranted conclusion that these facts make it a “Kindle killer”. This argument is similar to debates about religion, in which it is assumed that belief systems are a zero-sum game where there can be only one winner. But what is most noticeable about this argument is that it ignores some crucial facts. This isn’t too surprising, given the rich-geek myopia and herd mentality that pervades Silicon Valley culture. Here are the issues the geeks are ignoring:

Price: the cheapest iPad with 3G is $629. Add to this the $30/month data plan, and you have a two-year cost of $1349. Compare this to the cheapest Kindle, which is $259 and has no monthly charge for 3G access. Then consider the hints that Steve Jobs has given about raising eBook prices as a sop to the traditional publishers. Amazon won’t sit still, either. They’ve dropped the price on the Kindle at regular intervals, and are likely to do that again this year.

Battery life: the Kindle has a battery life of about two weeks when the 3G radio is turned off. I have confirmed this through personal use. This is a huge deal for me, especially when traveling. I don’t have to fret constantly about finding a place to recharge in outlet-starved airport terminals or train stations. It’s one of the key features of the Kindle that makes its use much closer to that of a real book than other electronic devices, including the iPad, which has a reported battery life of 10 hours.

Weight: the Kindle is much lighter than an iPad, which makes it more comfortable to use when reading in bed, or standing at a train station, or any other place where the device must be held in the hands. Even the larger Kindle DX is lighter than the iPad.

Simplicity: geeks with short attention spans and an addiction to email and Facebook won’t consider this a virtue, but the Kindle does one thing very well and offers no distractions. Again, this makes the device more like a real book. Admittedly, this factor may become less important as Amazon opens up the Kindle with their forthcoming developer’s kit.

Display: there is some debate about the readability of e-ink vs. LCDs, but the e-ink is definitely the winner in bright light, and I find it easier on the eyes than my laptop display. Amazon may switch to a different kind of display later this year, perhaps the Qualcomm Mirasol, but if it’s done right it should still offer the same benefits as e-ink: low power consumption and readability in sunlight.

02/03/2010 (1:38 pm)

Fixing the default shell in Ubuntu / Linux Mint

Filed under: linux, linux mint, ubuntu ::

Several years ago, the Ubuntu developers made a horrible decision to make dash the default shell instead of bash. This breaks numerous shell scripts, and I recently discovered it also broke one of my own Ruby scripts that depended on bash’s signal handling. The problem here was that when a TERM signal is sent to dash, it doesn’t kill off its child processes.

The problem isn’t fixed by making bash the login shell for a particular user, because some programs (such as Ruby) invoke /bin/sh, which is a symlink to /bin/dash. The fix for this problem is to make bash the default shell on a system-wide basis. The following command does that:

sudo dpkg-reconfigure dash

When you are asked whether to install dash as /bin/sh, answer No. This will update the symlink, among other things.

12/29/2009 (8:27 pm)

Improving fonts in Ubuntu/Linux Mint

Filed under: linux, linux mint, software, ubuntu ::

By default, Linux Mint 6 and 7 (and presumably, Ubuntu 8.10 and 9.04) come with a minimal set of somewhat ugly fonts. There are two things that can be done to improve the situation.

First, install the Microsoft TrueType fonts:

sudo aptitude install msttcorefonts

Then, if you are using an LCD monitor (e.g., a laptop), enable anti-aliasing (smoothing). On Linux Mint, start the Control Center from the main menu, then select Appearance. (On Ubuntu, I believe this is done using System > Preferences > Appearance.) Click the Font tab, and under Rendering, select Subpixel Smoothing.

You’ll see an immediate change in all fonts used in Gnome, but you may need to restart Firefox get it to see the new fonts and use smoothing.

10/24/2009 (10:46 am)

Viewing sheet music on a Kindle 2

Filed under: kindle, linux ::

The screen on the Kindle 2 is really too small for reading music at the piano, but it can be used as a replacement for the small pocket scores that are used for study. The trick is to convert the sheet music PDF file into a series of JPEG picture files. Here’s how to do that on Linux:

First, create a separate directory on your Linux machine for the sheet music score that you want to convert. This avoids clutter and accidents.

Then, convert the PDF file to one or more JPEG files using a command like this:

convert -geometry 600x800 op-118.pdf op-118.jpg

The convert program creates one JPEG file for each page in the PDF, using the second parameter as a filename template. In this example, it created the files op-118-0.jpg, op-118-1.jpg, etc. The -geometry option reduces the size of each picture to 600×800 pixels, which is the size of the Kindle 2 screen.

(The convert program is part of the ImageMagick suite; on Ubuntu you can install it using sudo aptitude install imagemagick.)

To avoid possible out-of-order sorting problems when there are more than 10 pages (op-118-2.jpg appearing after op-118-10.jpg), you can rename the first 10 files using this command:

rename 's/-([0-9])\.jpg/-0$1.jpg/' *.jpg

This ugly bit of regular expression magic renames op-118-0.jpg to op-118-00.jpg, op-118-1.jpg to op-118-01.jpg, etc.

Now you can copy the files to the Kindle. First, create a directory called pictures in the root of the mounted Kindle device. Then create a subdirectory of pictures with a recognizable name for your score. The Kindle will display this name in its home screen, so choose wisely. For this example, I created the directory pictures/brahms-op-118 on my Kindle.

Finally, copy the JPEG files to the directory you just created, unmount the device, and disconnect it.

The Kindle doesn’t show pictures by default. Press alt-Z on the home screen to force the Kindle to scan the pictures directory. It will now show each subdirectory of pictures as a separate “book”. When you navigate into such a book, the Kindle will display the series of pictures in that directory. The bottom of each picture may be chopped off, so press the F key to display it in full screen mode.

Look here for additional information on the Kindle picture viewer (scroll down to Kindle 2 Tip #4).

10/16/2009 (3:24 am)

Getting a refund on the Windows Tax

Filed under: windows ::

It’s nearly impossible to buy a PC without Windows unless you build it yourself. But one persistent person managed to get a refund from Dell, after only twelve emails back and forth and a lost day of work. That was easy!

10/13/2009 (9:21 am)

Automatic data loss on Windows

Filed under: software, windows ::

My employers have given me a Windows XP-64 machine, which sits 3000 miles away on the opposite coast. Operating it remotely using TightVNC isn’t anywhere near as fast or convenient as ssh, but at least it works.

The machine seemed to be working fine when I disconnected from it on Saturday night. When I reconnected on Sunday morning, my session with all of its terminal windows was gone, and the login screen was showing. Today, after poking around with the Event Log GUI (nothing so easy as sudo less /var/log/messages), I figured out what went wrong. A process called the Windows Update Agent started running at 3 AM Sunday morning, and after five minutes it rebooted the machine. So apparently Windows has an automatic data loss feature that is built in and enabled by default.

A Google search turned up this article, which says that the way to fix the automatic reboot is to edit the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\Auto Update and create an entry called NoAutoRebootWithLoggedOnUsers with the value 1. I also found this article, which shows how to use a GUI to disable the feature; this is the method I used, though I don’t know if it actually works. Either way, you have to wade through many levels of settings to find the right one, something that would be almost impossible without Google. And people think editing plain-text configuration files on Linux is hard!

10/13/2009 (4:12 am)

Bye bye Kindle

Filed under: kindle, kindle dx, piano ::

I’ve used the Kindle DX for a week, and it’s a lovely device despite the limitations I’ve been pushing against. I spent a few days vacationing in a town that has Sprint cell service, and can say that the Whispernet really is the killer feature that sets this device apart. I also tried it as a sheet music viewer at the piano, and it was fine for that, though I think it’s best used as a reminder tool for music that you already know; paper is still best for pieces that you’re actively learning.

But in my home town, the only available cell service is AT&T, making Whispernet useless here. So when I learned two days after the DX arrived that a version using the AT&T cell network was going to be available next year, I decided to send the DX back and wait for the AT&T version. Thank goodness for Amazon’s liberal 30-day trial period. I’ll be sorry to see it go, because I was looking forward to using it on an upcoming plane trip instead of lugging around dead tree books.

Perhaps by the time the AT&T DX (which will probably be called the “US and International” version) is out, some of the PDF limitations will have been removed, though I’m not counting on it.

10/08/2009 (2:27 am)

The Kindle and HTML links

Filed under: kindle, kindle dx ::

I had heard that the Kindle would recognize (and display correctly) HTML documents, if you renamed them to have a .txt filename suffix. My hope was that it would also recognize internal and external links. If this were the case, then it would be possible to write scripts that would help with the lack of organizational tools. These scripts could walk the documents directory tree and construct HTML files that represented that tree. It would also be possible to extract metadata (such as author, title, and keywords) and represent them appropriately in HTML.

But it turns out that this is not possible. The Kindle displays the formatting of HTML documents correctly, and even supports external links of type http:. But it does not support other types of links, such as file: or internal links.

These are limitations in the file viewer that the Kindle launches when you select an HTML (.txt) file from your home screen. (Such files show up in the “Books” section.) The experimental browser is slightly better, though. It recognizes file: links and allows you to select them, and will jump to the appropriate document. To get this to work, your HTML documents must have the extension .html, not .txt. Also, the external links in your document must have the prefix file:///mnt/us/. In other words, if you want to create a link to the file documents/test.html, the href attribute in the link must be file:///mnt/us/documents/test.html.

But there are some serious limitation in the browser’s support for links that make it unusable for my original purpose. First, the browser will not work if Whispernet is unavailable; in fact, it will hang the Kindle, forcing you to do a hard reset. Secondly, it does not allow links to other types of files besides HTML. I tried linking to a .azw file in the documents directory, and the browser complained that it could not open the file. The browser does recognize such a file when it is in an http: link, though, and will offer to download the file.

So it looks like there is no easy way to construct organizational tools using the Kindle’s HTML support.

« Previous PageNext Page »