12

I use Terminator as a terminal emulator and I like it a lot, I would just like to do one thing and I haven't been able to find out how to do it.

So, I know how I can right-click, go to preferences, and select the color profile and font. Then when I'm done, the terminator instance that I accessed preferences from reflects the updates that I've just made (i.e. the colors/fonts are different). I'd like to be able to do this but by manually editing the configuration file at ~/.config/terminator/config and then having an active terminator session reload the config file, then reflect those changes without having to restart the emulator.

Is there a way to do this?--Some sort of command to send to terminator to tell it to reload itself from the config file without having to close the actual program? I feel like this should be possible because if I manually edit the configurations through the GUI, the changes are reflected without the process needing to be restarted.

3
  • 1
    Related: answers.launchpad.net/terminator/+question/173257
    – Wizek
    Commented Dec 15, 2016 at 16:17
  • @Wizek FWIW that's for the gtk2/vte2 version. The current version is the total rewrite for thegtk3/vte3, although the developer's philosophy is presumably consistent with that post.
    – Sparhawk
    Commented Mar 14, 2017 at 4:49
  • 2
    Also looking for this exactly same thing. For my purpose it is part of writing a script that interchanges dark/light themes on my most frequently apps instead of spending 5 mins every day doing it manually.
    – John Smith
    Commented Jun 18, 2019 at 23:08

3 Answers 3

2

Not a commandline solution, but you can open the Preferences dialog and close it to reload the config file manually without killing Terminator.

1
  • 3
    The question already states (multiple times) that they know how to do this.
    – Sparhawk
    Commented Jun 19, 2019 at 0:52
2

If you want to get into the source code and make your own solution - since terminator is written in python, it's quite easy to get into the source - I found the following:

In the terminatorlib, there is the module terminal.py: if you run the two following lines in the Terminal class, it has the desired effect.

self.config.base.reload()
self.reconfigure()

For example, you could put it in the on_buttonpress of the class Terminal, in the section handling the left button of the mouse event :

   if event.button == self.MOUSEBUTTON_LEFT:
            # Ctrl+leftclick on a URL should open it
            if self.config["link_single_click"] or event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
                # Check new OSC-8 method first
                url = self.vte.hyperlink_check_event(event)
                dbg('url: %s' % url)
                if url:
                    self.open_url(url, prepare=False)
                else:
                    dbg('OSC-8 URL not detected dropping back to regex match')
                    url = self.vte.match_check_event(event)
                    if url[0]:
                        self.open_url(url, prepare=True)
                    else:
                        dbg("No regex match, discard event.")
            self.config.base.reload()  # <------ reload config file
            self.reconfigure()         # <------ refresh terminal profile

terminatorlib was located at /usr/lib/python3.11/site-packages/terminatorlib on my machine but of course you can find it simply running : sudo find / -name terminatorlib .

UPDATE: It looks like they added this natively (this here); so either build from source or wait for the next release and you won't have to write any code for yourself :)

1

I just wrote this very blind/fragile script to programmatically move the mouse to go through the steps of changing the color scheme through the Terminator settings window using xdotool (sudo apt-get install xdotool). It moves the mouse by x,y coordinates on the screen and I found the x,y coordinates on my screen purely by trial and error - have no idea if the coordinates will be the same on other computers. I'm on Ubuntu 20.

#!/bin/bash

if [ "$1" != "light" ] && [ "$1" != "dark" ]; then
    echo "Need to pass \"light\" or \"dark\" as arg"
    exit 1
fi

xdotool mousemove 100 100
xdotool click 3
xdotool mousemove 140 350
xdotool click 1
xdotool mousemove 140 100
sleep 1
xdotool click 1
xdotool mousemove 420 140
xdotool click 1
xdotool mousemove 420 250
xdotool click 1


if [ "$1" = "light" ]; then
    xdotool mousemove 420 230
    xdotool click 1
else
    xdotool mousemove 420 280
    xdotool click 1
fi

xdotool mousemove 840 720
xdotool click 1

There are probably ways to use some Selenium-like tool for Linux (I think I've seen some described for Ubuntu that use OpenCV to parse the pixels of your screen to find coordinates of certain buttons) that will actually choose the buttons based on their text, but this is working for me now. Sharing in case anyone is stuck with this frustrating problem.

1
  • Upvoted. Very hacky, but I like it! You found a solution where no easy one existed. Commented Jan 21, 2023 at 7:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .