Jorisvandijk.com

Future full-stack developer

Unkillable scratchpads in i3 window manager

How many times have you been going about your business having a wonderful time in your i3 window manager, when you forget that you're currently focussed on one of your scratchpads and not on the application you want to kill, when you absentmindedly press the key combination to terminate, resulting in closing your scratchpad?

Too many to count for me.

So there's a pretty simple solution to this, which essentially makes it impossible to close a scratchpad. If all your scratchpads are terminals (like mine), you can still close them by exiting the application running in them and then typing "exit" in the terminal itself. What you can not do however, is use your default i3 keybinding to close the scratchpad as it won't work on them anymore with the following command, which will replace your close/kill keybinding.

bindsym Mod4+q exec --no-startup-id [con_id="__focused__" instance="^(?!NAME).*$"] kill

In the above you can obviously change the keybinding to what you use to kill windows. The part that's important is the "NAME" part. This you should replace with the class name you assign to all your scratchpads. So for me it'd be:

bindsym Mod4+Escape exec --no-startup-id [con_id="__focused__" instance="^(?!floatterm).*$"] kill

No more having to reopen accidentally closed scratchpads!