Created
November 8, 2025 00:42
-
-
Save rbreaves/1228e9f03955f5be84c478187c9e25d3 to your computer and use it in GitHub Desktop.
Block macOS menubar while in fullscreen (hammerspoon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ---------------------------------------------------------------------- | |
| -- 🚫 Block macOS menubar reveal in fullscreen by redirecting mouse | |
| ---------------------------------------------------------------------- | |
| local BLOCK_HEIGHT = 5 -- pixels from top edge | |
| local blockMenubar = true | |
| local checkInterval = 0.02 -- seconds (~50 Hz) | |
| local function blockMenu() | |
| if not blockMenubar then return end | |
| local pos = hs.mouse.getAbsolutePosition() | |
| local screen = hs.mouse.getCurrentScreen() | |
| local frame = screen:fullFrame() | |
| -- If mouse reaches top edge | |
| if pos.y <= (frame.y + BLOCK_HEIGHT) then | |
| local newY = frame.y + BLOCK_HEIGHT + 2 | |
| hs.mouse.setAbsolutePosition({ x = pos.x, y = newY }) | |
| -- Optional visual indicator | |
| -- hs.alert.closeAll(); hs.alert("Menubar blocked", 0.3) | |
| end | |
| end | |
| -- Run repeatedly | |
| if _G.menubarBlockTimer then _G.menubarBlockTimer:stop() end | |
| _G.menubarBlockTimer = hs.timer.doEvery(checkInterval, blockMenu) | |
| -- Toggle hotkey | |
| hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "M", function() | |
| blockMenubar = not blockMenubar | |
| hs.alert.show("Menubar Block: " .. (blockMenubar and "ON" or "OFF")) | |
| end) | |
| hs.alert.show("Menubar Block loaded ✅") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment