bloovis.com

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/04/2009 (3:03 am)

Using an Epson Perfection V30 scanner in Linux

Filed under: linux, linux mint, ubuntu ::

When I was shopping for an inexpensive flatbed scanner, it was not always easy to figure out which ones would work in Linux. Many manufacturers use proprietary protocols in their products and generally ignore Linux. I bought an Epson V30 because it was cheap and because there are drivers available for download here. The drivers work on Linux Mint 6 (Ubuntu 8.10) or later, and on several other Linux variants. Unfortunately source code is not provided, so if you don’t have one of the popular distributions, you may be out of luck.

One of the things I wanted to do with the V30 was scan books and convert them to plain text (for personal use; I’m not a pirate). For this I used Tesseract, an open-source OCR package that was developed at HP in the 90s and is now being maintained by Google. (The package name in Mint / Ubuntu is “tesseract-ocr”.) This program has a slightly funky command line interface (only reads TIFF files; the input filename must end in “.tif”, not “.tiff” or anything else; the output filename must be given without an extension). But it works surprisingly well, and I was able to integrate it into xsane (a decent scan utility) by writing a wrapper shell script that makes its command line interface identical to the gocr program that xsane uses by default.

I experimented with varying the dots per inch when scanning a book, to see how that affected tesseract’s error rate. At 100 DPI, the output was gibberish. At 200 DPI, the output was nearly perfect, with only about four errors per page that needed to be corrected manually. At 300 DPI, the output was marginally better, with perhaps one or two fewer errors per page. As I mentioned, this seems remarkably good. After I scan a page and convert it to text, I’ll fix the obvious errors and remove any end-of-line hyphenation. Then I’ll run aspell on the text to find additional errors. The most common errors are missing spaces (”ofthe”) and “l” change to “1″.

Another approach to OCR is to buy the commercial, closed-source Vuescan. I owned a copy six years ago, when xsane was not quite up to snuff, and it worked beautifully. I’m trying the latest trial version, and it has a number of improvements. The most interesting new feature is the integration of tesseract-ocr. This saves several steps in the process of scanning text, and the speed-up may be worth the price.

06/11/2009 (1:05 pm)

Printing USPS Click-N-Ship labels in Firefox on Linux

Filed under: linux, software ::

I use the USPS web site to print shipping labels, and each time I upgrade to a new version of Firefox or LInux, I always run into the same problem: printing labels doesn’t work. As soon as I click the Pay and Print button, Firefox goes into some kind of infinite loop reading data from the USPS web site, and the PDF file containing the label is never seen.

The fix is to change how PDFs are handled by Firefox so that Adobe Reader is started as a separate process, rather than as an embedded window inside Firefox. Here’s how to do that in version 3.0 of Firefox:

Open Edit / Preferences, then click on the Applications tab. Enter PDF in the search box; a single entry with Content Type of “PDF document” should be displayed. Change the Action to “Use Adobe Reader”; make sure you don’t select “Use Adobe Reader (in Firefox)” accidentally.

02/14/2009 (5:56 am)

Power-off fix for Linux Mint 6 / Ubuntu 8.10

Filed under: linux, linux mint, ubuntu ::

The older computer on which I installed Linux Mint recently wouldn’t power off properly after a shutdown. This used to work on Mandrake 10.2. Apparently the problem is due to the newer Linux kernels requiring ACPI by default for power management, and this machine’s BIOS doesn’t seem to provide a compatible ACPI implementation.

After the usual slogging through Google search results and numerous experiments, the fix was extremely simple: add the following line to /etc/modules:

apm power_off=1

Several forum postings I found with Google suggested other solutions, including boot parameters and commenting out lines in various configuration files, but these weren’t necessary on this machine (which uses a Biostar M7VKQ motherboard).

02/09/2009 (9:46 pm)

Fixing screen resolution in Linux Mint 6 / Ubuntu 8.10

Filed under: linux, linux mint, ubuntu ::

