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

发布于 2024-07-24 23:55:50 字数 964 浏览 12 评论 0原文

因此,我最近为 zsh 脚本制作了一个 .app 包装器,但是当我运行它时,应用程序的图标不断在 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 获取它

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

讽刺将军 2024-07-31 23:55:51

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

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

野心澎湃 2024-07-31 23:55:50

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

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

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.

灵芸 2024-07-31 23:55:50

您需要 DropScript。 Dock 不支持像这样的 shell 脚本,它需要一些更成熟的东西。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文