在我的应用程序包装器脚本启动后,如何使停靠图标停止弹跳?

时间:2022-09-04 01:07:20

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.

所以我最近为zsh脚本创建了一个.app包装器,但是当我运行它时,应用程序的图标一直在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.

你也可以从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?

有什么方法可以让我的应用程序图标停止跳跃,并像一个普通的应用程序一样,只是坐在旁边有一个三角形?

3 个解决方案

#1


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.

应用程序的图标将在OS X Dock中弹回,直到应用程序进入其主事件循环并开始响应用户输入。由于您的脚本可能没有运行Carbon或Cocoa事件循环(分别参见Carbon Event Manager和NSApplication的文档),Dock正在等待,期望出现常规的前台GUI应用程序。

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.

我成功的脚本包装工具是Platypus。它可以在执行脚本时运行自己的事件循环,并执行许多其他方便的操作。

#2


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

你想要DropScript。 Dock不能像这样的shell脚本一起工作,它期望更完整的东西。

#3


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

我想如果你将LSUIElement添加到Info.plist文件中,它应该可以工作。

#1


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.

应用程序的图标将在OS X Dock中弹回,直到应用程序进入其主事件循环并开始响应用户输入。由于您的脚本可能没有运行Carbon或Cocoa事件循环(分别参见Carbon Event Manager和NSApplication的文档),Dock正在等待,期望出现常规的前台GUI应用程序。

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.

我成功的脚本包装工具是Platypus。它可以在执行脚本时运行自己的事件循环,并执行许多其他方便的操作。

#2


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

你想要DropScript。 Dock不能像这样的shell脚本一起工作,它期望更完整的东西。

#3


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

我想如果你将LSUIElement添加到Info.plist文件中,它应该可以工作。