I installed Linux Mint on my parents’ computer today, replacing Mandrake 10.2. (Yes, grandparents can use Linux.) This older computer has a motherboard with a built-in VGA adapter by Trident, connected to an ancient CRT display with a maximum resolution of 1024×768. But for some reason, Linux Mint set the resolution to 800×600, and the Screen Resolution tool in the Control Center would not allow it to be set higher.

After some Google searching, I came across some Ubuntu forum posts that suggested various fixes that did not work, or which required programs that were not available on the live CD. Finally, the thing that worked was quite simple: I edited /etc/X11/xorg.conf, and in the “Monitor” section added the following line:

HorizSync 28 - 60

After restarting X with Ctrl-Alt-Backspace and logging back in, the Screen Resolution tool now showed a number of newly available screen resolutions, including the desired 1024×768. Apparently, the Trident display driver (or some other piece of X) wasn’t able to detect the monitor capabilities automatically (perhaps due to the monitor’s extreme antiquity), and the new line in xorg.conf provided just enough of the required information.

01/04/2009 (8:29 pm)

Batch resizing images in Linux Mint / Ubuntu

Filed under: linux, linux mint, ubuntu ::

I recently switched my two main laptops to Linux Mint. I’ve been running KDE-based Linux distributions for years, and this is my first experiment with Gnome. Right away, I discovered that there are apparently no Gnome applications that can resize multiple images as easily as the premier KDE photo application, Digikam. GThumb, an otherwise decent photo viewer, has a memory leak bug in its “scale images” feature that quickly brings the system to its knees; this bug was supposedly fixed long ago but has resurfaced in Ubuntu 8.10. The batch plugin for Gimp looks like it ought to work, but almost always fails with various errors.

At this point, I resorted to using the ImageMagick “convert” command-line tool to resize images, which works fine, but is a little inconvenient, because it’s not possible to visually select the images for resizing.

I then came across a variant on this idea that works with Nautilus, the Gnome file manager. I took the script from this blog posting, then hacked it up a little to eliminate the renaming steps. This works quite well. You select one or more images in Nautilus, right click on them and select Scripts / Resize_Images. The script pops up a dialog asking for a maximum resolution. Then it starts to resize the images, placing them in a new subdirectory resized_to_NNN, where NNN is the new image size. It displays a progress dialog during the process.

I’ve placed a copy of my hacked version of the script here. After downloading it, move it to the ~/.gnome2/nautilus-scripts directory and make it executable using chmod +x Resize_images.

There is one serious problem with this script: the dialog boxes it pops up almost always end up being hidden behind other windows. This is a known bug with Zenity, the application used by the script to display dialogs. The problem and workaround are described in this bug report.

10/25/2008 (11:27 am)

Creating an encrypted directory on Linux

Filed under: linux, software, suse ::

There are a number of ways to encrypt a file system on Linux, and the choices of strategies (single directory or entire partition) and tools (dm-crypt, LUKS, losetup) can be bewildering. I didn’t have a spare partition to play with, and I wanted to use what seemed to be regarded as the preferred tool (LUKS). So here’s how I created an small encrypted directory on SLED (SUSE Linux Enterprise Desktop 10 SP2). (I cobbled together this information from Encrypted Root File System with SUSE and File System Encryption.) I performed all of these steps as root in root’s home directory.

First I created a 100 MB file and filled it with random data:

dd if=/dev/zero of=private bs=100M count=1
shred -n 1 -v private

I created a loopback device that referred to this file:

losetup /dev/loop0 private

I loaded various kernel modules required for encryption:

modprobe dm-mod
modprobe dm-crypt
modprobe aes
modprobe sha256
modprobe sha1

I created an encrypted mapping for the device:

cryptsetup -v --key-size 256 luksFormat /dev/loop0

At the prompt, I entered a passphrase (which would be used later to open the device). I verified that the encryption setup had succeeded using:

cryptsetup -v luksDump /dev/loop0

I opened the encrypted device, and at the prompt typed same the passphrase I had entered earlier:

