如何更改OS X应用程序包中的可执行文件 [英] How to change the executable in an OS X Application Bundle

查看:124
本文介绍了如何更改OS X应用程序包中的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Firefox启动之前运行一个脚本,退出后。在Ubuntu中,我通过创建一个新的快捷方式来调用我的函数,然后调用firefox命令,然后调用我的最后一个函数。由于firefox命令阻塞,直到应用程序退出,我的最后一个函数被立即调用后结束。



但是,在OS X不能做到这一点很好,因为我最终在码头上有两个图标。一个为我的脚本变成了一个应用程序&另一个用于Firefox应用程序。我宁愿只有一个码头图标&不要打破Firefox的更新。

我现在的解决方案是重命名MacOS / firefox {, - bin}前缀为real-,然后命名我的shell脚本firefox-bin。这个工作,但我很确定,下次firefox尝试更新自己我敬酒。

我试着改变CFBundleExecutable

任何人都可以提供其他建议吗?

解决方案

创建一个常规应用程序包,但是在其上设置 LSUIElement ,这样脚本应用程序的图标就不会被停放,并将Firefox 包含在包中。

这样做的一个简单方法是使用 参数选中设置
$ 1到应用程序的路径复选框,
所以你的脚本可以引用文件
在这个包里面。
检查在后台运行 - 这个设置
code> LSUIElement 给你。

  • 应用程序到
    资源文件夹,放下Firefox。

  • 将输出更改为无,以便您的日志
    消息进入系统

  • 在自定义图标上放置Firefox的图标文件(firefox.icns)。


  • 将App Name更改为Firefox。

    $ b

    对于类似下面的脚本:

  • / p>

     #!/ bin / sh 
    在前>& 2
    $ 1 /内容/资源/ Firefox.app/Contents/MacOS/firefox-bin
    在>& 2
    后回显

    你得到如下输出:

      4/8/09 1:16:33 PM [0x0-0x801801] .net.sabi .PlatypusScript [76610] 
    之前4/8/09 1:16:35 PM firefox-bin [76613]数据库加载时间:0.373( 717个对象)
    4/8/09 1:16:35 PM [0x0-0x801801] .net.sabi.PlatypusScript [76610]
    2009-04-08 13:16:35.699 firefox-bin [ 76613:10b]数据库加载时间:0.373(717对象)
    2009年8月8日下午1:16:57 [0x0-0x801801] .net.sabi.PlatypusScript [76610]

    如果您的用户以其他方式启动Firefox,例如使用URL处理程序和打开HTML文件,则需要使用本地应用程序,它可以将相应的Apple事件传递给Firefox,并将相应的URL和文件处理程序信息添加到Info.plist。 ( aemreceive 是一个方便的苹果事件接收的Python包装。)


    I would like to run a script before Firefox starts & after it quits. In Ubuntu I do this by creating a new shortcut that calls my function first, then calls the firefox command, then calls my last function. Since the firefox command blocks until the application quits, my last function is called immediately after the process ends.

    However, in OS X I cannot do this as nicely because I end up with two icons on the dock. One for my script turned into an application & another for the Firefox application. I would prefer to just have one dock icon & to not break Firefox updates.

    My current solution is to rename both MacOS/firefox{,-bin} to be prefixed with 'real-" and then name my shell script "firefox-bin". This works, but I am pretty sure that the next time firefox tries to update itself I am toast.

    I have tried changing the "CFBundleExecutable" property in the bundle's Info.plist file to be my script, but that doesn't work.

    Can anyone offer any other suggestions?

    解决方案

    Create a regular application bundle but set LSUIElement on it, so the script application's icon is hidden from the dock, and include Firefox inside the bundle.

    A simple way of doing this is with Platypus. Configure Platypus as follows:

    • Click "Parameters". Check the "Set $1 to path to application" checkbox, so your script can reference files inside the bundle.

    • Check "Runs in background"—this sets LSUIElement for you.

    • In the list of "Files and folders to be bundled with application into the Resources folder", drop Firefox.

    • Change Output to "None" so your log messages go to the system console.

    • Drop Firefox's icon file (firefox.icns) on the "Custom Icon" well.

    • Change "App Name" to Firefox.

    For a script that looks something like this:

    #!/bin/sh
    echo before >&2
    $1/Contents/Resources/Firefox.app/Contents/MacOS/firefox-bin
    echo after >&2
    

    you get output like:

    4/8/09 1:16:33 PM [0x0-0x801801].net.sabi.PlatypusScript[76610] before 
    4/8/09 1:16:35 PM firefox-bin[76613] Database load time: 0.373 (717 objects) 
    4/8/09 1:16:35 PM [0x0-0x801801].net.sabi.PlatypusScript[76610]
    2009-04-08 13:16:35.699 firefox-bin[76613:10b] Database load time: 0.373 (717 objects) 
    4/8/09 1:16:57 PM [0x0-0x801801].net.sabi.PlatypusScript[76610] after 
    

    If your users launch Firefox in other ways, such as with URL handlers and by opening HTML files, you'll instead need to use a native application, which can pass the appropriate Apple Events through to Firefox, and add the appropriate URL and file handler information to the Info.plist. (aemreceive is a convenient Python wrapper for Apple Event reception.)

    这篇关于如何更改OS X应用程序包中的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