views:

1503

answers:

4

I wish to write a utility to auto-hide the menu bar, much like the dock. This would replicate the a OS X 10.4-only application "Menufela", but for Snow Leopard.

[[NSApplication sharedApplication]
     setPresentationOptions:   NSApplicationPresentationAutoHideMenuBar
                             | NSApplicationPresentationAutoHideDock];

This code auto-hides the menu bar (and dock), but only in when the application is the frontmost window. How would I go about applying this behaviour system wide, regardless of what application is open?

The only thing I can think of is an InputManager, but I haven't written one before, thus I'm unsure if this is the correct way to go about it..

Also it seems InputManagers are limited as of Leopard/Snow Leopard - from this SO question:

it won't run them in a process owned by root or whell, nor in a process which has modified its uid. Most significantly, 10.5 won't load an Input Manager into a 64 bit process and has indicated that even 32 bit use is unsupported and will be removed in a future release.

I'm not concerned about the "will be removed in a future release" (it just has to work on Snow Leopard), and I don't think root-owned processes are an issue (all GUI applications should be running as the current), but presumably the code would have to be injected into many 64-bit applications (Finder/Safari/etc)

(I originally asked this on SuperUser, here, but as there was seemingly no existing utility to achieve this, it's more relevant to StackOverflow)

+1  A: 

The kiosk API is probably your best bet for this, though I haven't used it in years and don't know if it's even supported anymore.

http://developer.apple.com/mac/library/technotes/tn2002/tn2062.html

Azeem.Butt
+1  A: 

I haven't used it on Snow Leopard myself, but the only way of injecting systemwide that even has a chance as far as I know is mach_star, and even that will be a bit tricky. Apple isn't making this easy these days, which is why a lot of the old hacks are failing to be updated either in a timely manner or at all.

Chuck
+1  A: 

This recent Cocoa With Love article has information on how to hide the menubar:

http://cocoawithlove.com/2009/08/animating-window-to-fullscreen-on-mac.html

However, using the CarbonAPI (SetSystemUIMode()) requires the app to be 32-bit and does not work outside the scope of the application.

Edit: and reading a bit further, it seems that this API doesn't do anything that -[NSApplication setPresentationOptions] can't do.

Dave DeLong
Since AppKit uses it, it probably doesn't carry any 32-bit requirements.$ strings /System/Library/Frameworks/AppKit.framework/AppKit | grep "SetSystemUIMode"-[%@ %s0x%lx] Call to SetSystemUIMode(0x%lx, 0x%lx) failed with result %ld
Azeem.Butt
A: 

I hacked together a small SIMBL plugin to hide the Menu Bar: http://github.com/Crazor/MenuBarHider It uses the SetSystemUIMode() Carbon call, which is not limited to 32bit apps.

It doesn't work with Carbon apps like Xcode. I tried the newly released Application Enhancer form Unsanity, but I failed to get anything to work with APE. But so far Xcode is the only app I use that my plugin doesn't work on ;)

Crazor