SmartFinn / eve-ng-integration

integrates EVE-NG (aka UNetLab) with Linux desktop
http://git.io/eve-ng-integration
MIT License
322 stars 117 forks source link

Terminator new window / new tab behaviour #56

Open TheNetworkGuy opened 1 year ago

TheNetworkGuy commented 1 year ago

I like opening new tabs for each of my Telnet sessions instead of starting a new window for each device connection.

To accomplish this i've modified the code slightly with 2 changes:

First off i check if the Terminator process is already running. If this is the case, start a new instance for this terminal session. If there is a Terminator window then open a new tab on this window.

This behavior keeps my environment tidy and clean instead of having 7 different windows. Of course, we all have our preference but i would like to share my code on how I've modified this behavior. I can create a pull request as well but would like to know from the Dev's if this is beneficial to implement as the default for Terminator sessions.

All the next steps are edits in the eve-ng-integration file.

First off after all the imports, import the process_iter function.

from psutil import process_iter

Next up, modify the _terminal_emulator_cmd() function as so:

   def _terminal_emulator_cmd(self):
        if self.override_terminal:
            return self.override_terminal.split()
        elif self._is_command('x-terminal-emulator'):
            # go through a list of all processes
            for proc in process_iter():
                # If there's a match with the process name with Terminator
                if("terminator" in proc.name()):
                    # Start this terminal session with a new tab
                    return ['x-terminal-emulator', '--new-tab', '-e']
            else:
                # Start this terminal session with a new window
                return ['x-terminal-emulator', '-e']
        elif self._current_desktop('cinnamon', 'gnome', 'unity'):
           ...............