Merge pull request #361 from leandrost/feature/switch-profile
Remotinator "switch_profile" command
This commit is contained in:
commit
440b0a22e7
14
remotinator
14
remotinator
|
@ -45,6 +45,7 @@ COMMANDS={
|
|||
'get_window_title': [True, _('Get the title of a parent window')],
|
||||
'get_tab': [True, _('Get the UUID of a parent tab')],
|
||||
'get_tab_title': [True, _('Get the title of a parent tab')],
|
||||
'switch_profile': [True, _('Switch current terminal profile')],
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -63,11 +64,18 @@ if __name__ == '__main__':
|
|||
usage='%(prog)s command [options]',
|
||||
description=_('Run one of the following Terminator DBus commands:\n\n%s') % (command_desc),
|
||||
epilog=_('* These entries require either TERMINATOR_UUID environment var,\n or the --uuid option must be used.'))
|
||||
parser.add_argument('-u', '--uuid', dest='uuid', type=str, metavar='UUID', default=argparse.SUPPRESS,
|
||||
help=_('Terminal UUID for when not in env var TERMINATOR_UUID'))
|
||||
|
||||
parser.add_argument('command', type=str, nargs=1, choices=sorted(COMMANDS.keys()),
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('-u', '--uuid', dest='uuid', type=str, metavar='UUID', default=argparse.SUPPRESS,
|
||||
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'))
|
||||
|
||||
parser.add_argument('-v', '--version', action='version', version='%%(prog)s %s' %(APP_VERSION))
|
||||
|
||||
options = vars(parser.parse_args()) # Straight to dict
|
||||
|
||||
# Pull out the command
|
||||
|
@ -75,8 +83,8 @@ if __name__ == '__main__':
|
|||
del options['command']
|
||||
|
||||
func = getattr(ipc, command)
|
||||
|
||||
uuid_required = COMMANDS[command][0]
|
||||
|
||||
if uuid_required:
|
||||
uuid = options.get('uuid', os.environ.get('TERMINATOR_UUID'))
|
||||
if uuid:
|
||||
|
|
|
@ -197,6 +197,13 @@ class DBusService(Borg, dbus.service.Object):
|
|||
if terminal in terms:
|
||||
return root_widget.get_tab_label(tab_child).get_label()
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def switch_profile(self, uuid=None, options=dbus.Dictionary()):
|
||||
"""Switch profile of a given terminal"""
|
||||
terminal = self.terminator.find_terminal_by_uuid(uuid)
|
||||
profile_name = options.get('profile')
|
||||
terminal.force_set_profile(False, profile_name)
|
||||
|
||||
def with_proxy(func):
|
||||
"""Decorator function to connect to the session dbus bus"""
|
||||
dbg('dbus client call: %s' % func.__name__)
|
||||
|
@ -272,3 +279,8 @@ def get_tab_title(session, uuid, options):
|
|||
"""Call the dbus method to return the title of a tab"""
|
||||
print(session.get_tab_title(uuid))
|
||||
|
||||
@with_proxy
|
||||
def switch_profile(session, uuid, options):
|
||||
"""Call the dbus method to return the title of a tab"""
|
||||
session.switch_profile(uuid, options)
|
||||
|
||||
|
|
Loading…
Reference in New Issue