My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://taylor.braun-jones.com/blog/
and update your bookmarks.

Lifestyle Creep

As far as I know, this Mint blog post coined this phrase, but I actually like this post from diveintomark.org that covers the some topic of happiness through simple living (things like shedding material attachments).

Debian/Ubuntu Package Installation Shortcut

Alt-F2 then type
apt:packagename
Simple, quick, and should work in any window manager. Just remember that package names are case sensitive and almost always lowercase.

Here's an example where I install XBMC:




Then just click Install:



This example is with Ubuntu's default window manager, GNOME, but should work basically the same way in any other window manager, just not as pretty. *ducks*

Synergy for HTPC control

Synergy. Great app.
Synergy for HTPC control. Great application.

Setup is pretty simple, but the Synergy HOWTO on the Ubuntu Community Documentation was pretty horrendous. I decided I'd give back a little and did a major clean up/rewrite of it and now it is actually usable.

The one technical contribution I made was to speed up the X/GDM scripts slightly. Instead of:
/usr/bin/killall synergys
sleep 1
/usr/bin/synergys
It is now:
/usr/bin/killall synergys
while [ $(pgrep -x synergys) ]; do sleep 0.1; done
/usr/bin/synergys
You could say it saves less than a second. Or, you could say it's about a 10x speedup :-)

Now if someone would just write a synergy client for the Android platform I could get rid of Gmote and all it's quirks.

Waking Up is Hard to Do

Since I couldn't possibly write it any better, this is plagarized from the user page of a random Gnome developer:
  • 2:00 AM: Set alarm for 10 am (physical switch)
  • 2:03 AM: Tape piece of paper over alarm with the text "Why are you ruining my life?"
  • 2:07 AM: Go to bed
  • 2:15 AM: Fall asleep
  • ??? AM: Alarm is switched off, and the piece of paper is retaped over the alarm by a mysterious force. Abducted by aliens? Gremlins? Cruel alter ego?
  • 12:17 PM: Wake up with no memory of the alarm being disabled. Paper is still taped over the alarm like the alarm was never turned off (?!?)
  • 12:18 PM: Perform thorough exam for signs of alien abduction: scars, incisions, chips in the back of my neck, probes in various orifices. Results, negative
  • 12:19 PM: Inspect apartment security fixtures. Deadbolt: in place. Physical chain slider thing: in place. Pole blocking sliding glass door: in place. Grill over fan vent in bathroom: in place. Gremlin trap: empty
Conclusion: I have a cruel alter ego who wakes up when the alarm goes off, disables it for who knows what reason, laughs mischeviously, and then goes back to bed.
Solution: Tie myself up before going to bed.
Problem: How do I get out of bed when I'm back to my calm mild mannered normal self?

Better FOSS QA Testing

I just had a random thought when I came across the following in the Changelog for VirtualBox 3.1:
Mac OS X hosts (64 bit): don't interpret mouse wheel events as left click (bug #5049)
This seems like something basic that should have been caught in a beta release, but it didn't because there is no way to monitor the use case coverage. The typical QA process for most FOSS applications is to release a Beta version, watch the bug reports pour in, fix them, and repeat.

This is great, except – Wait, no, that's not what I meant to say. This sucks. Of all those beta users who downloaded gizmo-0.9beta how many actually tried using, say, the HTTP proxy feature? Or ran the application over a dial-up connection? Or ran on 64-bit OS X?

There are all kinds a solutions to this problem, all of which could be integrated into one of the many software project managment tools out there like code.google.com, Trac, sf.net, etc.

Ask for an email address when before reaching the beta download link and follow up a week later asking the user to fill out a quick report about the environment they ran the software in and, optionally, a list of the programs features they used. Click a green check next to the feature if it worked properly, and a red X if the feature did not work. After the form is submitted, post a screen with links to the effect of "Click here to submit a bug report for your problems you experienced with xyz"

