How to add Terminator as i3 WM scratchpad

Scratchpads in i3 are gems. They are very useful and handy and add more productivity compared with widgets. In fact, I am writing this post in a scratchpad (popup terminal) via Vim.

However, the downside of scratchpad is its difficulty to configure. It requires some hassle to get it working right. But after the first success adding more and configuring based on needs is a piece of cake.

Most of the available tutorials discuss on adding scratchpad that uses Urxvt. I initially started in that way but when reached to Urxvt configuration and saw it messed my Terminator I gave up and decided to make Terminator working and surprisingly it turns out to be easy.

Let’s get started.

To add any scratchpad regardless of what is used underneath, you need to edit i3 configuration file. This file is usually located at ~/.config/i3/config/. Now let’s assume that we want to add a scratchpad that opens a file in Vim inside an instance of Terminator on i3 startup hidden. To access and toggle to the instance, we use $mod + F1.

exec --no-startup-id terminator -c "vim" -e 'vim /tmp/test.txt'
for_window [instance="vim"] floating enable;
for_window [instance="vim"] move scratchpad; [instance="vim"] scratchpad show; move position 80px 50px; move scratchpad
bindsym $mod+F1 [instance="vim"] scratchpad show, resize set 1200 650

Now, let’s move to the explanation.

The first line tells i3 to execute an instance of Terminator that has a class name, using -c switch, vim assign to it. And then tells to the Terminator to runs vim /tmp/test.txt command using -e switch.

The reason for using the class name is to avoid manipulation of instances of Terminator and only target a single instance. Otherwise, any configuration in the next lines will be applicable to the entire Terminator instances, so be very careful about it.

The second line only enables floating mode for that instance of Terminator which is vim.

The third line is the most important line which applies multiple configurations. (1) Moves vim instance of Terminator to scratchpad area. (2) Sets the position of the scratchpad (80 px left, 50 px top).

And the last line sets the shortcut to toggle the scratchpad (Mod + F1) as well as setting the size of the scratchpad which in the above example is 1200x650.

Note: Don’t assign class name term to any Terminator scratchpad because it is a reserved keyword for any instances of Terminator created. As a result, the normal Terminator instance will not work properly. For instance, pressing (Mod + F1) instead of hiding the scratchpad, hides any Terminator instance regardless.

Leave a Reply