Running Dockless
While working on feature requests for DateLine recently, I needed to add the ability to run the app Dockless - that is, without a menu bar or Dock icon.
In 10.5 and later, you can simply add the following key to your info.plist file to let LaunchServices know that you want your app to run Dockless:
<key>LSUIElement</key> <true/>
But what if you want to be able to control in a preference item whether you app is Dockless or not?
It turns out that there is no Cocoa way to do this and some Carbon code is necessary. After a bit of Google Fu, I found this handy article at codesorcery. Thanks go to Justin for posing the question and to Dan who provided the actual code.
The problem with the above article, though, is that the definitive solution is only posted in the comments. So in the interests of making it easier to get your app running Dockless, I have tidied it up into a method snippet and posted it below.
- (void) setDockStatus { // this should be called from the application delegate's applicationDidFinishLaunching // method or from some controller object's awakeFromNib method // Neat dockless hack using Carbon from <a href="http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it" title="http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-...</a> if ([[NSUserDefaults standardUserDefaults] boolForKey:@"doShowInDock"]) { ProcessSerialNumber psn = { 0, kCurrentProcess }; // display dock icon TransformProcessType(&psn, kProcessTransformToForegroundApplication); // enable menu bar SetSystemUIMode(kUIModeNormal, 0); // switch to Dock.app [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@"com.apple.dock" options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifier:nil]; // switch back [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE]; } }

I've used the open-source utility StepMenus for years to enable torn-off main menus for apps running Dockless. It's an oldie, but a goodie. I recently recompiled it for 64-bit SL, so it can run in System Prefs without needing a relaunch of the app.
- reply
Submitted by Leland (not verified) on Tue, 02/23/2010 - 06:10.Hello.
I have the following problem.
I want to have app that is without dock icon but if you open the UI from tray status icon an application menu appears.
Now it seems that presense of Dock icon and App's Menu is tied together and the question is if there is a real way to make this happen: Have app without dock icon as agent but have App's menu visible while MainWindow got focus.
regards
- reply
Submitted by zden (not verified) on Wed, 01/20/2010 - 08:35.Hi zden,
As far as I am aware, there is no way to have a dockless app with a menu.
Regards,
Alex
- reply
Submitted by alex on Wed, 01/20/2010 - 09:04.Hi, Alex,
I think zden means the status bar menu. Actually, I have the same question. Without dock icon, how to make an application frontmost? You can not use command+tab to switch between applications(seems that only running application with docked icon will show in the switch list). But you can use Expose's All Windows to find your dockless application(by default, you just need to move your mouse to the right bottom corner of screen).
My try is: when dock is hidden, click a menu item in the status bar menu and invoke some method to make your main window topmost, but this does not work.
[yourMainWindow makeKeyAndOrderFront:sender];
I know one example with status bar menu and dock both configurable: CoverSutra. The show/hide dock and show/hide menu bar works well there.
So, if anybody has some idea, please tell me. Thanks.
- reply
Submitted by cool8jay (not verified) on Sat, 05/29/2010 - 03:18.Hi,
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
... may be what you are looking for.
Cheers,
Alex
- reply
Submitted by alex on Thu, 06/17/2010 - 07:00.You can just add the following key to info.plist in 10.6 and your app will run without a dock icon and menu.
"Application is agent (UIElement)" to YES
- reply
Submitted by Lene (not verified) on Sun, 11/08/2009 - 17:38.Hi,
I have updated this article to make it clearer that this is exactly the technique I am using, without having to read the referenced article on codesorcery.
Cheers
Alex
- reply
Submitted by alex on Fri, 12/04/2009 - 07:47.Post new comment