Take that one step further and ask for permission to collect information about the environment the first time it launches. If the user is willing to loose anonymity they can also enter their email address and the form they they are emailed one week later will be pre-populated with as much information about their environment/usage experience as possible.

Even better, turn this data into any number of cool visualizations which are publicly available in real time. Developers can quickly see what aspects of the software are problematic and, more importantly, what environments have not been test much (or at all). Hopefully they would decide to make some sort of concerted effort to get test coverage for those areas. And by making the data public and easily accessible in the form of pretty charts, users can see how well tested the application is on their particular platform/processor/new-fangled-peripheral.

Okay, that's enough ranting for tonight.

Easy, automated backups with rdiff-backup

Let me start by saying rdiff-backup is exactly the tool I set out to find when looking for a backup solution. It makes use of librsync so you get all the goodness of the rsync remote-delta optimization algorithm, plus incremental backups. To top it off, your most recent backup is stored as a simple mirror so recovering your most recent backup of a given file is just a matter of (s)cp'ing it.

To setup automated, unattended backups (the holy grail of data backups) I used a good HOWTO guide for setting up unattended backups. so I won't duplicate that; I'll just summarize and detail the parts that are unique to Debian or ARM/embedded systems (I'm running Debian squeeze on a SheevaPlug). For simplicity, I'll use the same machine names as were used in the original HOWTO – kitty for the backup server and fishie for the machine to be backed up. I'm only backing up one home directory on fishie for a hypothetical user we'll call nemo.

  1. First, install rdiff-backup on kittie and fishie:
    sudo apt-get install rdiff-backup
  2. Create an account for your backup bot:
    adduser --system --group --disabled-login --disabled-password --home /var/backupbot backupbot
    My 1 TB USB hard drive is mounted at /var so that is where I place the home directory. This also follows the FHS guidelines.
  3. Create a public/private key pair for backupbot, copy it to the authorized_keys file of nemo@fishie, then test it:
    sudo -s -u backupbot
    ssh-keygen -f ~backupbot/.ssh/id_fishie
    ssh-copy-id -i ~backupbot/.ssh/id_fishie.pub nemo@fishie
    ssh nemo@fishie
  4. Assuming the above commands worked, you should now be logged in as nemo@fishie. Open an editor and prepend the following to the long line of gibberish that was just added to ~nemo/.ssh/authorized_keys
    command="rdiff-backup --server --restrict-read-only /home",from="kittie",no-port-forwarding,no-X11-forwarding,no-pty 
    Now any SSH session that is authenticated using this key will (1) automatically launch rdiff-backup in server mode and (2) have several SSH features disabled (for extra security).
  5. As backupbot, open ~backupbot/.ssh/config (sudo -u backupbot emacs ~backupbot/.ssh/config) and enter the following:
    host nemo-backup
        hostname fishie
        user nemo
        identityfile /backup/.ssh/id_fishie
        compression no
        protocol 2
    Some notes about these options:
    • I don't use root to log into the remote machines because I'm only backing up home directories. This means you should take care to not to create files within your home directory that you do not have read access to (or at least keep them confined to one subdirectory so that rdiff-backup can skip them with a simple --exclude option). To find and fix any files that you may have already created while (e.g.) running as root use the following command:
      sudo find ~nemo -not -user nemo -exec chown nemo:nemo {} +
    • The first time I ran a backup I used 'compression yes'. I promise never to do that to you again, poor little SheevaPlug. If you have a slower link speed or a faster CPU then compression may make sense. For more optimization you may want to experiment with 'cipher blowfish' option. It can supposedly run at 88% of the speed of 'cipher none' but I haven't had a chance to play with it myself.
  6. The last step is to automate the backup. Run sudo -u backupbot EDITOR=emacs crontab -e. Add the following crontab line:
    30 0 * * * rdiff-backup nemo-backup::/home/nemo /var/backupbot/nemo && rdiff-backup --remove-older-than 3M /var/backupbot/nemo && echo "Backup successful"
    This will run a backup every night at 12:30 AM and delete any incremental backups older than 3 months.

I'll do a follow up post on how I setup postfix with Gmail's SMTP servers. So that each user gets an email each morning with the status of the backup.

Ugh... Why the paranoia, Transmission!?

Just wasted an hour because of the janky configuration setup for an otherwise great BitTorrent daemon, Transmission. Basically, the default configuration for Transmission that ships with Debian has RPC authentication turned on in two places. Finally discovered this by reading the README in /etc/transmission-daemon (*blush*). This pointed me to Message #24 of bug 539936 which explained things nicely. Solution summary:
  1. Stop transmission-daemon
  2. Turn off RPC authentication in
    /etc/transmission-daemon/settings.json
  3. Turn off --auth parameter in
    /etc/default/transmission-daemon
  4. Restart transmission-daemon
Sheesh.

Installing Flash on PortableFirefox

Lifehacker and many other blog postings which turned up in a Google search for "portable firefox flash" seem seem to have outdated information, about where to place the flashplayer.xpt and NPSWF32.dll files. It cost me over an hour of trouble shooting the correct location to place these two files (at least with Firefox 3.0.8 and Flash 10) is

FirefoxPortable/
Data/plugins

Ahh, it feels good to finally see this:

Easy remote torrent queuing with trasmission, zenity, and a dab of glue

Here is just a dab of glue that takes two very cool projects, Transmission and Zenity, and makes something very usable. Open a text editor as the root user (gksu gedit) and copy and paste this script:

#!/usr/bin/env bash

targethost=$(zenity --list --title "Assign host to download torrent" \
--radiolist --column " " --column "Host Name" \
TRUE localhost \
FALSE YOURSERVER) || exit

# Special case for localhost so it will still work if transmission is
# not already running
if [ "${targethost}" == "localhost" ]; then
transmission "$1" &
else
# TODO: Start transmision on the remote host if it is not already
# running
transmission-remote ${targethost} -a "$1"
fi

Just replace YOURSERVER with the name of the computer running transmission. Save the script to /usr/local/bin/add-remote-torrent (or whatever you want to name it) and give it execute permssions (sudo chmod +x /usr/local/bin/add-remote-torrent) For help setting up the transmission daemon the Transmission wiki has some well written guides, particulary the one on running Transmission on a headless machine.

Also, note that this script requires Transmission 1.50 or later, which supports adding torrents by URL. Ubuntu 9.04 and newer have this by default. Users of older releases need to add the official Transmission repository. From System -> Administration -> Software Sources, add the following APT line:

deb http://ppa.launchpad.net/transmissionbt/ubuntu intrepid main

Then add the authentication key so that the software repository is recognized as a "Trusted Software Provider"

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com \
0xa37da909ae70535824d82620976b5901365c5ca1

Regardless of what version of Ubuntu you are running, you will need to explicitly install the Command Line Interface version of Transmission (transmission-cli) :

sudo apt-get install transmission-cli

Finally, go to your web browsers setting/preferences page and associate BitTorrent files (MIME type "application/x-bittorrent") with /usr/local/bin/add-remote-torrent. In Firefox this setting is located at Edit->Preferences->Applications. Now when ever you click a torrent link you will have the option of downloading the torrent on your own computer or on another computer.

Kink the video, not your neck

If you're anything like me when shooting short video clips with your camera, you regularly find that you've captured a great little clip with one exception – the video is turn on its side. Here is a little script to get you out of that dilemma, since I've found that it's not as easy as it should be with most video editors for Linux.

#!/usr/bin/env perl
#
# Naulilus (or command line) script to rotate one or more videos, renaming
# each one from, e.g., 'dir/input.avi' to 'dir/output (rotated).avi'
#
# Author: Taylor Braun-Jones
#
use File::Basename;

my ($input, $output);
my ($filebase, $dir, $suffix);

if ($ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}) {
@videos = split "\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS};
# open DBG, ">/tmp/rotate_video_debug" and select DBG;
} else {
@videos = @ARGV;
}

