[kupfer: 21/51] Move kupferrelay.py into the package into kupfer --relay



commit 042d320d7ff9be4239322f741fd01f8464ff4cc3
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Mar 28 16:51:44 2011 +0200

    Move kupferrelay.py into the package into kupfer --relay
    
    Make kupferrelay.py its own subprogram that can be started with
    ``kupfer --relay``

 kupferrelay.py => kupfer/keyrelay.py |   11 +++++++++--
 kupfer/main.py                       |    8 ++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/kupferrelay.py b/kupfer/keyrelay.py
similarity index 86%
rename from kupferrelay.py
rename to kupfer/keyrelay.py
index 58fd182..be6a1e0 100644
--- a/kupferrelay.py
+++ b/kupfer/keyrelay.py
@@ -1,3 +1,7 @@
+"""
+This is a program of its own, that does not integrate with the
+Kupfer process.
+"""
 import os
 
 import gtk
@@ -45,11 +49,14 @@ def main():
 	relayed_keys = list(get_all_keys())
 
 	for key in relayed_keys:
-		keybinder.bind(key, relay_key, key)
+		rebind_key(key, True)
 	bus = dbus.Bus()
 	bus.add_signal_receiver(rebind_key, 'BoundKeyChanged',
 			dbus_interface=IFACE)
-	gtk.main()
+	try:
+		gtk.main()
+	except KeyboardInterrupt:
+		raise SystemExit(0)
 
 if __name__ == '__main__':
 	main()
diff --git a/kupfer/main.py b/kupfer/main.py
index 7a21a42..7bec629 100644
--- a/kupfer/main.py
+++ b/kupfer/main.py
@@ -43,6 +43,7 @@ def get_options():
 		("no-splash", _("do not present main interface on launch")),
 		("list-plugins", _("list available plugins")),
 		("debug", _("enable debug info")),
+		("relay", _("run keyboard shortcut relay service on this display")),
 	]
 	misc_options = [
 		("help", _("show usage help")),
@@ -95,6 +96,9 @@ def get_options():
 		if k == "--debug":
 			global _debug
 			_debug = True
+		if k == "--relay":
+			keyrelay_main()
+			raise SystemExit
 
 	# return list first of tuple pair
 	return [tupl[0] for tupl in opts]
@@ -132,6 +136,10 @@ def _set_process_title():
 	else:
 		setproctitle.setproctitle("kupfer")
 
+def keyrelay_main():
+	import kupfer.keyrelay
+	kupfer.keyrelay.main()
+
 def gtkmain(quiet):
 	import pygtk
 	pygtk.require('2.0')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]