Added new get_focused_terminal dbus command which returns uuid of
currently focused terminal
This commit is contained in:
parent
ee8c51d10e
commit
1efd0eed7f
|
@ -41,6 +41,7 @@ COMMANDS={
|
|||
'hsplit': [True, _('Split the current terminal horizontally')],
|
||||
'vsplit': [True, _('Split the current terminal vertically')],
|
||||
'get_terminals': [False, _('Get a list of all terminals')],
|
||||
'get_focused_terminal': [False, _('Get the uuid of the current focused terminal')],
|
||||
'get_window': [True, _('Get the UUID of a parent window')],
|
||||
'get_window_title': [True, _('Get the title of a parent window')],
|
||||
'get_tab': [True, _('Get the UUID of a parent tab')],
|
||||
|
@ -88,9 +89,9 @@ if __name__ == '__main__':
|
|||
if uuid_required:
|
||||
uuid = options.get('uuid', os.environ.get('TERMINATOR_UUID'))
|
||||
if uuid:
|
||||
func(uuid, options)
|
||||
print(str(func(uuid, options)))
|
||||
else:
|
||||
err("$TERMINATOR_UUID is not set, or passed as an option.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
func(options)
|
||||
print(str(func(options)))
|
||||
|
|
|
@ -150,6 +150,13 @@ class DBusService(Borg, dbus.service.Object):
|
|||
"""Return a list of all the terminals"""
|
||||
return [x.uuid.urn for x in self.terminator.terminals]
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def get_focused_terminal(self):
|
||||
"""Returns the uuid of the currently focused terminal"""
|
||||
if self.terminator.last_focused_term:
|
||||
return self.terminator.last_focused_term.uuid.urn
|
||||
return None
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def get_window(self, uuid=None):
|
||||
"""Return the UUID of the parent window of a given terminal"""
|
||||
|
@ -217,7 +224,7 @@ def with_proxy(func):
|
|||
"Remotinator can't connect to terminator. " +
|
||||
"May be terminator is not running.")
|
||||
|
||||
func(proxy, *args, **argd)
|
||||
return func(proxy, *args, **argd)
|
||||
return _exec
|
||||
|
||||
@with_proxy
|
||||
|
@ -259,6 +266,11 @@ def get_terminals(session, options):
|
|||
"""Call the dbus method to return a list of all terminals"""
|
||||
print('\n'.join(session.get_terminals()))
|
||||
|
||||
@with_proxy
|
||||
def get_focused_terminal(session, options):
|
||||
"""Call the dbus method to return the currently focused terminal"""
|
||||
return session.get_focused_terminal()
|
||||
|
||||
@with_proxy
|
||||
def get_window(session, uuid, options):
|
||||
"""Call the dbus method to return the toplevel tab for a terminal"""
|
||||
|
|
Loading…
Reference in New Issue