foreach $input ( @videos ) {
chomp $input;
($filebase, $dir, $suffix) = fileparse("$input", '\..*$') or die "Failed
to parse filename: $input";
$output = "$dir$filebase (rotated)$suffix";
print "Rotating: '$input' -> '$output'\n";
system "mencoder -vf rotate=1 -o \"$output\" -oac copy -ovc lavc \"$inpu
t\"";
}
close DBG if DBG;

Just drop this script into $HOME/.gnome2/nautilus-scripts/ and give it execute permsions
chmod +x SCRIPTNAME
Also, make sure you have mencoder installed. On Debian-based systems (like Ubuntu) it's as simple as:
sudo apt-get install mencoder

Short DHCP Lease Times

If you are an Ubuntu user who has experienced WiFi disconnects from public hot spots while other Windows and Mac users around you are Web browsing worry free you're not the only one. In this particular case, however, the fix may be quite easy.

The symptoms my wife experienced were that she could connect to the USC wireless network and happily surf the internet for about an hour before being booted off and not being able to reconnect for a period of about 24-hours. Turns out, according to USC IT department, that defaut DHCP lease time in Ubuntu is shorter than that on Windows and Mac OS. This exceeded whatever arbitrary DHCP renewal rate threshold USC has configured and caused her MAC address to be blacklisted for a day. Here's the fix:

