Hiding/Show dock app icons with lsappinfo and ApplicationType=UIElement

So, this is a weird/niche request, I’ll admit.

I just learned that you can hide the dock icon of just about any running app (*) with a shell command.

I’m using Twitterrific as an example in the two commands below.

This will remove the app from the dock

/usr/bin/lsappinfo setinfo -app Twitterrific ApplicationType=UIElement

and this will bring it back

/usr/bin/lsappinfo setinfo -app Twitterrific ApplicationType=Foreground

I’d love to be able to do this automatically for some apps that I don’t want to see in my Dock, but which I launch/quit several times a day.

(I know that the logical solution is that I should just ignore the fact that they are in my Dock, but I like a clean Dock. I don’t keep any apps in there except the currently-running ones, and if I don’t have to see all of the low-priority ones, I’d prefer that. Hey, I said it was a weird request, I don’t deny it.)

Hiding the Dock icon is easy. I just made a Keyboard Maestro macro for when apps deactivate:

Set Variable To Text:

	Set Variable “TRIGGER_VALUE” to Text (%TriggerValue%)

Run Shell Script:

	lsappinfo setinfo -app "$KMVAR_TRIGGER_VALUE" ApplicationType=UIElement

The Problem

The problem comes when I try to use apps hidden in this manner again.

I can “activate” the apps by Alfred or Contexts, but Keyboard Maestro doesn’t seem to recognize that they have activated, because a macro set to run whenever any app activates does not seem to trigger if the Dock icon has been hidden in this manner. This also means that the menu bar does not update to show the app’s menus.

Obviously, if an app hasn't been designed specifically to work without its menu bar, it doesn’t work well.

So I appear to be stuck with a cool idea that I can’t use.

Anyone have any clever ideas that I might not have tried?

(*) Finder doesn’t seem to work, but I haven’t found any others that don’t.

Well, before anyone tries to solve this one… don't bother.

The good news is that I figured out that if I used an activation trigger which specifically listed the apps that I had hidden, then I could get Keyboard Maestro to automatically run the 'unhide' commands.

Unfortunately, although the menu items for the apps came back, they usually were not "click-able" which made the whole thing effectively useless.

So, idea shelved. Oh well. Better luck next time.

It will lose effect after restart the system, how can I solve it?

I don’t know that you can. The only option I can think of is to make sure it is set again after reboot.

Keyboard Maestro has options for running macros when the engine starts. That’s probably the easiest way.