summaryrefslogtreecommitdiffstats
path: root/pylock.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylock.py')
-rw-r--r--pylock.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/pylock.py b/pylock.py
index dda47ba..f4841cd 100644
--- a/pylock.py
+++ b/pylock.py
@@ -34,9 +34,9 @@ import argparse
from gi.repository import Gtk, Gdk, Gio
-from DBus import DBus
from Locker import Locker
from LockWindow import LockWindow
+import Message
import pam
@@ -74,8 +74,20 @@ locale.textdomain('pylock')
Gtk.Settings.get_default().set_property('gtk-theme-name', theme)
+if Message.getSelection() != 0:
+ if args.timeout == 0:
+ Message.sendLockMessage()
+ exit(0)
+ else:
+ print('There seems to be a Pylock instance already running.', file=sys.stderr)
+ exit(1)
+
+
window = LockWindow()
+if not Message.acquireSelection(window):
+ print('Unable to register for lock messages', file=sys.stderr)
+
def lock(timeLeft):
window.updateLockMessage(args.username, timeLeft)
@@ -98,8 +110,10 @@ else:
locker = Locker(args.timeout, lock, window.unlock, args.logout, logout, updateTimeout)
-if args.timeout != 0:
- dbus = DBus(locker)
+def _triggerLock(w, e):
+ locker.lock()
+
+window.connect('map-event', _triggerLock)
pamAuth = pam.pam()