Last week when I was bored I decided to play around with my Eee PC and was trying to think of a cool use for the built in webcam. If you haven’t seen an Eee PC then the webcam has been placed above the screen so it points at the user when the lid has been opened

This gave me an idea that could prove useful if you think there are snoopers who might be accessing your laptop. The idea was to use the webcam to take a photo when the laptop lid is opened. This way whenever you leave your laptop unattended and someone comes along, when they open the laptop to use it an incriminating photo will be taken

To take the photo I used a program called Streamer. Streamer is a small command line application that can take photos and videos using a webcam. Once installed you can take snapshots with the command:

streamer –o filename.jpeg

Note that the filename extension must be .jpeg rather than .jpg for streamer to work.

Now that you are able to take photos the next thing to do is set up the laptop to do so whenever the lid is opened. To do this Advanced Configuration and Power Interface (ACPI) can be used.

ACPI has a file called lid.sh which is located in Ubuntu under /ect/acpi. Opening this file as root in a text editor will show what a laptop does when the lid is opened and closed

Close to the top of the file should be the following line:

Code:

grep –q closed /proc/acpi/button/lid/*/state

This line is followed by an ‘if statement’. This statement is used to discover if the lid has been opened or closed. The first part of the statement (between the then and else lines) is what happens with the lid is closed and the second part (between the else and fi lines) is what happens when it is opened

Therefore, to get the laptop to take a photo when the lid is closed is add the streamer command to take a photo after the else line like so

Code:

else
  streamer –o ~/lidopen.jpeg
 
  for x in /tmp/.X11…

Save the file and it should take immediate effect. However, opening and closing the lid on my laptop didn’t work. Going back to lid.sh I noticed the line:

Code:

if [ `CheckPolicy` = 0 ]; then exit; fi

This line is checking to see if the command CheckPolicy runs on your system and kills the script if it cannot. From looking up the command CheckPolicy it appears it is a SELinux policy compiler. As I don’t use SELinux this command won’t be recognised by my system so the lines below this wont be run (which includes the line we added)

To solve this problem I changed this line to be:

Code:

if [ `CheckPolicy` = 0 ]
then
  grep –q closed /proc/acpi/button/lid/*/state
  [[ $? = 0 ]] || streamer –o ~/lidopen.jpeg
 
exit
fi

This code is does the same check, to see if the CheckPolicy command is recognised and exit if not. However it also now checks to see if the lid has been opened and if so it will take a photo before exiting

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

My name is Kieren and this is my blog. I use it mostly to document any solutions to problems I come across in computing.

Search

XML Feeds