Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is there a way to NOT have a dock icon ?

Is it possible to turn off the dock icon for a process that runs with one today ?

I am running background scripts etc and the dock gets crowded even on a big screen. Is there a way to turn off the dock icon for an app/process ?

Posted on Oct 18, 2005 4:19 AM

Reply
6 replies

Oct 18, 2005 9:57 AM in response to Guy Facius

If the applications are the kind that are "packages", it should be possible to change them to "background" apps by adding a ' LSBackgroundOnly' key (with a string value of "1") to their "Info.plist" files. If the application does require some user interaction, such as presenting dialogue boxes, the ' LSUIElement' key would probably be a better choice (no "Dock" icon or application specific menu). For programmes that aren't "packages", the same thing might be possible by editing its "plst" resource in the resource fork. For more information on the keys, see this document.

To modify the "Info.plist" file, control-click the programme's "Finder" icon and choose "Show Package Contents" from the contextual menu. Navigate through the "the.app" > "Contents" folder, and open the "Info.plist" file in a text editor. Apart from a few keys with values consisting of "arrays" or "dict"(ionary) entries, most of the file's contents should consist of two line "key" - "value" pairs. Without interupting an existing "key" - "value" pair, insert these two lines and save the changes:<pre> <key>LSBackgroundOnly</key>
<string>1</string></pre>Then open the "the.app" > "Contents" > "MacOS" folder, and double click the executable file (or if that doesn't launch the app, call it from the command line). This is one way to make "launch services" aware of the changes to the "Info.plist" file.

Note that by forcing the app to the background, you will lose the ability to quit it using the usual methods.

The above methods change the programmes so that running in the background is a property of the application. An alternative method (though not recommended) to temporarily hide a programme's "Dock" icon is to move the running application to a different folder, restarting the "Dock" (eg using "Activity Monitor.app", AppleScript or the command line) and moving the application back to its original location.

Nov 11, 2005 1:17 AM in response to Tracy Montenegro

In principle, it should be possible to add either of the above keys indirectly using AppleScript. The terminal command ' defaults' can be used to modify ".plist" files, and AppleScript's "do shell script" can be used run terminal commands.

So at its most basic, as an example, try backing up your "TextEdit.app" (and quit it if it is running), then pasting this in to a "Script Editor.app" document (you must be logged in to an "admin" account):<pre>do shell script "defaults write /Applications/TextEdit.app/Contents/Info LSUIElement -string 1"
do shell script "/Applications/TextEdit.app/Contents/MacOS/TextEdit"</pre>However, it should be noted that once in a while, the ' defaults' command can cause a ".plist" file to be erased (that's why I suggested backing up "TextEdit.app" first). When this happened, it may have been when ' sudo' was used - it has happened to me a few times, but not every time, and not often enough to be able to figure out how to reproduce the bug reliably. Another factor is that sometimes, changes to the ".plist" file are not recognized by "Launch Services" so it may be necessary to include a ' lsregister' step in the script to make the change take effect (if the change was being made outside of a script, one might move the app, or duplicate it to get it to register). The ' defaults' command by default, leaves a ".plist" file with "600" permissions, whereas a typical ".plist" file has "664" or "644", and the new owner of the file will be the person running the script rather than what is probably "root" - so both "ownership" and "permissions" will have to be corrected (more steps for the script). But then again, they may not be an issue on a single-user machine...

So there are a few things to consider, depending on how thorough you want to be, but it is certainly possible.

btw, a correction is in order on my previous post - it appears that keyboard shortcuts may be effective even for an app with ' LSUIElement' set to "1" so it might be possible to quit the app using ⌘Q.

Jan 27, 2006 7:33 PM in response to biovizier

I was looking for the solution to this same question and followed your instructions, which worked great. I just have 2 questions.

First, after I execute the command in Terminal, when I go to quit it, it terminates the process, thereby quitting the program I just opened. How do I get out of Terminal without quitting the program?

Second, and most importantly: When I restart my computer, or log out and back in, these programs that I do not want to show in the dock open automatically, since they are login items. In doing so, they open in the dock. If I have to manually go in and open them from Terminal every time I log in, then its not worth it to get them out of the dock. Is there any way to have them automatically start up, but not go into the dock in doing so?

If it matters, the programs I'm currently trying to do this with are Stickies and Foldershare.

Thanks!

Philip

Jan 28, 2006 12:37 PM in response to fancypants

It should only be necessary to launch the modified programme from the command line once - and that's just a cheap trick to try to get "Launch Services" to re-read the "Info.plist" file since "opening" the ".app" programme the normal way doesn't usually do the job. Once the file is read, "Launch Services" will usually continue to use those values, which are presumably cached somewhere. But regarding your first question, if the programme is being launched from 'Terminal.app", the command can be executed using ' nohup' to prevent it from terminating when "Terminal.app" is quit, eg:<pre>nohup /Applications/TextEdit.app/Contents/MacOS/TextEdit 1>/dev/null &</pre>However, if "AppleScript" is used instead, this method doesn't seem to work with the ' do shell script' so I don't know if there is a way around having the AppleScript wait for the launched executable to finish, short of having a separate app-launching script to launch the app indirectly.

But hopefully, none of that will be necessary - based on a review of the wording in earlier post where I suggested making a backup of the programmes before trying to modify them, I suspect that the problem with the login items might be that the original, un-modified copies are the ones set to open automatically. The "loginwindow.plist" file uses "AliasData" data to keep track of "login items" (even if they are moved) so if the "copy" was the one that was modified, then the reference in the ".plist" file might still be pointing to the original. If that is the case, then all that should be necessary is to remove and re-add the programmes, making sure that the modified version is selected.

Is there a way to NOT have a dock icon ?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.