cryptsetup luksOpen /dev/loop0 private

This created a mapping device at /dev/mapper/private. The next step was to create a file system:

mkfs.ext3 /dev/mapper/private

Finally, I mounted the file sytem at /mnt:

mkdir /mnt/private
mount /dev/mapper/private /mnt/private

At this point, I now had a 100MB encrypted directory, mounted at /mnt/private and backed by the file ~/private.

To unmount the file system and close the encrypted device, I did this:

umount /mnt/private
cryptsetup luksClose private

10/19/2008 (6:54 am)

Reviving an old ThinkPad with TinyMe 2008

Filed under: linux, pclinuxos, software, thinkpad ::

I bought my first ThinkPad nine years ago, and now have five of them. Two of them (an A30p and a T40) are hopelessly broken, with system boards that either won’t power up or won’t stay powered up. The others are working pretty well, including the oldest one, a model called the 380Z, which despite the name, has no relation to Datsun sports cars.

The 380Z served me well for a couple of years. It was running Mandrake Linux practically from day one, and was a reliable, non-sleek tank. Recently I thought it might be fun to update it to a more recent Linux. But its specs are quite modest by today’s standards. Its power is about 1/10th that of a modern laptop in just about every area: 96 MB of RAM, a 233 MHz Pentium II processor, and a 4 GB hard disk. Nothing could be done about the RAM, and that’s the biggest problem, because most Linux GUIs these days (KDE being my favorite) require about 256 MB at a minimum if you want some memory left over for running a browser. The hard disk problem solved itself: when I powered the machine on yesterday for the first time in a year, the disk made terrible clunking and seeking noises and the BIOS reported it as dead. So I swapped in an 80 GB disk from the dead T40.

Now at least the machine could boot and presumably take a new OS installation. But what to install? I am a fan of PCLinuxOS, but it’s a bit on the heavy side for such a lightweight machine. So I tried a cut-down version of this OS called TinyMe 2008. This distro replaces the lovely but somewhat porky KDE GUI with a lightweight GUI based on various minimalist components (Openbox, LXPanel, Nitrogen, and iDesk).

I ran into a serious problem during installation having to do with the limited RAM on the 380Z. If a swap partition was not already available on the hard disk, then the live CD installer would eventually crash, apparently due to running out of RAM. My solution was to create a swap partition manually, enable it, and patch the installer so that it wouldn’t die when attempting to mount or unmount the swap partition.

The first step was to create the swap partition. This was accomplished by running the installer, and telling it to use the entire disk. The installer created three partitions, one of which was a swap, and then asked me to reboot the system. I did that, and when the login screen came up, I switched to a text console using Ctrl-Alt-F1, and logged in as root. I formatted and enabled the swap partition using mkswap /dev/hda5 and swapon -a. Then I switched back to the login screen using Ctrl-Alt-F7.

After logging in as root in the GUI, I launched a terminal (called Sakura) and edited two of the installer Perl scripts so that it wouldn’t die trying to mount or unmount the swap partition.

  • /usr/lib/libDrakX/fs/mount.pm: I edited the two lines containing syscall_('swapon',...) and syscall_('swapoff',...), changing the die calls to print.
  • /usr/lib/libDrakX/draklive-install: I commented out the line containing fs::mount::swapoff by prefixing it with a # character.

After these changes, the installer completed successfully without aborting or crashing the system. The resulting installation is a minimal Linux system that uses Opera as its web browser. This is certainly a decent alternative to Firefox, but I do miss the AdBlock Plus extension that makes browsing commercial, ad-laden sites more pleasant. The Orinoco-based wifi card (a Dell TrueMobile 1150 PCMCIA card) is supported and works perfectly with WEP (but probably won’t work with WPA, if past experience can be trusted).

The main post-installation problem was that sound didn’t work. The 380Z has an old Plug-And-Play Crystal Sound 423x device that pre-dates PCI. After a day of Google searching and experimentation, I determined that the ALSA driver (snd-cs4232) would not work, and that I needed to use the older OSS driver (cs4232). I edited /etc/modprobe.d/sound to look like this:

