Display mirroring with Hammerspoon
08 Dec 2025 in TIL
I need to mirror my screens periodically - enough that it's painful to go in to system settings each time and configure mirroring.
Here's a Hammerspoon snippet that will toggle mirroring. It works because allScreens returns a single value if your second screen is mirroring the first.
C34H89x and LC49G95T are my screen names, which I looked up in system settings.
luahs.hotkey.bind({ "cmd", "alt", "ctrl", "shift" }, "M", function()local screens = hs.screen.allScreens()if #screens == 1 thenscreens[1]:mirrorStop()elselocal screenToMirror = hs.screen.find("C34H89x")local screenToHide = hs.screen.find("LC49G95T")screenToHide:mirrorOf(screenToMirror)endend)