Start Apps in i3 with Keyboard Shortcuts


Here's how to start apps using i3 keyboard shortcuts. Or: How to make an i3 app switcher.

You have a tool, like your screenshot tool, flameshot that you want to start when pressing a global key combination.

Set Key Binding

You're in luck. i3 can help you. Pop open the config:

nvim ~/.config/i3/config

My i3 $mod is alt/cmd, so in order to set up the screenshot tool the same as the MacOS default, I could add a key binding for alt-shift-4:

bindsym $mod+Shift+4 exec --no-startup-id flameshot gui

App Switcher

But I reload the config, and I get an error:

ERROR: Duplicate keybinding in config file:
  state mask 0x9 with keysym 4, command "exec --no-startup-id flameshot gui, mode "default""

This is because I use the alt-shift-[number] combo of keys to move windows to different workspaces (eg, workspace 4).

In order to give me a different namespace for key combos, I can create a new mode -- a mode for picking apps. Add to i3/config:

set $app_picker App picker (f) flameshot

mode "$app_picker" {
    bindsym f exec --no-startup-id flameshot gui, mode "default"

    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+Shift+d mode "$app_picker"

This:

  • Creates a mode called "$app_picker".
  • To switch to that mode, binds a key combo of alt-shift-d.
  • When the mode is displayed, the i3bar will show "App picker (f) flameshot".
  • When in that mode, binds a key combo of f to run the command flameshot gui.
  • After running it, the mode is exited, back to "default" mode.
  • Instead of running a command, one can press 'enter' or 'esc' to exit back to "default" mode.

Reload that puppy, and now you have a key combo that can switch you into picking apps or running commands. Let your fingers delight in i3!