From 2e1dd1f3166165a3bd81df0db078c247e18f8ca6 Mon Sep 17 00:00:00 2001 From: Dante Calderon Date: Mon, 24 Oct 2022 00:51:53 -0500 Subject: [PATCH 1/2] Add CLI command to reload configuration --- terminator | 11 +++++++++++ terminatorlib/ipc.py | 11 +++++++++++ terminatorlib/optionparse.py | 3 +++ 3 files changed, 25 insertions(+) diff --git a/terminator b/terminator index 150fca0e..5f5c33a3 100755 --- a/terminator +++ b/terminator @@ -109,6 +109,13 @@ if __name__ == '__main__': import dbus try: dbus_service = ipc.DBusService() + + if(OPTIONS.reload): + # Reload only is executed when exist at least one window, + # Check if exist another way to know if master process is not active. + dbg('reload option, killing app') + sys.exit() + except ipc.DBusException: dbg('Unable to become master process, operating via DBus') # get rid of the None and True types so dbus can handle them (empty @@ -121,6 +128,10 @@ if __name__ == '__main__': if OPTIONS.new_tab: dbg('Requesting a new tab') ipc.new_tab_cmdline(optionslist) + if OPTIONS.reload: + dbg('requesting to reload configuration for all windows') + ipc.reload_configuration() + elif OPTIONS.unhide: print('requesting to unhide windows') ipc.unhide_cmdline(optionslist) diff --git a/terminatorlib/ipc.py b/terminatorlib/ipc.py index 4303f28f..9484b221 100644 --- a/terminatorlib/ipc.py +++ b/terminatorlib/ipc.py @@ -124,6 +124,12 @@ class DBusService(Borg, dbus.service.Object): """Create a new tab""" return self.new_terminal(uuid, 'tab') + @dbus.service.method(BUS_NAME) + def reload_configuration(self): + """Reload configuration for all terminals""" + self.terminator.config.base.reload() + self.terminator.reconfigure() + @dbus.service.method(BUS_NAME) def bg_img_all (self,options=dbus.Dictionary()): for terminal in self.terminator.terminals: @@ -343,6 +349,11 @@ def new_tab_cmdline(session, options): """Call the dbus method to open a new tab in the first window""" session.new_tab_cmdline(options) +@with_proxy +def reload_configuration(session): + """Call the dbus method to reload configuration for all windows""" + session.reload_configuration() + @with_proxy def unhide_cmdline(session,options): session.unhide_cmdline(options) diff --git a/terminatorlib/optionparse.py b/terminatorlib/optionparse.py index befafa6e..a616db77 100644 --- a/terminatorlib/optionparse.py +++ b/terminatorlib/optionparse.py @@ -39,6 +39,9 @@ def parse_options(): parser = argparse.ArgumentParser() + parser.add_argument('-R', '--reload', action='store_true', dest='reload', + help=_('Reload terminator configuration')) + parser.add_argument('-v', '--version', action='store_true', dest='version', help=_('Display program version')) parser.add_argument('-m', '--maximise', action='store_true', dest='maximise', From 285022ef29bef2ae835230294e048c15225dc3cc Mon Sep 17 00:00:00 2001 From: Dante Calderon Date: Mon, 5 Dec 2022 20:37:57 -0500 Subject: [PATCH 2/2] Update comment --- terminator | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/terminator b/terminator index 5f5c33a3..c0891f31 100755 --- a/terminator +++ b/terminator @@ -112,8 +112,7 @@ if __name__ == '__main__': if(OPTIONS.reload): # Reload only is executed when exist at least one window, - # Check if exist another way to know if master process is not active. - dbg('reload option, killing app') + # if not there is nothing to reload sys.exit() except ipc.DBusException: