最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

以编程方式更改mac上的桌面应用程序图标。 2019

运维笔记admin13浏览0评论

以编程方式更改mac上的桌面应用程序图标。 2019

以编程方式更改mac上的桌面应用程序图标。 2019

有没有办法在MacBook桌面应用程序上更改图标,这复制了在Finder窗口中复制/粘贴图标时发生的相同操作?通过终端,node.js或其他什么?我到目前为止尝试过:

1)通过终端,删除和替换图标本身,我不喜欢这样,因为它完全删除原始图标,并不适用于每个应用程序。

2)通过node.js和terminal,创建一个图标?文件,但是这对每个程序都不起作用,我在权限访问方面遇到了麻烦。如果有人有解决方案,我想听听。

3)使用applescript,这可以工作但是同时循环多个图标对于它来说太过分了。

我已经搜索了好几天,但信息非常有限或过时。我将不胜感激任何帮助!

回答如下:

要更改应用程序的图标,我使用带有applescript的shell脚本。目标是更改应用程序info.plist中的“图标文件”,并将图标(文件)复制到应用程序的资源中。 “application”.app / Contents / Resources /“。所有在Droplet中完成,我在其上拖动所需的图标,打开一个窗口,选择必须更改其图标的应用程序。使用plutil我将文件info.plist转换为xml1(我保存在“.app / Contents / infoo.plist”下以避免任何问题并找到原始文件。)要更改值“图标文件”,我使用“/ usr / libexec / PlistBuddy”和“-c Set” :“要查看更改,您必须启动应用程序(其图标已更改),在Dock中您必须看到新图标(如果停靠选项处于活动状态)

在Droplet脚本下面

    global testdir
on open draggedItems
    repeat with currentItem in draggedItems
        set icon_image_file_string to POSIX path of (draggedItems)
        set {name:Nm, name extension:Ex} to info for POSIX file icon_image_file_string
        set Nm to do shell script "echo " & Nm & " | sed 's#." & Ex & "##'"

        set testdir to POSIX path of (choose file of type {"APPL"} with prompt "Choisissez  l'Application pour changer son icone  :")
        set {name:Nmm, name extension:Ex} to info for POSIX file testdir

        do shell script "plutil -convert xml1 " & quoted form of (testdir & "Contents/Info.plist ") & " | cat " & quoted form of (testdir & "Contents/Info.plist") & " >" & quoted form of (testdir & "Contents/Infoo.plist")
        try
            do shell script "cp -f " & quoted form of icon_image_file_string & " " & quoted form of (testdir & "Contents/Resources/")
        end try
        try
            set icon_image_file to do shell script "/usr/libexec/PlistBuddy   " & quoted form of (testdir & "Contents/Info.plist") & " -c \"Set:CFBundleIconFile " & Nm & "\""
        end try
    end repeat
end open
发布评论

评论列表(0)

  1. 暂无评论