Thu, 29 May 2008

Auto-locking My Computer When I Walk Away

The other day, while I was wating for several GB to transfer over the network at work, I finally got around to setting something that's been dancing at the back of my mind for a while: computer-based proximity detection using Bluetooth.

I have a Treo 650. It has Bluetooth. I also have a USB Bluetooth Adapter. I originally planned to carry the bluetooth adapter around and hook it up to different computers whenever I wanted to talk to the Treo, but I've only been using it at work, so I've been leaving the adapter connected to my Linux computer at work. The thought occurred to me that I could use the Bluetooth adapter to see whether my phone was nearby and do things based on that information. At least to start, I decided to have the computer lock itself when I wasn't around.

I have the BlueZ Bluetooth stack installed. (On Debian, that's the bluez-utils package.) They include a l2ping program, but that establishes a full Bluetooth connection with the device, which makes my Treo turn on the screen, play a little sound, and show a pop-up dialog. That's a little intrusive for something that I want checked several times a minute. Some people use hcitool rssi to find out the strength of the phone's (or other device's) Bluetooth signal. That also requires a full Bluetooth connection. I ended up using hcitool name, which returns the name of the device if it's found and nothing if it's not. More importantly, it doesn't cause the Treo to do anything but silently send its response, and it works even if the Treo screen is off.

So I now have a stupid little shell script that looks like this:

#!/bin/sh

PHONE_ADDR=01:23:45:67:89:AB
PHONE_NAME="glamdring"
WAIT_TIME=15

while true; do
  if [ "$(hcitool name $PHONE_ADDR)" \!= "$PHONE_NAME" ]; then
    xscreensaver-command -lock
  fi
  sleep $WAIT_TIME
done

There are programs for Windows that do similar things. Possibly one of the simplest is Blue Lock, which is also open-source (and written in Delphi). I'm probably just going to write a simple Windows program to listen on the network for a message from my Linux computer to tell it to lock the screen.

Fri, 02 May 2008

New Site Hosting

In the interests of better site availability and less Comcast AUP-breaking, I've finally gotten around to outsourcing my website hosting. I'm currently at NearlyFreeSpeech.net, a webhost committed to the twin goals of free speech and affordable web hosting.

How free is their speech? Read their Abuse page:

"A NearlyFreeSpeech.NET member site is defaming me or otherwise injuring me civilly."

Please forward a copy of your legal finding from a court of competent jurisdiction to our contact address. If you have not yet obtained such a finding, a preliminary injunction or court order is also sufficient.

If you are not able to obtain the above, you will need to work directly with the site operator to resolve your differences. We will have to fall back on our members' contractual assertion that the content they upload is legitimate and therefore we will not be able to get involved

How affordable is their hosting? You pay only for the bandwidth and storage that you actually use: $1 per gigabyte of bandwidth and $0.01 per megabyte-month of storage. (Plus the bandwidth cost goes down the more you use.)

They support a variety of CGI scripting languages, including C, PHP, Perl, Python, and Ruby. Oh, but also Fortran, Tcl, Lisp, Scheme, OCaml, and Haskell.

We'll see how it goes, but I think I'll like it here.


Phil! Gold