running without the service on dbus failure

This commit is contained in:
sezanzeb 2020-11-23 23:42:23 +01:00
parent b1fff0c286
commit fc07f96ec7

View File

@ -54,11 +54,20 @@ def get_dbus_interface():
) )
return Daemon(autoload=False) return Daemon(autoload=False)
logger.debug('Found the daemon process') try:
bus = dbus.SessionBus() logger.debug('Found the daemon process')
remote_object = bus.get_object('com.keymapper.Control', '/') bus = dbus.SessionBus()
interface = dbus.Interface(remote_object, 'com.keymapper.Interface') remote_object = bus.get_object('com.keymapper.Control', '/')
logger.debug('Connected to dbus') interface = dbus.Interface(remote_object, 'com.keymapper.Interface')
logger.debug('Connected to dbus')
except Exception as error:
logger.error(
'Could not connect to the dbus of "key-mapper-service", mapping '
'keys only works as long as the window is open.'
)
logger.error(error)
return Daemon(autoload=False)
return interface return interface