Configuring Docks in Gimp by editing the sessionrc config file.

Anyone who has used Gimp is familiar with the use of the toolbox and the docks that appear on the screen. People naturally have their own preferences about how to arrange these user interface elements. I worked for a long time with screens in landscape mode, with a dock on each side of the screen. The left hand one would consist solely of a layer list and the right hand one would have the toolbox at the top of it, and below it would be tool options, dashboard and error console, typically.

Since I changed recently to using a screen in portrait mode, I naturally have felt the best option for optimised use of screen real estate is to have the toolbox and two sets of tabs stacked vertically on just one side of the Gimp window. This turned out to be practically impossible to achieve from the GUI and so my thoughts quickly turned to editing Gimp’s configuration files to make this happen. It turns out this is relatively straightforward to achieve.

The first obstacle to overcome is to locate these configuration files. Gimp is commonly available on Linux in two particular forms: natively built packages supplied as part of a distro, or the flatpak edition, which is the official means of distribution by the Gimp Project itself. The flatpak option has the advantage of being updated more frequently than a lot of distros’ own packages, especially ones like Debian that prioritise stability and so have relatively fewer updates. Distro packages usually use the .config path in your home directory to store the configs. A typical path would be something like ~/.config/GIMP/<version>. However, flatpak editions have often used a different location that is flatpak specific: typically it will look like ~/.var/app/org.gimp.GIMP/config/GIMP/<version>. The Gimp Project is aware of concerns about duplicating the config files and has made various efforts to overcome this, and it seems likely the ~/.config/ path will be the one that will be standardised on in future.

Then the file we are looking for is called sessionrc (with no extension). As with any time you are planning to edit a configuration file, you should make a backup copy first before editing. Also, ensure that Gimp is closed, because the file is only read in when Gimp first loads, and when Gimp quits, it rewrites the whole file without prompting, erasing any previous contents. Editing the file while Gimp is open will not do anything to Gimp, and you’ll lose your changes when you quit Gimp.

In the sessionrc file, the layout of toolbox and docks is contained in a section of the file that is basically a subsection of something headed the following:

(session-info "toplevel"
    (factory-entry "gimp-single-image-window")

So as an example in the particular sessionrc file I have used, within that section of the file we can find these two subsections:

    (gimp-dock
        (side left)
        (book
            (current-page 0)
            (dockable "gimp-layer-list"
                (locked)
                (tab-style icon)
                (preview-size 32)
                (aux-info
                    (show-button-bar "true")))))

which refers to a dock by itself, that is on the left side, and has one tab which is a Layer List, and;

    (gimp-toolbox
        (side right)
        (book
            (current-page 0)
            (dockable "gimp-tool-options"
                (locked)
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-undo-history"
                (locked)
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-dashboard"
                (locked)
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")
                    (cpu-expanded "yes")
                    (memory-expanded "yes"))))))

which refers to a toolbox with a tab dock underneath it, that appears on the right hand side, and has the tabs Tool Options, Undo History and Gimp Dashboard docked to it.

It is important that you use an editor that can do bracket completion so that you can ensure you have closed the right number of brackets. The extra close bracket on the second (gimp toolbox) section is relevant to the fact that it is closing the “session-info” section because it is the last subsection of the “session-info” data structure. Whereas the gimp-dock subsection has one less bracket because it is not the last part of the “session-info “section. It is also important to ensure you have indented everything properly, rather like writing Python code. For the purpose of this discussion we don’t need to know the detailed syntax of every part of these data structures. All we need to be able to work out is how to put the subsections in the right places to be able to get the layout of docks and toolboxes we want, and then change the tabs and so forth we need later.

So for my requirement, which is a toolbox followed by two docks, all I need to do is have in the right part of sessionrc, something that looks like this:

(session-info "toplevel"
    (factory-entry "gimp-single-image-window")
    (position 0 133)
    (size 1440 2309)
    (open-on-exit)
    (aux-info
        (left-docks-width "218")
        (right-docks-width "5")
        (maximized "yes"))
    (gimp-toolbox
        (side left)
        (book
            (current-page 1)
            (dockable "gimp-tool-options"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-device-status"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-undo-history"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-image-list"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true"))))
        (book
            (position 224)
            (current-page 0)
            (dockable "gimp-undo-history"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-image-list"
                (tab-style icon)
                (aux-info
                    (show-button-bar "true")))
            (dockable "gimp-layer-list"
                (tab-style icon)
                (preview-size 32)
                (aux-info
                    (show-button-bar "true"))))))

This example has given me a toolbox with two docks under it. The section for a set of tabs in a dock is called a “book” in this file syntax. This is the actual file text after I have configured the tabs in each dock to what I want them to be, and dragged the widths and heights to what suits me best. To create this I started with a toolbox section that was on the left and had already a dock (book) below it, and then I simply copied the book section and pasted it back underneath itself to get two docks stacked vertically.

In actual use in computers I am now generally having tool options / error console / dashboard in the top dock, and layer list / undo list in the bottom one.