<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nix | Bas Nijholt</title><link>https://www.nijho.lt/tag/nix/</link><atom:link href="https://www.nijho.lt/tag/nix/index.xml" rel="self" type="application/rss+xml"/><description>Nix</description><generator>Hugo</generator><language>en-us</language><copyright>© 2026</copyright><lastBuildDate>Fri, 20 Nov 2026 00:00:00 +0000</lastBuildDate><image><url>https://www.nijho.lt/media/icon_hu_408a8f6cef43e327.png</url><title>Nix</title><link>https://www.nijho.lt/tag/nix/</link></image><item><title>Switching apps on macOS in under 30 ms ⚡</title><link>https://www.nijho.lt/post/macos-hotkey-app-switcher/</link><pubDate>Fri, 20 Nov 2026 00:00:00 +0000</pubDate><guid isPermaLink="false">/post/macos-hotkey-app-switcher/</guid><description>&lt;p&gt;I have an extreme obsession with productivity, and I address it on the micro level.&#10;For example, I almost exclusively voice-dictate my interactions with AI (I &lt;a href="https://www.nijho.lt/post/diction-agent-cli-qwen/"&gt;self-host the dictation&lt;/a&gt; too).&#10;When my hands are on the keyboard, they&amp;rsquo;re on a &lt;a href="https://www.nijho.lt/post/glove80-split-ergonomic-keyboard/"&gt;Glove80&lt;/a&gt;, the nerdiest variant you can get, with all black keys.&lt;/p&gt;&#10;&lt;p&gt;I also have a deep obsession with declarative tools.&#10;Whenever I set up a new VM, a computer at home, or a new MacBook, I want the entire process to be reproducible and fast.&#10;That ties in with my love for &lt;a href="https://www.nijho.lt/post/proxmox-to-nixos/"&gt;NixOS&lt;/a&gt;, and it&amp;rsquo;s why my &lt;a href="https://www.nijho.lt/post/dotfiles/"&gt;dotfiles&lt;/a&gt; are public.&#10;Keyboard Maestro didn&amp;rsquo;t fit that, so I replaced it.&lt;/p&gt;&#10;&lt;p&gt;This post is about &lt;a href="https://github.com/basnijholt/macos-hotkey-app-switcher" target="_blank" rel="noopener"&gt;&lt;code&gt;macos-hotkey-app-switcher&lt;/code&gt;&lt;/a&gt;, which I believe to be one of the fastest and simplest hotkey app switchers for macOS.&#10;I built it end to end in &lt;a href="https://www.nijho.lt/post/mindroom/"&gt;MindRoom&lt;/a&gt;, my &lt;a href="https://github.com/mindroom-ai/mindroom" target="_blank" rel="noopener"&gt;open-source&lt;/a&gt; agent platform.&#10;It reads its hotkeys from a plain text file, and on my M2 MacBook it brings an app to the front in a median of 29 ms.&lt;/p&gt;&#10;&lt;aside class="callout callout-note"&gt;&lt;svg class="ico" viewBox="0 0 256 256" aria-hidden="true"&gt;&lt;path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"/&gt;&lt;/svg&gt;&lt;div&gt;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;I used Keyboard Maestro almost only for app hotkeys, and it was one of the last things on my Mac I couldn&amp;rsquo;t configure from a text file.&lt;/li&gt;&#10;&lt;li&gt;AppleScript was much slower, so I had an agent find which macOS call Keyboard Maestro makes and build a small Swift replacement installed by nix-darwin.&lt;/li&gt;&#10;&lt;li&gt;AppKit&amp;rsquo;s supported &lt;code&gt;activate&lt;/code&gt; call turned out to be just as fast as Keyboard Maestro&amp;rsquo;s deprecated Carbon call: the speed comes from not starting a new process on every key press.&lt;/li&gt;&#10;&lt;/ul&gt;&lt;/div&gt;&lt;/aside&gt;&#10;&lt;details class="toc" open&gt;&lt;summary&gt;Table of contents&lt;/summary&gt;&lt;nav id="TableOfContents"&gt;&#10; &lt;ul&gt;&#10; &lt;li&gt;&lt;a href="#four-commands-to-a-new-mac"&gt;Four commands to a new Mac&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#how-i-switch-apps"&gt;How I switch apps&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#why-not-applescript"&gt;Why not AppleScript&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#what-keyboard-maestro-actually-does"&gt;What Keyboard Maestro actually does&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#building-the-replacement"&gt;Building the replacement&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#testing-the-alternatives"&gt;Testing the alternatives&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#how-fast-it-is"&gt;How fast it is&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#how-it-fits-in-my-config"&gt;How it fits in my config&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#what-it-doesnt-do"&gt;What it doesn&amp;rsquo;t do&lt;/a&gt;&lt;/li&gt;&#10; &lt;li&gt;&lt;a href="#conclusion"&gt;Conclusion&lt;/a&gt;&lt;/li&gt;&#10; &lt;/ul&gt;&#10;&lt;/nav&gt;&lt;/details&gt;&#10;&#10;&lt;h2 id="four-commands-to-a-new-mac"&gt;Four commands to a new Mac &lt;a class="anchor" href="#four-commands-to-a-new-mac" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Whenever I set up a new laptop, I run about four commands in the terminal.&#10;One installs my &lt;a href="https://github.com/basnijholt/dotfiles" target="_blank" rel="noopener"&gt;dotfiles&lt;/a&gt;.&#10;One loads my &lt;span class="hover-tip" data-tooltip="A private key used to decrypt files. My SSH keys and other secrets live in a private repository encrypted with it." tabindex="0"&gt;GPG key&lt;/span&gt;, to decrypt my secrets, like SSH keys and such.&#10;One installs &lt;span class="hover-tip" data-tooltip="Nix for macOS system configuration: the apps, settings and background services of the whole Mac are declared in one config file." tabindex="0"&gt;nix-darwin&lt;/span&gt;.&#10;And finally a Nix switch command, and everything is the way I want it to be.&lt;/p&gt;&#10;&lt;p&gt;However, there were a couple of holdouts.&#10;One of them was &lt;a href="https://www.keyboardmaestro.com/" target="_blank" rel="noopener"&gt;Keyboard Maestro&lt;/a&gt;, which is a fantastic application.&#10;It&amp;rsquo;s paid, and I paid for it.&#10;But I almost exclusively used it to map keys on my keyboard to rapidly switch between apps.&#10;Its macros are made in its own app, not in a text file I can keep in my dotfiles.&lt;/p&gt;&#10;&lt;h2 id="how-i-switch-apps"&gt;How I switch apps &lt;a class="anchor" href="#how-i-switch-apps" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;m a furious multitasker, so I have many things open at once.&#10;I don&amp;rsquo;t want to look like a &lt;a href="https://www.nijho.lt/post/glove80-split-ergonomic-keyboard/"&gt;mad person clicking Command-Tab&lt;/a&gt; all the time to switch between apps.&lt;/p&gt;&#10;&lt;p&gt;So what I have is one key.&#10;If I hold my &lt;code&gt;Home&lt;/code&gt; key, which is under my pinky, plus another key like &lt;code&gt;B&lt;/code&gt;, I go to the Brave browser.&#10;&lt;code&gt;Home&lt;/code&gt; + &lt;code&gt;T&lt;/code&gt; is my terminal.&#10;&lt;code&gt;Home&lt;/code&gt; + &lt;code&gt;M&lt;/code&gt; is the MindRoom app.&#10;My Glove80 firmware turns holding &lt;code&gt;Home&lt;/code&gt; into &lt;code&gt;Ctrl&lt;/code&gt; + &lt;code&gt;Alt&lt;/code&gt; + &lt;code&gt;Shift&lt;/code&gt;, and I have 14 of these bindings.&#10;The same ones live in my Hyprland config on Linux.&lt;/p&gt;&#10;&lt;h2 id="why-not-applescript"&gt;Why not AppleScript &lt;a class="anchor" href="#why-not-applescript" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Typically people suggest using an &lt;span class="hover-tip" data-tooltip="Apple&amp;#39;s scripting language for controlling Mac apps. Running a script starts a new process, compiles it, and sends a message to the app." tabindex="0"&gt;AppleScript&lt;/span&gt; like &lt;code&gt;tell application &amp;quot;Brave Browser&amp;quot; to activate&lt;/code&gt;, or &lt;code&gt;open -b &amp;lt;bundle id&amp;gt;&lt;/code&gt;.&#10;I did not find those reliable, and they were quite slow compared to Keyboard Maestro.&#10;Karabiner-Elements can bind app hotkeys from a file too, often via &lt;code&gt;open -b&lt;/code&gt; or its &lt;code&gt;open_application&lt;/code&gt; action, but I didn&amp;rsquo;t want a verbose JSON config just for 14 bindings.&lt;/p&gt;&#10;&lt;p&gt;So what did I do?&#10;I used a reverse engineering tool to figure out what mechanism Keyboard Maestro actually uses.&lt;/p&gt;&#10;&lt;h2 id="what-keyboard-maestro-actually-does"&gt;What Keyboard Maestro actually does &lt;a class="anchor" href="#what-keyboard-maestro-actually-does" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;I asked my agent in MindRoom to use &lt;a href="https://github.com/morluto/rea" target="_blank" rel="noopener"&gt;REA&lt;/a&gt;, a tool that lets AI agents reverse engineer apps and binaries, on Keyboard Maestro.&#10;The Claude Opus 5.5 subagent it handed this to declined straight away, because it was asked to disassemble a commercial binary.&#10;So I switched to a more willing model.&#10;I gave it a prompt that asked for static analysis only, for interoperability, without launching or patching anything and skipping all licensing and registration code&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;.&#10;A quick check with &lt;code&gt;nm&lt;/code&gt; and &lt;code&gt;strings&lt;/code&gt; already turned up the candidate APIs.&#10;To see which path actually runs, it ran REA with &lt;span class="hover-tip" data-tooltip="A free reverse engineering suite from the NSA that turns machine code back into readable assembly and C-like code." tabindex="0"&gt;Ghidra&lt;/span&gt; on a copy of the Keyboard Maestro Engine binary and wrote a report&lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#10;&lt;p&gt;Keyboard Maestro registers its global hotkeys with Carbon&amp;rsquo;s &lt;code&gt;RegisterEventHotKey&lt;/code&gt;, which needs no Accessibility permission.&#10;When a hotkey fires, it calls &lt;code&gt;SetFrontProcessWithOptions&lt;/code&gt;, an old &lt;span class="hover-tip" data-tooltip="Apple&amp;#39;s older C interfaces for Mac apps, from the classic Mac OS era. Many are deprecated but still work." tabindex="0"&gt;Carbon&lt;/span&gt; function that brings the app to the front with all its windows.&#10;Apple deprecated &lt;code&gt;SetFrontProcessWithOptions&lt;/code&gt; in 2013, but it still works.&#10;There&amp;rsquo;s no AppleScript involved, and the app doesn&amp;rsquo;t have to answer anything.&lt;/p&gt;&#10;&lt;h2 id="building-the-replacement"&gt;Building the replacement &lt;a class="anchor" href="#building-the-replacement" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;From that report, my agent had Claude Opus 5.5 write a small Swift program that stays running in the background and does the same thing.&#10;The first working version took just a couple of prompts, and my main instruction was one line:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;i want to have something that i can just configure with a text file. declaratively&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;Then GPT-6.2 Sol reviewed it and found bugs.&#10;The worst one would have broken my MindRoom key: the tool read any value ending in &lt;code&gt;.app&lt;/code&gt; as a file path, so the &lt;span class="hover-tip" data-tooltip="The unique name macOS uses for an app, like com.brave.Browser. It stays the same when the app is renamed or moved." tabindex="0"&gt;bundle ID&lt;/span&gt; &lt;code&gt;chat.mindroom.app&lt;/code&gt; was never looked up as an app.&lt;/p&gt;&#10;&lt;p&gt;It took one afternoon to go from my first message to a public repo with CI, a Homebrew formula, and a nix-darwin module.&lt;/p&gt;&#10;&lt;h2 id="testing-the-alternatives"&gt;Testing the alternatives &lt;a class="anchor" href="#testing-the-alternatives" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;I had assumed the deprecated Carbon call was what made Keyboard Maestro fast.&#10;Apple can remove a deprecated function in any macOS release, so I had an agent benchmark nine ways to bring an app to the front from a background process&lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#10;&lt;p&gt;AppKit&amp;rsquo;s supported &lt;span class="hover-tip" data-tooltip="The Swift and Objective-C interface for a running app. Its activate method asks macOS to bring that app to the front." tabindex="0"&gt;`NSRunningApplication.activate`&lt;/span&gt;, with the option to bring all windows, turned out to be just as fast.&#10;In every run it came within about 3 ms of &lt;code&gt;SetFrontProcessWithOptions&lt;/code&gt;, sometimes faster and sometimes slower.&#10;The raw activation calls, timed without a hotkey press, had already hinted at it: 20.8 ms for &lt;code&gt;SetFrontProcessWithOptions&lt;/code&gt; versus 23.1 ms for AppKit&amp;rsquo;s &lt;code&gt;activate&lt;/code&gt;.&#10;Since macOS 14, the OS can refuse an activation request from a background app, for example right after you type into the frontmost window.&#10;In 480 test switches across the benchmarked methods, with typing right before each switch, macOS never refused.&#10;So the tool now uses AppKit&amp;rsquo;s &lt;code&gt;activate&lt;/code&gt; call instead.&lt;/p&gt;&#10;&lt;p&gt;That points to the real reason Keyboard Maestro feels instant: it stays resident and makes one in-process call, whichever activation API it uses.&#10;&lt;code&gt;osascript&lt;/code&gt; starts a new process for every key press, compiles the script, and sends an &lt;span class="hover-tip" data-tooltip="The message system Mac apps use to talk to each other. The sender waits until the receiving app answers." tabindex="0"&gt;Apple Event&lt;/span&gt; that the app has to answer.&#10;&lt;code&gt;open -b&lt;/code&gt; also starts a new process every time.&lt;/p&gt;&#10;&lt;h2 id="how-fast-it-is"&gt;How fast it is &lt;a class="anchor" href="#how-fast-it-is" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;These are the medians from synthetic key press to app in front, on my M2 MacBook&lt;sup id="fnref:4"&gt;&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref"&gt;4&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#10;&lt;div class="table-wrap"&gt;&#10;&lt;table&gt;&#10;&lt;thead&gt;&#10;&lt;tr&gt;&#10;&lt;th&gt;Method&lt;/th&gt;&#10;&lt;th style="text-align: right"&gt;Median&lt;/th&gt;&#10;&lt;th&gt;Benchmark run&lt;/th&gt;&#10;&lt;/tr&gt;&#10;&lt;/thead&gt;&#10;&lt;tbody&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&lt;code&gt;macos-hotkey-app-switcher&lt;/code&gt; (AppKit, current)&lt;/td&gt;&#10;&lt;td style="text-align: right"&gt;29.3 ms&lt;/td&gt;&#10;&lt;td&gt;Nov 20 head-to-head&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&lt;code&gt;macos-hotkey-app-switcher&lt;/code&gt; (Carbon, earlier)&lt;/td&gt;&#10;&lt;td style="text-align: right"&gt;26.6 ms&lt;/td&gt;&#10;&lt;td&gt;Nov 20 head-to-head&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&lt;code&gt;open -b &amp;lt;bundle id&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&lt;td style="text-align: right"&gt;58 ms&lt;/td&gt;&#10;&lt;td&gt;Nov 19 baseline&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&lt;code&gt;osascript -e 'tell application id &amp;quot;…&amp;quot; to activate'&lt;/code&gt;&lt;/td&gt;&#10;&lt;td style="text-align: right"&gt;112 ms&lt;/td&gt;&#10;&lt;td&gt;Nov 19 baseline&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;That&amp;rsquo;s about twice as fast as &lt;code&gt;open -b&lt;/code&gt;, and nearly four times as fast as AppleScript.&#10;I didn&amp;rsquo;t time Keyboard Maestro&amp;rsquo;s full hotkey path, or other resident launchers like Hammerspoon or Raycast.&#10;They also avoid spawning a process per key press, so they should be in the same ballpark.&#10;The difference here is scope: this tool is one Swift file of under 300 lines, with no dependencies, no Accessibility permission, and no UI.&lt;/p&gt;&#10;&lt;h2 id="how-it-fits-in-my-config"&gt;How it fits in my config &lt;a class="anchor" href="#how-it-fits-in-my-config" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The config is one line per hotkey.&#10;These are my bindings:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Format: modifiers+key = bundle id (or an app path, which must contain a /). Saved changes apply at once.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Taken from the Keyboard Maestro &amp;#34;Open Apps&amp;#34; group (all windows, reopen windows, leave it at the front).&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.1password.1password # 1Password&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.t3tools.t3code # T3 Code&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.brave.Browser # Brave Browser&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.apple.iCal # Calendar&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.apple.mail # Mail&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+g&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.google.Chrome # Google Chrome&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;chat.mindroom.app # MindRoom&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.spotify.client # Spotify&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.tinyspeck.slackmacgap # Slack&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.googlecode.iterm2 # iTerm2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.todesktop.230313mzl4w4u92 # Cursor&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+v&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.microsoft.VSCode # Visual Studio Code&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;com.openai.codex # Codex&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;ctrl+alt+shift+z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;us.zoom.xos # Zoom&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The tool watches the file, so saving it applies the change right away.&lt;/p&gt;&#10;&lt;p&gt;My &lt;a href="https://github.com/basnijholt/dotfiles/blob/main/configs/macos-hotkey-app-switcher/hotkeys.conf" target="_blank" rel="noopener"&gt;hotkeys file&lt;/a&gt; lives in my dotfiles.&#10;nix-darwin installs the tool and starts it as a &lt;span class="hover-tip" data-tooltip="The macOS service manager. A launchd agent is a background program that starts when you log in." tabindex="0"&gt;launchd&lt;/span&gt; agent:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-nix" data-lang="nix"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;macos-hotkey-app-switcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;github:basnijholt/macos-hotkey-app-switcher&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# ...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;macos-hotkey-app-switcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don&amp;rsquo;t use Nix, Homebrew works too:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;brew install basnijholt/tap/macos-hotkey-app-switcher&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;brew services start macos-hotkey-app-switcher&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now my app hotkeys come with those four commands too.&lt;/p&gt;&#10;&lt;h2 id="what-it-doesnt-do"&gt;What it doesn&amp;rsquo;t do &lt;a class="anchor" href="#what-it-doesnt-do" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;It only switches apps.&#10;Keyboard Maestro does hundreds of other things, and it&amp;rsquo;s still the tool I&amp;rsquo;d recommend for anything beyond this.&#10;If you keep it, turn off its app hotkeys first, because macOS lets two apps hold the same key and then both fire.&lt;/p&gt;&#10;&lt;h2 id="conclusion"&gt;Conclusion &lt;a class="anchor" href="#conclusion" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;I reverse engineered Keyboard Maestro to copy its trick, and the tool ended up not needing it.&#10;Staying running in the background and making one call is enough, and my app hotkeys now live in my dotfiles like everything else.&lt;/p&gt;&#10;&lt;div class="footnotes" role="doc-endnotes"&gt;&#10;&lt;hr&gt;&#10;&lt;ol&gt;&#10;&lt;li id="fn:1"&gt;&#10;&lt;p&gt;Before writing this post (checked on 2026-11-20), I looked for whether Keyboard Maestro&amp;rsquo;s license forbids this kind of analysis and couldn&amp;rsquo;t find an app license agreement at all. I bought Keyboard Maestro 11 directly from Stairways Software (through FastSpring), not from the Mac App Store. The 11.1.1 download, the store page, and the wiki state only that a license is per user, for up to five Macs, and for one major version. The app bundle&amp;rsquo;s license folder holds only the licenses of open-source libraries it uses, and my tool contains no Keyboard Maestro code.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:2"&gt;&#10;&lt;p&gt;The analysis ran on Keyboard Maestro Engine 11.1.1, on the arm64 slice of a copied binary (&lt;code&gt;lipo -thin arm64&lt;/code&gt;), with the REA CLI (&lt;code&gt;search&lt;/code&gt;, &lt;code&gt;xrefs&lt;/code&gt;, &lt;code&gt;function&lt;/code&gt;) and Ghidra 12.2. Nothing was launched or patched. The report traced the action from &lt;code&gt;AActivateApplication::DoAction&lt;/code&gt; through Keyboard Maestro&amp;rsquo;s own &lt;code&gt;activateWithOptions:&lt;/code&gt; wrapper to &lt;code&gt;GetProcessForPID&lt;/code&gt; and &lt;code&gt;SetFrontProcessWithOptions&lt;/code&gt;, and found that &amp;ldquo;all windows&amp;rdquo; maps to flag &lt;code&gt;0&lt;/code&gt; and &amp;ldquo;one window&amp;rdquo; to flag &lt;code&gt;1&lt;/code&gt; (&lt;code&gt;kSetFrontProcessFrontWindowOnly&lt;/code&gt;).&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:3"&gt;&#10;&lt;p&gt;Measured on 2026-11-20 on the M2, macOS 26.5.2, 30 rounds per method and condition, from a background launchd job, between two test apps and between TextEdit and Calculator. &lt;code&gt;NSWorkspace.openApplication&lt;/code&gt; and &lt;code&gt;LSOpenCFURLRef&lt;/code&gt; were 1 to 24 ms slower and raised only one window. Setting the app&amp;rsquo;s &amp;ldquo;frontmost&amp;rdquo; attribute through the Accessibility API needs a permission grant. On macOS 13 the tool also sets the older &lt;code&gt;activateIgnoringOtherApps&lt;/code&gt; option, which macOS 14 and later ignore. Private SkyLight functions were not considered.&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:4"&gt;&#10;&lt;p&gt;Measured on an M2 MacBook using two small test apps switched back and forth 30 times per method with synthetic key presses, timed until the app was in front with its window on top. On 2026-11-19 (the baseline run), the earlier Carbon build measured 26 to 28.3 ms across revisions against 57.5 ms for &lt;code&gt;open -b&lt;/code&gt; and 112 ms for &lt;code&gt;osascript&lt;/code&gt;. On 2026-11-20, the current AppKit build measured 29.3 ms against 26.6 ms for the Carbon build in the same head-to-head run, which is within the spread between runs.&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/div&gt;&#10;</description></item><item><title>ZFS Unlock</title><link>https://www.nijho.lt/project/zfs-unlock/</link><pubDate>Mon, 29 Jun 2026 00:00:00 +0000</pubDate><guid isPermaLink="false">/project/zfs-unlock/</guid><description/></item><item><title>dotfiles</title><link>https://www.nijho.lt/project/dotfiles/</link><pubDate>Fri, 19 Apr 2019 00:00:00 +0000</pubDate><guid isPermaLink="false">/project/dotfiles/</guid><description/></item></channel></rss>