Created
September 26, 2013 13:37
-
-
Save utdemir/6714298 to your computer and use it in GitHub Desktop.
Takes a photo from webcam on screen unlock. Works on KDE. Depends on fswebcam, python2, python2-gobject, python2-dbus.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# coding: utf-8 | |
COMMAND = 'fswebcam --save ~/Dropbox/images/unlock-{date}.jpeg' | |
import subprocess | |
from datetime import datetime | |
import gobject | |
import dbus | |
import dbus.glib | |
from dbus.mainloop.glib import DBusGMainLoop | |
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
def handler(status): | |
if not status: | |
cmd = COMMAND.format(date=datetime.now().isoformat()) | |
subprocess.call(cmd, shell=True) | |
bus = dbus.SessionBus() | |
ss = bus.get_object('org.kde.screensaver', '/ScreenSaver') | |
ss.connect_to_signal("ActiveChanged", handler) | |
gobject.MainLoop().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment