6

So I recently made an .app wrapper for a zsh script, but when I run it, the icon for the app keeps hopping in the Dock.

The app is basically:

% find Example.app -type f
Example.app/Contents/Info.plist
Example.app/Contents/MacOS/wrapper.sh
% cat Example.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <!-- tell OSX what the name of the executable is -->
 <key>CFBundleExecutable</key>
 <string>wrapper.sh</string>
</dict>
</plist>
% cat Example.app/Contents/MacOS/wrapper.sh
#!/usr/bin/env zsh
# not my real script, but something else that hangs for a while
sleep 10
%

You can also grab it from github.

Is there any way I can get the app icon to stop hopping, and act like a normal app, and just sit there with a triangle next to it?

Jim Puls
  • 79,175
  • 10
  • 73
  • 78
rampion
  • 87,131
  • 49
  • 199
  • 315

3 Answers3

9

An application's icon will bounce in the OS X Dock until the app enters its main event loop and begins responding to user input. As your script probably doesn't run a Carbon or Cocoa event loop (See documentation for Carbon Event Manager and NSApplication, respectively), the Dock is waiting continuously, expecting a regular foreground GUI application to emerge.

A script-wrapping tool that I've had success with is Platypus. It can run its own event loop while executing your script, and do a number of other convenient things.

Draxillion
  • 578
  • 3
  • 6
2

You want DropScript. The dock doesn't work with shell scripts like that, it expects something a bit more full-fledged.

Jim Puls
  • 79,175
  • 10
  • 73
  • 78
  • It appears the latest version (0.5) of DropScript is a PPC-only binary. Won't work on Intel Macs with any recent (>10.5 I think?) version of OS X. – pendor Mar 28 '14 at 17:11
2

I think if you add LSUIElement to your Info.plist file, it should work.

user2199684
  • 93
  • 1
  • 6
  • For those who come later, this key actually removes the app from the dock entirely. Use this for apps that run as background processes, but not apps you want the user to be able to focus on. – James G Mar 15 '23 at 04:11