xiaozi 2020-01-02 00:19:18

获取app图标

#!/bin/zsh

APPNAME=$1

if [[ -z "$APPNAME" ]]; then
    echo '请先指定一个appname'
    exit 0
fi

# 获取图标名称
ICON=$(/usr/libexec/plistbuddy -c Print:CFBundleIconFile: "/Applications/${APPNAME}.app/Contents/Info.plist")
if [[ -z "$ICON" ]]; then
    echo '找不到icon文件'
    exit 0
fi

mkdir -p ~/Desktop/appIcons/48/

if [[ "$ICON" == *.icns ]] ICON=${ICON%.*}
ICONPATH="/Applications/${APPNAME}.app/Contents/Resources/${ICON}.icns"
# 转换格式
sips -s format png "${ICONPATH}" --out ~/Desktop/appIcons/48/"${APPNAME}".png -Z 48

评论

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.139.0. UTC+08:00, 2024-12-22 17:15
浙ICP备14020137号-1 $访客地图$