Recently I’ve switched from using VMWare Fusion to Microsoft Remote Desktop for my windows needs (thanks a lot apple for screwing me over with the switch from intel). And one of the biggest problems that I’ve been struggling with has been that while VMWare Fusion does a remarkable job preventing the mac os menu bar from opening on your full screen VM, Microsoft Remote Desktop does no such favors. And it is annoying.
When trying to build/run my applications, I often go to the IDE menu bar. Where i run my mouse along the top of the screen until it ends up on the right option. But unfortunately, now that just means that I open the mac os menu bar. Want to close the browser, nah, you want to open mac os notification center (why is that even a thing). How about opening a file menu? no, you clearly meant to close your RDP window. There’s CLEARLY nothing else you could have intended.
After doing some internet research, my findings were
- There is no setting for mac os, hidden or otherwise, to configure how long it takes the menu bar to come down in full screen apps
- there’s clearly something hidden, because if you use citrix there’s some kind of citrix options that make it happen, but if you’re not using citrix too bad
- There’s no per app setting to configure the menu bar
- There’s a way to make the menu bar perpetually visible for full screen apps, but there is no way to make it perpetually hidden for full screen apps
The lengths which people go through to try and resolve this is astonishing. There’s someone who re-did the firefox’s CSS to move the tabs from the top of the screen to the bottom. There’s a paid app on the app store to change the color of the menu bar to “hide” it by just making it always visible, but in an ignorable color. And the closest to a working solution I found, a python script that runs a timer to check every tenth of a second where your mouse is, and move it away from the top of the screen so the menu wouldn’t open. Which someone found too infrequent, so people make it check more often. Trying to balance the frequency of their mouse checks with cpu usage.
Enter, solving the problem on my own.
By using the eventTap, you can monitor events on a global level to track the mouse, and move it if it’s too close to the top of the screen. Unlike the python solution, it doesn’t run when the mouse isn’t moving. And you aren’t trying to balance the resource utilization of your code with the potential of the timer not running often enough.
Rather than writing my own objective-c app for this like I’ve done in the past, or writing the same thing in swift, I decided instead to use Hammerspoon.
Hammerspoon is an app that allows you to write scripts for all sorts of stuff. It handles launching on startup, it can do keyboard or mouse things, it has a console to make debugging scripts faster than launching xcode, and it centralizes all sorts of scripts for things like this into a single app. And of course the most important feature of all, I’m already using it for other stuff.
Once Hammerspoon is installed, click on the menu icon and go to Open Config
which will open your init.lua
script in your editor.
You can configure Hammerspoon to not have a menu icon, in which case you will just have to open ~/.hammerspoon/init.lua
manually.
You can put all this code into its own file, and just import it into your init script if you want. That can help you to keep things isolated, but that’s up to you to google, because how you manage your scripts doesn’t really impact me. 🙂
This is what I’ve landed on as a script that keeps me happy enough.
It blocks the mouse from moving within the top 5 pixels of the screen. I found that to be the most consistent distance.
It uses the event tap so that it isn’t wasting resources. I’ve found that the cpu usage of this script is only about 1.4% while I am constantly moving my mouse. But since it uses the event tap, it doesn’t do anything if you aren’t moving your mouse.
The script works with multiple monitors, even if they aren’t aligned. And could easily be modified to make it so some applications block the menu bar from showing, and others don’t. I didn’t do that, because I realized that this solves the annoyance of teams opening the menu bar when I try to leave a meeting or unmute myself.
I also implemented a keyboard shortcut to disable the wall for when I actually do need to get the menu bar to come down. However, I found that I kept forgetting to re-enable it. So instead of doing shortcut to turn it off, shortcut to turn it on, I landed on using a timer, and mouse location to determine if I’ve “finished” having my mouse at the top of the screen.
Though its really easy to modify the script to work differently
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
-- prevent mouse from getting within the top x pixels of the screen to prevent the menu bar from appearing when undesirable blockedPixels = 5 bypass = false mouseEventTap = hs.eventtap.new({hs.eventtap.event.types.mouseMoved}, function(event) --todo: you could filter with hs.application.frontmostApplication() if you want to only block the menu for certain apps. I don't if(bypass) then local rel = hs.mouse.getRelativePosition() if(rel.y >= 30) then resetTimer:start() else resetTimer:stop() end else local rel = hs.mouse.getRelativePosition() if(rel.y < blockedPixels) then local frame = hs.mouse.getCurrentScreen():fullFrame() local abs = event:location() abs.y = frame.y + blockedPixels local newEvent = event:copy():location(abs) newEvent:post() return true end end end) mouseEventTap:start() --enable and disable the mouse event for when i want to get to the menu hs.hotkey.bind({"ctrl", "cmd", "alt"}, "space", function() if(bypass == true) then bypass = false else bypass = true local pos = hs.mouse.getRelativePosition() pos.y = 4 hs.mouse.setRelativePosition(pos) end end) --timer to re-enable, because i keep forgetting to turn it back on after i turn it off resetTimer = hs.timer.new(30, function() resetTimer:stop() bypass = false end) |
This is brilliant. Helps me when using Microsoft Remote Desktop to stop the macOS menu and title bar appearing when I’m accessing the menu of a Windows app inside the remote session. 👍