Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add CLI command to reload configuration #690

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions terminator
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ if __name__ == '__main__':
import dbus
try:
dbus_service = ipc.DBusService()

if(OPTIONS.reload):
# Reload only is executed when exist at least one window,
# if not there is nothing to reload
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
Expand All @@ -121,6 +127,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)
Expand Down
11 changes: 11 additions & 0 deletions terminatorlib/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def new_tab(self, uuid=None):
"""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:
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions terminatorlib/optionparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down