alias snd-card-0 cs4232
alias sound-slot-0 cs4232
options cs4232 io=530 irq=5 dma=0 dma2=0

I verified these settings by running the ThinkPad’s DOS-based configuration utility, PS2.EXE. I also found it necessary to run aumix after booting to bring up the speaker and PCM levels to audibility.

Another problem with the installation is that graphics acceleration was not enabled; this was very apparent when scrolling or moving windows. The solution was to run the PCLinuxOS Control Center, select “Hardware” and “Set up the graphical server”, and change the resolution bit depth from 24 bits to 16 bits. This is apparently required to work around a limitation of the NeoMagic graphics chip in the 380Z.

09/14/2008 (10:16 am)

Using a Treo 700P as a USB modem on SLED

Filed under: linux, suse, thinkpad, treo ::

During my frequent trips to Vermont over the last four years, I’ve discovered that most airports do not offer free WiFi access (Burlington VT and JetBlue at JFK are notable exceptions). In preparation for an upcoming trip to Vermont and the need to do some telecommuting en route, I figured out how to use my Sprint Treo 700p as an EVDO modem on SLED (SUSE Linux Enterprise Desktop) SP2 on a ThinkPad R61. I was aided in this by a couple of blog postings: Treo 700p Tether with Linux and Dialup Networking via Treo 700p and Ubuntu. Rather than list only the things I did differently, here is a complete procedure.

Installation:

As an ordinary user on Linux:

  • Create the directory usbmodem somewhere (e.g. in ~/tmp or ~/Desktop). Make it the current directory.
  • Download the USB Modem zip file. If you purchased the official version, it’ll have a name like usbmodem_retail_1_60.zip .
  • Unpack the zipfile using unzip usbmodem_retail_1_60.zip
  • Install USBModem.prc on the Treo; you’ll find this file in the current directory. I did this by uploading the file to my web site, and then selecting it in the Treo’s web browser.

As the root user on Linux:

  • From the usbmodem directory created earlier, run this command:
    cp drivers/linux/ppp-script-evdo-template /etc/ppp/peers/ppp-script-treo
  • Edit /etc/ppp/peers/ppp-script-treo. Change the “connect” line to:
    connect '/usr/sbin/chat -s -v "" AT OK ATD#777 CONNECT'
    Change the “user” line to:
    user USERNAME
    where USERNAME is your Treo’s user name, as determined from the main phone app, Options / Phone Info, UserName.
  • Edit /etc/ppp/pap-secrets, and add this line:
    USERNAME@sprintpcs.com *
    where USERNAME is the phone’s user name as determined in the previous step, and where there is a single tab between USERNAME@sprintpcs.com and the asterisk, not spaces.

Making a Connection:

  • Turn on the Treo, and connect it to the Linux machine with the USB sync cable.
  • Wait a few seconds and verify that the visor kernel module has been loaded with lsmod | egrep visor.
  • On the Treo, start the USB Modem program and press the “Enable Modem Mode” button.
  • Back on Linux, perform the following steps as root.
  • Bring down all other networks using ifdown eth0 or ifdown eth1 as necessary.
  • Verify that the USB modem driver and device are present using ls -l /dev/ttyACM0
  • Connect to the EVDO network using:
    pppd /dev/ttyACM0 call ppp-script-treo
    You should see messages about the connection being established. If you see a message about default route not being overridden, you forgot to bring down all your existing net connections earlier.
  • Verify the connection using route -n. You should see two entries for ppp0. To make really sure the connection is working, try ping -c3 www.google.com
  • End the connection by pressing the “Disable Modem Mode” button in the USB Modem program on the Treo. This should automatically bring down the ppp0 connection on Linux.

It should be possible to use KPPP (the KDE dialup connection application) instead of the various command line tools described above, but I have not tried this.

The irony in all this is we can finally do something with our cell phones that we were doing with Ricochet 13 years ago.

« Previous PageNext Page »