Recently, I posted about my Karabiner-Elements Complex Modification Rule to map a key to Escape. Here, I make a small tweak to use it to launch an application too!
In macOS, it's possible to set keyboard hotkeys for certain pre-defined tasks. Go to System Preferences > Keyboard > Shortcuts. Launching Activity Monitor is one of them, but try as I might, I can't get it to work for me, e.g.
So, Karabiner-Elements to the rescue!
Similar to my instructions in the previous post on Mapping a physical Escape key on a MacBookPro with Touch Bar - just add another keystroke combination and map "to"
to a "shell_command"
. Here I am using Control-Option-` to launch Activity Monitor.app.
Simply edit the rules element in the file ~/.config/karabiner/karabiner.json
:
…
"rules": [ {
"description": "A Grave Escape",
"manipulators":
[ {
"from": { "key_code": "grave_accent_and_tilde" },
"to": [ { "key_code": "escape" } ],
"type": "basic"
},{
"from": { "key_code": "grave_accent_and_tilde",
"modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "grave_accent_and_tilde" } ],
"type": "basic"
},{
"from": { "key_code": "grave_accent_and_tilde",
"modifiers": { "mandatory": [ "option", "command" ] } },
"to": [ { "key_code": "escape", "modifiers": [ "option", "command" ] } ],
"type": "basic"
},{
"from": { "key_code": "grave_accent_and_tilde",
"modifiers": { "mandatory": [ "option", "control" ] } },
"to": [ { "shell_command": "open -a '/Applications/Utilities/Activity Monitor.app'" } ],
"type": "basic"
} ]
} ]
…
Using this method you can map any application to the hotkey of your choice. Good luck!