Edit /etc/dhcp3/dhclient.conf as root with the following command (Tip: Use Alt-F2):
gksu gedit /etc/dhcp3/dhclient.conf
Change the DHCP lease time by editing the following option (or adding it if it does not already exist)
option dhcp-lease-time 86399;
That sets the lease time to be 86399 seconds – one second shy of a day.

Gmail Contacts... Almost Accessible

Google has provided interfaces to most of its services through standard protocols, which is great. I can access my Google Calendar events via a private iCal address (one-way only, Google to my local client). I can access my Gmail messages through POP or IMAP. I can import my OpenDocument files to Google Docs (even keep them synchronized as I work on them with the help of OpenOffice.org2GoogleDocs extension).

One gripe I've had since the beginning of Gmail is that I cannot access my Gmail contacts from any LDAP-supported address book — until GCALDaemon. It's a daemon that, among other things, translates LDAP requests from a local client (e.g. Mozilla Thunderbird) to gmail.com HTTP requests. A bonus feature for me (though this seems to actually be the main feature of GCALDaemon) is that I get two-way synchronization with my Google Calendar now too. GCALDaemon is available for Linux, OS X, and Windows, though the developers are obviously Windows centric — the Linux release comes as a zip file (no .deb, .rpm, or even tarball) and then you are instructed to add execute permissions the the shell scrips as part of the manual installation process! It also lacks an init script, so I wrote a simple one to get the job done (Assumes you unpacked the zip file to /opt):
#! /bin/sh
# /etc/init.d/GCALDaemon
#

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting GCALDaemon ..."
start-stop-daemon --start --pidfile /var/run/GCALDaemon.pid \
--chuid nobody:nogroup --background --make-pidfile \
--exec /opt/GCALDaemon/bin/standalone-start.sh
;;
stop)
echo "Stopping GCALDaemon ..."
start-stop-daemon --stop --pidfile /var/run/GCALDaemon.pid --user nobody
;;
*)
echo "Usage: /etc/init.d/blah {start|stop}"
exit 1
;;
esac
for getting up and running quickly. So why are Gmail contacts only almost accessible? Only email addresses and phone numbers seem to supported by GCALDaemon, not postal addresses.

See also:
UPDATE (2008-11-14): I discovered Zindus and have been using it for a few weeks now. It's a more elegant solution, though they still need to figure out out a better solution for syncing postal addresses. The best solution is to simply standardize the way postal addresses are stored, IMO. Currently the Thunderbird address book keeps sepearate fields for Street, City, etc., whereas Google (and many others) store addressses as one big free-form field.

