Skip to content

New feature: A Separate Json file for dynamic Layouts #213

Closed

Description

@dvdlevanon

Adding the following command line arguments

--layout path/to/layout.json

The Json file may provide an easy way to configure a collection of tabs and terminals using common pre-defined layouts, and also may support basic theming like background and text color.

This would allow to:

  1. Edit Layouts using a Text Editor instead of the "Preferences > Layouts" dialog.
  2. Share layouts easily between machines and people.
  3. A way to keep layouts under source control (git).

For years I used terminator and this feature was missing. so I wrote my own script that takes a list JSON files, representing layouts and profiles, and build a unified INI file for the terminator. Those files are also in the source control so my colleagues can use them easily.

Now that I see terminator is under active development again, I think of adding this feature to the code base. Would like to get your feedback and suggestions.

Activity

  1. mattrose commented on Sep 19, 2020

    @mattrose
    Member

    This sounds interesting. I think it might be better to have profiles defined in JSON rather than layouts. Profiles have the functionality that you need (judging from your description), and can contain layouts as well.

    Personally, I'd be very comfortable working on this with you as well, just because it would be a nice change from all the GUI programming I've been doing lately with trying to get background image support back, and definitely an area in which I'm more comfortable :)

  2. dvdlevanon commented on Sep 19, 2020

    @dvdlevanon
    ContributorAuthor

    Hi,

    Thanks for your response @mattrose, would be glad to work with you, I already started something and will have it ready for push soon, will share the PR.

    Regarding layout vs profiles, I might miss something, currently a .config file looks like:

    [profiles]
      [[Monitor]]
        allow_bold = False
        icon_bell = False
        background_color = "#100000"
        background_darkness = 0.93
        background_type = transparent
        font = Monospace 16
        foreground_color = "#DCDfff"
        show_titlebar = False
        scrollbar_position = hidden
        scrollback_lines = 3000
        scrollback_infinite = True
        use_system_font = False
    [layouts]
      [[Monitor]]
        [[[root]]]
          fullscreen = False
          last_active_window = True
          maximised = True
          order = 0
          parent = ""
          position = 1920:0
          size = 1920, 1080
          title = Monitor
          type = Window
        [[[tabs]]]
          active_page = 0
          labels = htop, cmus
          order = 0
          parent = root
          type = Notebook
        [[[htop]]]
          command = htop ; bash
          order = A
          parent = tabs
          type = Terminal
        [[[cmus]]]
          command = cmus ; bash
          order = B
          parent = tabs
          type = Terminal
    

    Seems like tabs+terminals are part of the layouts section, while profile holds things like colors and fonts. isn't it?

  3. mattrose commented on Sep 19, 2020

    @mattrose
    Member

    You know what, you're right. Profiles and Layouts are separate. For some reason I thought that Layouts were a subset of Profiles. Looking forward to your PR

  4. dvdlevanon commented on Sep 19, 2020

    @dvdlevanon
    ContributorAuthor

    Just pushed the initial PR, work is still in progress.
    #214

    I put some json files in here: https://github.com/dvdlevanon/terminator/tree/layout-json-file/layout-files-examples

    Example run:

    ./terminator --no-dbus --layout layout-files-examples/2-3-grid.json --maximise
    ./terminator --no-dbus --layout layout-files-examples/3-tabs-2-rows.json --maximise
    

    The --layout argument may be either a name of a layout from the global config file, or a path to a layout.json file.
    It first look for the layout name, like the regular behaviour of terminator, and only if it is missing it tries to look for a file.
    If the argument passed is indeed a file, the new LayoutFile.get_layout_file method will build a dict with the same format like in the ini file.
    This way it is both backward compatible with current logic, and pretty safe as no actual touching in the existing logic.

    Would like to hear your opinion and suggestions.

  5. dvdlevanon commented on Sep 19, 2020

    @dvdlevanon
    ContributorAuthor

    Here is a screenshot with this example:

    ./terminator --no-dbus --layout layout-files-examples/2-3-grid.json --maximise
    

    https://ibb.co/zFVBM55

  6. mattrose commented on Sep 20, 2020

    @mattrose
    Member

    That looks very clean on first glance, and thanks for the PR. Hopefully I'll be able to pull it down and play with it tomorrow, but more likely Monday.

  7. dvdlevanon commented on Sep 20, 2020

    @dvdlevanon
    ContributorAuthor

    @mattrose Noticed I just pushed my latest changes, and I slightly changed the interface due to the profile support that was added.

    Example run:

    ./terminator --config-json layout-files-examples/4-4-grid.json
    

    The --config-json parameter is a layer above the regular config file, it may contain a single layout and a single profile. both used by default if no other option is specified.

    It is possible for the user to create custom a layout, with custom colors and fonts in a single Json file. Then use it when opening terminator without touching the global config, using the new --config-json parameter.

    The Json file is pretty straightforward, its depth is unlimited and may contain very complex layouts with combination of tabs, horizental and vertical terminals.

  8. bitinerant commented on Sep 27, 2022

    @bitinerant

    I am excited about this feature but so far cannot find documentation and link above to some examples is broken. It would be great if a brief explanation and several examples could be added to https://gnome-terminator.readthedocs.io/en/latest/advancedusage.html

  9. bitinerant commented on Sep 27, 2022

    @bitinerant

    Update: I found one example .json file (source):

    {
    	"layout": {
            "vertical": false,
    		"tab1": [
    			{
                    "ratio": 0.7,
    				"children": [
    					{
    						"command": "bpytop;neofetch;bash"
    					},
    					{
    						"command": "neofetch;sleep 6;man terminator;bash"
    					}
    				]
    			},
    			{
    				"children": [
    					{
    						"command": "pyradio -p 16;bash",
                            "ratio": 0.6
    					},
    					{
    						"command": "cava;bash",
                            "ratio": 0.4
    					},
    					{
    						"command": "theme.sh -i2;bash"
    					}
    				]
    			}
    		]
    	},
    	"profile": {
            "font": "JetBrains Mono NL Regular 9"
    	}
    }
    
  10. FernandoBasso commented on Oct 24, 2022

    @FernandoBasso
    Contributor

    Just pushed the initial PR, work is still in progress. #214

    I put some json files in here: https://github.com/dvdlevanon/terminator/tree/layout-json-file/layout-files-examples

    That branch doesn't exist anymore, it seems. Here's a link to @dvdlevanon's master branch which currently also contains the examples.

    Thanks a lot for this work, @dvdlevanon. Much appreciated!

  11. mattrose commented on Oct 25, 2022

    @mattrose
    Member
  12. added a commit that references this issue on May 11, 2026
  13. added a commit that references this issue on May 14, 2026
  14. added a commit that references this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions