Shantz Webcam Autolocker

Sometimes I do some things that even I can’t explain why I did ’em. Did this one in one of those times as well. This is a simple (and useless) script to monitor motion in front of your PC, auto-lock it when you are away and auto-unlock it when you come back. Kinda useless cuz there is no security aspect (read face detection etc) and any kind of motion triggers the unlock. Did it just because I was really bogged down by the shitload of work that I’ve been doing for the past few weeks (and even weekends as well), so wanted to take a break for a few minutes, and just chanced over my own “Home Security Using a Webcam and Twitter” post, so thought of doing something related to motion-detection again.


1. Works only in linux, primarily because the motion detection software we are going to use here works only in linux, otherwise we can port the script to other platforms.

2. You should have motion installed. If you are using Debian/Ubuntu or one of their derivatives, this is as simple as typing

sudo apt-get install motion

Otherwise, just go to the link above and download.


This is very simple.

1. Download the zip file attached to this post and unzip somewhere preferably in your home directory.

2. Open your terminal/command prompt. “cd” to the folder where you unzipped the zip file.

3. Run the following command.

motion -c ./motion.conf

4. Run the following(in a different terminal, after cd’ing to the same folder):


And that’s it. See the magic (a pretty useless one, I admit :-D) happen.


The script takes a few options that you can use to customize the program according to your needs.

Usage: ./shantz-locker [-l <LockThreshold>] [-u UnlockThreshold] [-s LockScanInterval] [-t UnlockScanInterval]

#LockThreshold – Determines the threshold (based on no. of samples sans motion) to lock your PC. Default is 5
#UnlockThreshold – Determines the threshold (based on no. of samples with motion) to unlock your PC. Default is 2
#LockScanInterval – How soon to check if there is motion when your PC is in unlocked state. Default interval is 5 seconds
#UnlockScanInterval – How soon to check if there is motion when your PC is in locked state. Default interval is 2 seconds

If you liked it, or disliked it, or want to add your modifications to it, or have some cool idea that I can modify it for, just give me a shout in the comment box below.

DOWNLOAD: Shantz Webcam Autolocker

9 Responses

  1. Project: Shantz Webcam Autolocker | My Technophilic Musings

    […] Shantz Webcam Autolocker […]

  2. Stemp
    Stemp at |

    Is it possible to really locking the screen and ask for a password when you come back ?

  3. Kirk
    Kirk at |

    What is the purpose of locking the computer if it unlocks automatically when anyone goes in front? Why not just, not lock it. Maybe comment #2 makes sense, turn off the screen saver and ask for your password.

    I can see this being useful for slight increase in battery life if it suspends/hibernates your laptop when you leave and wakes up when you come back.

  4. ThomasEgi
    ThomasEgi at |

    Well this is especially usefull if you want your computers to catch the attention of people passing by. if you extend it a little it should be no problem to do.
    so it’s a nice toy for exhibitions, salesrooms etc. whenever you pass by a notebook or screen+webcam the pc jumps out of the screensaver and welcomes the user, inviting him to take a seat and have a look at the product.

    wouldnt you be surprised if a computer sunddley stops saving his screen and tries to interact with you out of the blue?? great eye-catcher if you ask me.

  5. Webcam Locker von Shantz - Mindfactory AG Community Forum

    […] System wieder. Wie das funktioniert erkl

  6. Tor
    Tor at |

    A much cooler locker/unlocker is blueproximity. Lock and unlock your pc by the proximity of your paired bluetooth phone. I use it at work and it’s really handy.

  7. Nalle Berg
    Nalle Berg at |

    If you could make the application take a few pictures and send them by mail to a predefined address, we could have picture of the one «borrowing» your PC. Then it’d be a good security app!

    Nalle Berg

Comments are closed.