Skip to content

Instantly share code, notes, and snippets.

@raxigan
Created March 31, 2022 05:19
Show Gist options
  • Save raxigan/588bb3c97ec2a2a3b3042846fbf7fe51 to your computer and use it in GitHub Desktop.
Save raxigan/588bb3c97ec2a2a3b3042846fbf7fe51 to your computer and use it in GitHub Desktop.
Hammerspoon script to disable Mission Control on macOS
disableTopScreenEdgeForDragging = hs.eventtap.new({ hs.eventtap.event.types.leftMouseDragged }, function(e)
local loc = e:location()
if loc.y == 0.0 then
hs.mouse.setAbsolutePosition({ x = loc.x, y = 0.01 },
1337 -- a hack, do not remove
)
end
end)
disableTopScreenEdgeForDragging:start()
@homecb
Copy link

homecb commented Sep 4, 2024

Thanks for the additional info. Looks like I'll have to replace the keyboard.

@yrnehli
Copy link

yrnehli commented Sep 17, 2024

This script now interferes with macOS Sequoia's window tiling system, meaning it prevents windows from filling the screen when dragging to the top edge.

I have made a workaround for this by adding a new event listener on left mouse up:

function fill()
    hs.application.frontmostApplication():selectMenuItem({"Window", "Fill"})
end

function fillOnTopScreenDragging(e)
    if e:location().y == 0.0 then
        fill()
    end
end

hookLeftMouseUp = hs.eventtap.new({hs.eventtap.event.types.leftMouseUp}, fillOnTopScreenDragging)

hookLeftMouseUp:start()

@raxigan
Copy link
Author

raxigan commented Sep 18, 2024

Thanks for your update @yrnehli. Do you know if the original issue with window dragging and mission control activation is still there? I stopped using hammerspoon completely a while ago and the problem seems to be gone (at least for me). Not sure if it got fixed in some os update or I changed sth in my settings in the meanwhile. My last investigation of this issue was more than 2 years ago.

@yrnehli
Copy link

yrnehli commented Sep 18, 2024

@raxigan Yeah, the original issue is still present - you have to drag quite quickly and violently to the top of the screen but it still triggers mission control. It annoyingly interferes with the new native macOS tiling system...

The only other tool I've seen where you can disable this is BetterSnapTool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment