From c11c9a0db030f18ff590da15b9caa45fd08785ed Mon Sep 17 00:00:00 2001 From: Matt Rose Date: Mon, 16 Aug 2021 19:16:21 -0400 Subject: [PATCH] add bg_img_all command to switch background on all terminals --- remotinator | 7 ++++--- terminatorlib/ipc.py | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/remotinator b/remotinator index f846ae19..4cf30b93 100755 --- a/remotinator +++ b/remotinator @@ -47,7 +47,8 @@ COMMANDS={ 'get_tab': [True, _('Get the UUID of a parent tab')], 'get_tab_title': [True, _('Get the title of a parent tab')], 'set_tab_title': [True, _('Set the title of a parent tab')], - 'bg_img': [True, _('Set the background image')]. + 'bg_img': [True, _('Set the background image')], + 'bg_img_all': [False, _('Set the background image for all terminals')], 'switch_profile': [True, _('Switch current terminal profile')], 'switch_profile_all': [False, _('Switch profile of all currently running terminals')], } @@ -76,13 +77,13 @@ if __name__ == '__main__': help=_('Terminal UUID for when not in env var TERMINATOR_UUID')) parser.add_argument('-p', '--profile', dest='profile', type=str, default=argparse.SUPPRESS, - help=_('Terminal UUID for when not in env var TERMINATOR_UUID')) + help=_('Profile name to switch to')) parser.add_argument('-f', '--file', dest='file', type=str, default=argparse.SUPPRESS, help=_('File to pass to command')) parser.add_argument('-x', '--execute', dest='execute', type=str, default=argparse.SUPPRESS, - help=_('Terminal UUID for when not in env var TERMINATOR_UUID')) + help=_('Command to run in new terminal')) parser.add_argument('-t', '--tab-title', dest='tab-title', type=str, default="Missing Tab Title! Use -t argument!", help=_('Tab name to set. Only used with "set_tab_title" command.')) diff --git a/terminatorlib/ipc.py b/terminatorlib/ipc.py index a1161526..1e24f124 100644 --- a/terminatorlib/ipc.py +++ b/terminatorlib/ipc.py @@ -125,14 +125,13 @@ class DBusService(Borg, dbus.service.Object): return self.new_terminal(uuid, 'tab') @dbus.service.method(BUS_NAME) - def bg_img(self,uuid=None,options=None): - terminals = [] - if uuid: - terminals.append(self.terminator.find_terminal_by_uuid(uuid)) - else: - terminals = self.get_terminals() - for terminal in terminals: + def bg_img_all (self,options=dbus.Dictionary()): + for terminal in self.terminator.terminals: terminal.set_background_image(options.get('file')) + + @dbus.service.method(BUS_NAME) + def bg_img(self,uuid=None,options=dbus.Dictionary()): + self.terminator.find_terminal_by_uuid(uuid).set_background_image(options.get('file')) @dbus.service.method(BUS_NAME) def hsplit(self, uuid=None,options=None): @@ -212,7 +211,7 @@ class DBusService(Borg, dbus.service.Object): return new_terminal_set[0] def new_terminal(self, uuid, type): - """Split a terminal horizontally or vertically, by UUID""" + """Split a terminal horizontally o?r vertically, by UUID""" dbg('dbus method called: %s' % type) if not uuid: return "ERROR: No UUID specified" @@ -433,6 +432,10 @@ def switch_profile_all(session,options): """Call the dbus method to return the title of a tab""" session.switch_profile_all(options) +@with_proxy +def bg_img_all(session,options): + session.bg_img_all(options) + @with_proxy def bg_img(session,uuid,options): session.bg_img(uuid,options)