5

所以我最近.app为 zsh 脚本制作了一个包装器,但是当我运行它时,应用程序的图标一直在 Dock 中跳跃。

该应用程序基本上是:

% 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
%

您也可以从 github 获取它

有什么方法可以让应用程序图标停止跳动,并像普通应用程序一样工作,然后坐在那里,旁边有一个三角形?

4

3 回答 3

9

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

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

于 2009-06-17T16:47:09.927 回答
2

你想要DropScript。Dock 不适用于这样的 shell 脚本,它需要一些更成熟的东西。

于 2009-06-17T16:26:28.627 回答
1

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

于 2013-05-29T01:10:08.237 回答