FInally, A Solid DVD-to-MPEG Converter

For some reason I never came across HandBrake until reading about it by chance on diveintomark.org. It's a CLI application that makes great use of two cores. With my dual-core opteron, top reports close to 200 percent CPU utilization. I don't think I've ever seen that from a single application before. It runs on Mac OS and Windows and there is even a Mono-based GUI for Linux called RippedWire, which I have yet to try out.

Typing Heaven

For my first Father's Day (woohoo!) I received a SpaceSaver keyboard from pckeyboard.com. It's essentially an old school Model M with a few modernizations:
I've considered buying a used Model M in the past, but was put off by the amount of desk space it eats up and its lack of a Super modifier key (which is useful for all kinds of shortcuts).

The only thing I would change about the SpaceSaver -- and this is fairly minor -- would be to add volume control keys above the number pad like on the recently deprecated Apple keyboard. Another idea I have brainstormed, but haven't though through completely, is to move/add a modifier key next to the number pad, ideally around the bottom left so that you can easily run two-key shortcuts with your right hand (thumb + index/middle/ring fingers).

Debian RC Script Control

As a former Gentoo user, I had to learn the Ubuntu/Debian way to add service to a system runlevel. For my desktop, I never had to worry about it because, as usual with Ubuntu, a nice GUI is provided to manage startup services (System -> Administration -> Services). However when installing pyscrabble-server on my closet server I had to lookup the CLI tool for the job. (Note that I could have just used X11 forwarding to run the GUI tool, but that is just not nearly as cool and would have required lots of unnecessary GUI packages) It its simplest form, the comand to automatically start and stop /etc/init.d/SERVICE at startup and shutdown is simply:

sudo update-rc.d SERVICE defaults

From the man page:

If defaults is used then update-rc.d will make links to start the service in runlevels 2345 and to stop the service in runlevels 016.
For anything more complex, see the man page. Note that Debian has good bash completion support for the update-rc.d command.

If you're adding your own home-brew service, you can always just add commands to /etc/rc.local and make that file executable.

MythStream: Please help me ditch my cable TV

So I've been wondering when someone would finally get around to writing a plugin like this for MythTV. I can't wait to get a setup that uses this plugin so that I can ditch cable TV altogether. Especially with the writer's strike that is sure to lead to an increase in reality TV... Ow, my eyes; they bleed...

OpenDocument Templates

I thought it was encouraging to find that templates for shipping labels and other things are much easier to find in OpenDoc format (.ott) these days. For example, these at wordlabel.com worked great for my Avery labels.

On a separate note, I really like that pasting unformatted text is finally an easily accessible option in OpenOffice:


Creating Fillable PDF Forms

From what I can tell, creating fillable PDF forms can't be done for free in Windows. However, I came across this great guide for creating a fillable PDF on a Linux box using Scribus. Haven't tried it yet, but I will keep it in mind for the next time I have a need.

SANE Network Scanning

A good, simple network scanning with SANE HOWTO seemed to be missing from the internet so I added this one to the Ubuntu Wiki.

Scripting Windows Registry Changes

This is something every power Windows user should know about automating changes to the Windows registry. Let's just learn by example:

reg add HKLM\SOFTWARE\Atria\ClearCase\CurrentVersion /v Region /d MyClearCaseRegion /f

This adds the Region "Value Name" (/v), sets the "Value Data" (/d) to MyClearCaseRegion and forces it to overwrite an existing registry entry if one exists (/f).

All you have to do is look up the key you want to change using regedit.exe (Start->Run->regedit) and don't forget to convert the top level directory name into a four-letter acronym. For example HKEY_LOCAL_MACHINE becomes HKLM. Here is a regedit screenshot showing the registry entry created with the above example.


That should cover 95% of your registry automation needs and for everything else there is:

reg /?