Category Archives: Open Source

Automatically lock your Linux machine via bluetooth

I had a requirement to lock my laptop at work automatically without having to touch it. The way devised by a friend was to enable the screensaver and its locking mechanism every time my phone’s bluetooth was out of range i.e. could not be seen via hcitool scan. It works *really well*! Now my laptop locks whenever I leave the room.

Update: It seems this was popular with reddit.com/r/linux, so I’ve uploaded the script to github and added unlocking support!

Here’s the code:

#!/bin/bash
DEVICE=the bluetooth MAC id
DEV_NAME="The actual device's alias/name"
INTERVAL=5 # in seconds
# Start xscreensaver if it's not already running
pgrep xscreensaver
if [ $? -eq 1 ]; then
echo "Starting xscreensaver..."
xscreensaver &
fi
# Assumes you've already paired and trusted the device
while [ 1 ]; do
opt=`hcitool name $DEVICE`
echo $opt
if [ "$opt" = "$DEV_NAME" ]; then
echo "Device found. Not locking"
else
echo "Can't find device $DEVICE ($DEV_NAME); locking!"
xscreensaver-command -lock
fi
sleep $INTERVAL
done

Private Window in Firefox Nightly

One of things I disliked about using Firefox was the lack of “Private Window”. Whenever you wanted a private session it would reuse the current window. This is contrary to how Chrome has always done it.

Now, in Firefix Nightly (version 20 onwards), you get a private window instead of replacing the tabs. This is a neat little feature that lets you keep your current tabs open and browse privately in the new window. Anonymity online just got a little easier!