[kupfer: 13/51] kupferrelay: Wait for kupfer if it is not running when started
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 13/51] kupferrelay: Wait for kupfer if it is not running when started
- Date: Mon, 28 Mar 2011 15:02:10 +0000 (UTC)
commit a2ed0d8018bd066906e44fd92a10db1b827ff9a6
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:42 2011 +0200
kupferrelay: Wait for kupfer if it is not running when started
kupferrelay.py | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/kupferrelay.py b/kupferrelay.py
index 5f4c1bf..4018bf1 100644
--- a/kupferrelay.py
+++ b/kupferrelay.py
@@ -12,10 +12,15 @@ IFACE = "se.kaizer.kupfer.Listener"
def get_all_keys():
- bus = dbus.Bus()
- obj = bus.get_object(SERV, OBJ)
- iface = dbus.Interface(obj, IFACE)
- return iface.GetBoundKeys(byte_arrays=True)
+ try:
+ bus = dbus.Bus()
+ obj = bus.get_object(SERV, OBJ)
+ iface = dbus.Interface(obj, IFACE)
+ return iface.GetBoundKeys(byte_arrays=True)
+ except dbus.DBusException as exc:
+ print exc
+ print "Waiting for Kupfer to start.."
+ return []
def rebind_key(keystring, is_bound):
if is_bound:
@@ -37,11 +42,11 @@ def relay_key(key):
def main():
DBusGMainLoop(set_as_default=True)
- bus = dbus.Bus()
relayed_keys = list(get_all_keys())
for key in relayed_keys:
keybinder.bind(key, relay_key, key)
+ bus = dbus.Bus()
bus.add_signal_receiver(rebind_key, 'BoundKeyChanged',
dbus_interface=IFACE)
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]