[core/input] Use util.cli to execute commands

If the registered callback is not callable (i.e. no Python method),
assume it's a command that should be invoked via a shell.
This commit is contained in:
Tobias Witek 2020-02-08 13:40:51 +01:00
parent 9d4936b596
commit 4d34fa9261

View file

@ -1,4 +1,5 @@
import uuid import uuid
import util.cli
LEFT_MOUSE = 1 LEFT_MOUSE = 1
MIDDLE_MOUSE = 2 MIDDLE_MOUSE = 2
@ -10,7 +11,8 @@ callbacks = {}
class Object(object): class Object(object):
def __init__(self): def __init__(self):
self._id = uuid.uuid4() super(Object, self).__init__()
self._id = str(uuid.uuid4())
def id(self): def id(self):
return self._id return self._id
@ -31,5 +33,7 @@ def _invoke(event, callback):
for cb in callback.get(event['button']): for cb in callback.get(event['button']):
if callable(cb): if callable(cb):
cb(event) cb(event)
else:
util.cli.execute(cb, wait=False)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4