fix: use upstream SVG (not nonexistent PNG) for .app icon conversion
This commit is contained in:
+19
-11
@@ -62,19 +62,27 @@ class GlabelsQt < Formula
|
|||||||
</plist>
|
</plist>
|
||||||
PLIST
|
PLIST
|
||||||
|
|
||||||
# Convert upstream PNG icon to .icns using sips (macOS built-in).
|
# Mac icon: convert upstream's SVG (installed at share/icons/hicolor/<size>/apps/glabels.svg)
|
||||||
# Upstream installs hicolor PNGs at share/icons/hicolor/<size>/apps/glabels.png.
|
# to .icns via sips. Prefer the scalable SVG; fall back to a sized variant if missing.
|
||||||
# Pick the largest available; fall back gracefully if none found.
|
icon_src = share/"icons/hicolor/scalable/apps/glabels.svg"
|
||||||
candidate_pngs = Dir[share/"icons/hicolor/*/apps/glabels.png"].sort_by do |path|
|
unless icon_src.exist?
|
||||||
size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i
|
candidates = Dir[share/"icons/hicolor/*/apps/glabels.svg"].sort_by do |path|
|
||||||
-size # largest first
|
size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i
|
||||||
|
-size # largest first
|
||||||
|
end
|
||||||
|
icon_src = Pathname.new(candidates.first) if candidates.first
|
||||||
end
|
end
|
||||||
if candidate_pngs.first
|
|
||||||
system "sips", "-s", "format", "icns",
|
if icon_src && icon_src.exist?
|
||||||
candidate_pngs.first,
|
begin
|
||||||
"--out", resources/"glabels-qt.icns"
|
system "sips", "-s", "format", "icns",
|
||||||
|
icon_src.to_s,
|
||||||
|
"--out", (resources/"glabels-qt.icns").to_s
|
||||||
|
rescue => e
|
||||||
|
opoo "sips icon conversion failed (#{e.message}); .app will use generic Mac icon."
|
||||||
|
end
|
||||||
else
|
else
|
||||||
opoo "No upstream PNG icon found; .app will use generic Mac icon."
|
opoo "No upstream icon found; .app will use generic Mac icon."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user