aboutsummaryrefslogtreecommitdiff
path: root/macos-svg2icns.sh
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-11-08 18:47:51 +0100
committerPřemysl Eric Janouch <p@janouch.name>2025-11-11 19:28:45 +0100
commit690e60cd74c44ed1e2d21b27e3152856845ead28 (patch)
tree4a11dff3cec93315170c0caf9a0540c80aef8b75 /macos-svg2icns.sh
parenta7ff9f220db0785e88a6013d286b5f6b92f71693 (diff)
downloadfiv-690e60cd74c44ed1e2d21b27e3152856845ead28.tar.gz
fiv-690e60cd74c44ed1e2d21b27e3152856845ead28.tar.xz
fiv-690e60cd74c44ed1e2d21b27e3152856845ead28.zip
Build an application bundle on macOSorigin/masterorigin/HEAD
This is far from done, but nonetheless constitutes a big improvement. macOS application bundles are more or less necessary for: - showing a nice icon; - having spawned off instances actually be brought to the foreground; - file associations (yet files currently do not open properly); - having a reasonable method of distribution. Also resolving a bunch of minor issues: - The context menu had duplicate items, and might needlessly end up with (null) labels.
Diffstat (limited to 'macos-svg2icns.sh')
-rwxr-xr-xmacos-svg2icns.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/macos-svg2icns.sh b/macos-svg2icns.sh
new file mode 100755
index 0000000..791e37e
--- /dev/null
+++ b/macos-svg2icns.sh
@@ -0,0 +1,22 @@
+#!/bin/sh -e
+# macos-svg2icns.sh: convert an SVG to the macOS .icns format
+if [ $# -ne 2 ]
+then
+ echo >&2 "Usage: $0 INPUT.svg OUTPUT.icns"
+ exit 2
+fi
+
+svg=$1 icns=$2 tmpdir=$(mktemp -d)
+trap 'rm -rf "$tmpdir"' EXIT
+
+iconset="$tmpdir/$(basename "$icns" .icns).iconset"
+mkdir -p "$iconset"
+for size in 16 32 128 256 512
+do
+ size2x=$((size * 2))
+ rsvg-convert --output="$iconset/icon_${size}x${size}.png" \
+ --width=$size --height=$size "$svg"
+ rsvg-convert --output="$iconset/icon_${size}x${size}@2x.png" \
+ --width=$size2x --height=$size2x "$svg"
+done
+iconutil -c icns -o "$icns" "$iconset"