Show/Hide Application Icon in Dock

8

2

Is there away to toggle an Application Icon in the OS X Dock? Specifically I was hoping to be able to use the 'deafults' command to toggle something within the given application.

cynicaljoy

Posted 2010-12-02T17:30:19.673

Reputation: 215

Is this only while the program is not running, or only when running, or always? – Arjan – 2010-12-02T19:13:36.017

Answers

5

If you want to remove the icon when the application is not running:

Click and hold (drag) it from the Dock, and release it somewhere else. If the application is running, the icon will move back to the Dock, but will disappear whenever you quit the application. If it's not running, the icon will disappear in a "cloud of smoke".

Alternatively, right-click the application icon in the Dock, and select Options, then toggle Keep in Dock.

If you want to also hide the icon when the application is running:

There is a way, but is presents two problems:

  1. The application no longer has a menubar
  2. The application does no longer appear in the Cmd-Tab list of programs

The application still responds to keyboard shortcuts defined for menu items, so if you're comfortable controlling the application only using these, it's possible.

It looks a bit like what opens when you select the "[Program Name] Help" menu item in the Help menu.


To accomplish it:

You need to edit the file Info.plist in the application's bundle. To do this, right-click the application and choose "Show Package Contents". Navigate to Contents, and edit Info.plist.

The file format is usually XML, which you can edit with any plain text editor, such as TextWrangler, BBEdit, TextMate, or even TextEdit.

Insert the following lines directly after the line containing <dict>:

<key>LSUIElement</key>
<true/>

Save the file and restart the application.


In case the file format is not XML, but binary (the binary file starts with bplist, followed by binary "junk"), you need Property List Editor, which is part of Apple's developer tools (you can, of course, always use PLE if you have it installed)

Open the file in PLE, and select "Add Item". Type "Application is agent (UIElement)", which will autocomplete. Check the value box, and save.

Daniel Beck

Posted 2010-12-02T17:30:19.673

Reputation: 98 421

I guess it's worth noting that whilst this works so long as the app is open, if you minimise the app it will now appear next to the folders and trash with a screen preview rather than an icon. – Steve – 2016-07-24T10:46:17.800

@Steve This question is about applications, your comment is about windows. There's a difference between applications and windows on OS X that is far more pronounced than on Windows or Linux: An application has a single dock icon, can generally only have one instance running (you can't start another copy of it), and can have any number of windows. – Daniel Beck – 2016-07-24T19:26:35.797

I might undo the change because of this result, I think it's worth noting, didn't happen before hiding the icon. – Steve – 2016-07-24T22:58:41.533

Very rarely, property list files are a third format. It's considered obsolete, and I don't know what you need to enter to accomplish this in that other format. – Daniel Beck – 2010-12-02T19:06:13.123

I guessed other .plist formats might be converted using plutil, but that only knows of 2 formats too.

– Arjan – 2010-12-02T19:12:55.893

@Arjan Property List Editor can read that third format, "Text Property List" (the others being XML and Binary), and even has an option to save in that format, but it's not implemented. It's an interesting idea though, and it just might work. – Daniel Beck – 2010-12-02T19:38:25.393

Thanks, editing the Info.plist is simple enough. Love the fact that it doesn't appear in the Application Switcher as well. – cynicaljoy – 2010-12-02T21:01:05.770

@Daniel You can convert between xml and plain text plists with pl. – Lri – 2011-03-09T00:02:20.223

@Lri Is there an advantage over @Arjan's plutil? – Daniel Beck – 2011-03-09T00:10:13.167

@Daniel plutil only supports xml1 and binary1. And (in Lion DP?) json. Plain text .plists still work fine most of the time, but they are often converted to binary or xml when they are modified. – Lri – 2011-03-10T16:24:15.670

@Lri Now I understand, OK. That format has been deprecated long ago, I'm not sure it's that useful anymore. – Daniel Beck – 2011-03-10T18:10:11.287

It seems this might also break the code signing signature: "a code signature consists of three parts: [...] A seal, which is a collection of checksums or hashes of the various parts of the code, such as the identifier, the Info.plist, the main executable, the resource files, and so on. The seal can be used to detect alterations to the code and to the app identifier." This might yield problems when running updates, or for firewall rules, I think.

– Arjan – 2013-08-16T10:02:18.937

From the command line: first make a backup, sudo cp -a /Applications/MyApplication.app/Contents/Info.plist /Applications/MyApplication.app/Contents/Info.plist.orig Next, sudo defaults write /Applications/MyApplication.app/Contents/Info.plist LSUIElement 1 and after that, make the file readable by everyone again: sudo chmod o+r /Applications/MyApplication.app/Contents/Info.plist. – Arjan – 2013-08-16T10:14:49.970

@Arjan You're right about the code signing problems. – Daniel Beck – 2013-08-16T10:57:42.937

3

Alternatively... (Building on the answer from @Daniel Beck)...

Open the same Info.plist in Xcode

  • Right click within the top-level Information Property List key and select Add Row
  • Type Application is agent (UIElement) as the new key
  • Set the new key's value to YES
  • Save
  • Restart the corresponding application to see results

Old McStopher

Posted 2010-12-02T17:30:19.673

Reputation: 193