I built niri for macOS

Niri is a window manager for Linux. Instead of arranging windows in a grid, it lines them up on a horizontal strip you can scroll. All windows have the same height, and new ones appear next to the existing ones, so you end up with an endless canvas of windows.

The first time I tried this approach, it turned out to be far more comfortable than the usual way of managing windows. You don’t have to keep pressing Alt + Tab, hunt for the right window in a list, drag it with the mouse and resize it. If the window you need doesn’t fit on screen, you scroll the strip to it. And since all windows are the same height, you barely think about where they are.

macOS has a few window managers with a similar idea, but they all have drawbacks. They control windows through the Accessibility API, which lets third-party apps read and move other apps’ windows. Even the most capable of them, OmniWM, emulates vertical switching between workspaces with screenshots of windows.

My MacBook isn’t the newest, and when I run a lot of apps the system starts to lag. It’s especially annoying when the delay shows up even while switching windows.

Meanwhile, macOS’s own animations stay smooth. Switching Spaces or opening Mission Control, for example, rarely turns into a slideshow. It looks like system components get a different priority and have access to mechanisms that regular apps don’t.

What if I could control real windows?

Recently I came across a demo by @unixzii on Twitter. It animates windows in 3D, a bit like album covers on an old iPod.

The implementation is what hooked me. These are real macOS windows with real transforms, no screenshots or virtual copies.

Around the same time I saw a demo by @asciidiego with Compiz effects from Linux running on macOS. A window burns up when you close it, and Spaces switch by rotating a cube. That one is reverse engineering of the macOS compositor too.

You can’t get this with the tools macOS gives regular apps. The system itself can move and transform windows, and the animations in Mission Control and Stage Manager stay smooth even under load. So the mechanisms already exist somewhere inside macOS. I just had to reach them.

So the idea was to get straight into WindowServer and the system components that manage windows. With the same mechanisms macOS uses, the result could be just as smooth.

I figured it was time to try building my own niri-style window manager again. Claude had gotten smarter since my last attempt, so I started on a POC.

Torturing Claude again

I had been turning this idea over for several months. I already had examples of other macOS window managers and old proofs of concept that injected code into WindowServer and Dock. Nothing useful had come out of them before.

I started experimenting with Claude. As soon as I asked it to look into injecting code into WindowServer and managing window transforms from inside a system process, it blocked the session. I had to start over, maybe ten times.

Eventually I changed my approach. Instead of asking Claude to inject code into system processes right away, I suggested it first study how Yabai, AeroSpace and OmniWM work. Then we gradually went deeper into macOS internals, looking for the right functions.

After a few rounds of research we had enough information to start writing code. I asked Claude to save the results to docs/WINDOWSERVER.md so that later sessions could pick up where the earlier ones left off.

Reverse engineering macOS

I had to dig into private functions in Dock and WindowServer. Apple doesn’t document them, so we had to work out how they behave ourselves. Since this is reverse engineering of closed system components, nobody guarantees the code will keep working on future versions of the OS.

Apple changes macOS internals, function signatures and code layout between releases. So I’m not sure yet whether the project will work on macOS versions below 27. They may need all the research done over again.

There’s another catch. For any of this to work, you have to disable System Integrity Protection (SIP). It’s a macOS protection that stops anything from interfering with system components. Some companies don’t allow turning it off on work machines, so this window manager isn’t for everyone.

But for me it was worth it. Windows behave almost the way I wanted from niri on macOS. And I’m working with real system windows and their transforms instead of controlling them through the Accessibility API.

nori scrolls the strip, opens and moves windows, resizes a column, slides between Spaces and opens the overview

It’s past the experiment stage now. The current version does everything I need, and it’s my daily driver. I strongly recommend trying nori. It changes how the whole OS feels to use, for the better.

By the way, the bar in the video is homemade too. You can find it in my dotfiles and ask your agent to adapt it for you.

How to turn off SIP

You only need to turn off part of SIP, once, from Recovery. The app can’t do this step for you. If SIP is still on, nori shows these steps and copies the command for you.

  1. Shut the Mac down. Hold the power button until “Loading startup options” appears, then click Options → Continue and log in.

  2. In the menu bar choose Utilities → Terminal and run

    csrutil enable --without fs --without debug --without nvram
    csrutil enable --without fs --without debug --without nvram

    It warns about an unsupported configuration. That’s expected.

  3. Restart.

This turns off three protections. Without Debugging Restrictions the loader may call task_for_pid on Dock. Without NVRAM Protections the app can set the boot argument it needs. Without Filesystem Protections the app can grant itself Accessibility. The rest of SIP stays on.

This weakens the security of the whole Mac, so only do it on your own machine. The README explains how to undo it.