Goku has a concept called a simlayer. A simlayer allows you to press any single key on the keyboard, then any second key while holding the first and trigger an arbitrary action as a result. I’m going to write a karabiner.edn config that opens Firefox when you press .+f.

{:simlayers {:launch-mode {:key :period}},
 :templates {:open-app "open -a \"%s\""},
 :main
 [{:des "launch mode",
   :rules [:launch-mode [:f [:open-app "Firefox"]]]}]}
❯ goku
Done!

To start, we define a simlayer for the period key. We will reference this layer when we define our rules. Next we define a template. Each entry in :templates is a templated shell command that can run when a rule is satisfied. Finally, we define the “launch mode” rule in :main. We can call it anything we want, so I chose “launch mode”. Now let’s breakdown the rule

  • :launch-mode references the simlayer
  • [:f [:open-app "Firefox"]] is the rule. In this case, when f is pressed, we invoke the :open-app template passing “Firefox” as an argument. The shell commands that runs as a result is open -a "Firefox"

If we want to add more mappings for applications to launch with this simlayer, we can augment the rule like so

{:simlayers {:launch-mode {:key :period}},
 :templates {:open-app "open -a \"%s\""},
 :main
 [{:des "launch mode",
   :rules
   [:launch-mode
    [:f [:open-app "Firefox"]]
    [:s [:open-app "Spotify"]]
    [:i [:open-app "Cursor"]]
    [:c [:open-app "Calendar"]]]}]}

Lastly, let’s add another template and another rule in “launch mode” using that template, meaning we will still use the period key to trigger the rule.

{:simlayers {:launch-mode {:key :period}},
 :templates {:open-app "open -a \"%s\"", :open-url "open \"%s\""},
 :main
 [{:des "launch mode",
   :rules
   [:launch-mode
    [:f [:open-app "Firefox"]]
    [:s [:open-app "Spotify"]]
    [:i [:open-app "Cursor"]]
    [:c [:open-app "Calendar"]]
    [:a [:open-url "https://calendar.google.com"]]]}]}