#!/usr/bin/env python3 import signal import sys import os import pwd import locale from gi.repository import Gtk, Gdk from Locker import Locker from LockWindow import LockWindow import pam def get_username(): return pwd.getpwuid(os.getuid())[0] theme = 'UzL-login' timeout = 5 logoutTimeout = 15 username = get_username() def handler(signum, frame): Gtk.main_quit() signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) signal.signal(signal.SIGQUIT, handler) locale.setlocale(locale.LC_ALL, '') locale.bindtextdomain('pylock', '/home/neoraider/Devel/Python/pylock/locale') locale.textdomain('pylock') Gtk.Settings.get_default().set_property('gtk-theme-name', theme) window = LockWindow() def lock(timeLeft): window.updateLockMessage(username, timeLeft) window.lock() def logout(): pass def updateTimeout(timeLeft): window.updateLockMessage(username, timeLeft) locker = Locker(timeout, lock, window.unlock, logoutTimeout, logout, updateTimeout) pamAuth = pam.pam() def tryUnlock(w, password): if pamAuth.authenticate(username, password): locker.unlock() else: window.reset() window.setAuthMessage(pamAuth.reason) return True window.connect('tryUnlock', tryUnlock) Gtk.main()