Chris Metcalf bio photo

Chris Metcalf

Twitter Facebook LinkedIn Instagram GitHub Stack Overflow Photography

Jealous of the Mac-freaks and all the cool tricks they can do with their Bluetooth cellphones, like locking their computer automatically when they walk away?

I spent a few minutes today hacking around and came up with a quick proof-of-concept script for something thats been bouncing around in my head for awhile:


    LOCK_CMD="xscreensaver-command -lock"

    while true;
          (sudo l2ping -s 1 -c 1 $BD_ADDR > /dev/null 2>&1 ) || $LOCK_CMD
          sleep $DELAY

It periodically pings your Bluetooth phone (replace BD_ADDR with the particular BD Address of your phone). When the ping fails (when you walk out of range), it can lock your screen, pause XMMS, etc. Not bad for 5 lines of Bash script.

Now I’ve just got to beef it up a bit, add some more options. If I’ve got the time, I’ll turn it into a Python Gnome applet so you can throw it in a toolbar.