add bg_img_all command to switch background on all terminals

This commit is contained in:
Matt Rose 2021-08-16 19:16:21 -04:00
parent 0434880f13
commit c11c9a0db0
2 changed files with 15 additions and 11 deletions

View File

@ -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.'))

View File

@ -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)