This is useful for changing the default F4 key that is bound to Spotlight to launch Alfred in macOS Big Sur.
Setup:
- Make sure you have Karabiner installed.
- Open
~/.config/karabiner/karabiner.json
. - Copy the
rules
object from below snippet and add it withinprofiles.complex_modifications
. The basic structure of yourkarabiner.json
file should look something like this:
{
"global": {
..........
},
"profiles": [
{
"complex_modifications": {
"parameters": {
..........
},
"rules": [
{
"description": "F4 to CMD+SPACE",
"manipulators": [
..........
- Pressing F4 should now launch Alfred instead of Spotlight!
Hope this helps!
Thank you for sharing this!
I couldn't figure out how to add this function to Karabiner by editing karabiner.json through the steps you provided. However, I'm unsure if that was because the steps provided are a bit unclear, or if my extremely limited knowledge of code is to blame.
After some unsuccessful tries of figuring out what code to put where, I found a perhaps simpler solution:
Voilà.
The necessary lines of code are added to my karabiner.json automatically, and as a bonus, I can easily remove these lines/this function by disabling the rule in settings. I have no idea if this solution is better in any way, but I decided to leave this here in case any code illiterate people has the same struggles in the future :)
Edit: I believe that one advantage from my solution is that the changes made persists across future updates of Karabiner.
I tried to roll everything back to see if there was something wrong with your code
as I noticed my updated karabiner.json had two elements which are not in the code you provided:After comparing the original, unchanged karabiner.json with my failed attempt and my successful attempt, I realised that my original mistake was not adding enough of the end brackets from your code. By copy pasting line 3 to 22 "between" the square brackets after "rules" (on line 19 in an original, unedited karabiner.json), it worked perfectly.
So no! Nothing wrong with the code. Just user error.
Again, thank you, shripadk!