【问题标题】:Custom icon for .pkg file on Lion OSXLion OSX 上 .pkg 文件的自定义图标
【发布时间】:2011-12-20 15:31:51
【问题描述】:

我使用 PackageMaker 创建了一个包,并想更改 .pkg 文件的默认图标。 经过一番谷歌搜索,这里的 seticon 实用程序http://sveinbjorn.org/osxutils_docs 解决了我对所有 OSX-es 的问题,除了最新的 Lion 10.7(内核 11.0.0)。默认图标被替换为对双击不敏感的灰色方形,看起来像文件关联损坏。

另外两天的谷歌搜索让我了解了资源分叉、SetFile(1) 和其他一些有用的员工,比如这个旧线程 Changing icon of package created by package maker,但仍然没有运气。

我正在尝试做类似的事情:

target=pack.pkg

icon_filename="$(perl -e 'print "Icon\r"')"

触摸“$target/..namedfork/rsrc/$icon_filename”

cp "Icon.icns" "$target/..namedfork/rsrc/$icon_filename"

/Developer/Tools/SetFile -a C "$target"

并得到: build-Mac:pack.pkg/..namedfork/ 不是目录。

我做错了什么?有人能告诉我 Lion 中资源分叉的区别吗?还有其他可编写脚本的解决方案吗?

请注意,我是 MAC 的新手,我会感谢傻瓜的详细答案。

【问题讨论】:

    标签: macos icons osx-lion pkg-resources


    【解决方案1】:

    我终于想通了,以防有人需要,放在这里。我使用了苹果脚本:

    set newIcon to (POSIX file "IconMac.icns") as alias
    set theItem to (POSIX file "Installer.pkg") as alias
    
    tell application "Preview"
    activate
    open newIcon
    end tell
    tell application "System Events"
    tell process "Preview"
        keystroke "c" using command down
    end tell
    end tell
    tell application "Preview" to quit
    
    tell application "Finder"
    set infoWindow to open information window of theItem
    set infoWindowName to name of infoWindow
    end tell
    
    tell application "System Events"
    tell application process "Finder"
        tell window infoWindowName
            keystroke tab
            delay 1
            keystroke "v" using command down
        end tell
    end tell
    end tell
    
    tell application "Finder"
    close infoWindow
    end tell
    

    【讨论】:

    • 此方法不适用于 macOS 10.13.6。通过将 osascript 添加到设置/隐私/A11Y 应用程序,我能够使其适用于 Mojave。
    • @gamma 该脚本在 Mojave 上不适合我。你必须从上面修改它吗?我收到来自com.apple.Preview/com.apple.Preview.PasteboardItems 的拒绝许可
    • 我想我保留了原样。但如果我没记错的话,我必须将 osascript 命令添加到 Preferences / Privacy / A11Y Apps。
    猜你喜欢
    • 2016-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    • 2011-09-30
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多