Files
NetMesh/scripts/generate-mac-icon.sh
zhaolei 3c72efcb7f
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
[Init] Initial commit - NetMesh terminal manager
2026-09-13 18:24:01 +08:00

58 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# Generate build/icon.icns from the macOS app artwork using Apple's native
# iconutil pipeline. Keep hand-tuned 16px/32px 1x artwork: shrinking the
# large macOS artwork turns its subtle highlight into a bright one-pixel frame.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SOURCE="$ROOT/public/icon.png"
VECTOR_SOURCE="$ROOT/public/icon.svg"
OUTPUT="$ROOT/build/icon.icns"
TEMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/netcatty-mac-icon.XXXXXX")"
ICONSET="$TEMP_ROOT/icon.iconset"
SMALL_VECTOR="$TEMP_ROOT/icon-small.svg"
SMALL_RASTER="$TEMP_ROOT/icon-small.png"
cleanup() {
find "$TEMP_ROOT" -type f -delete
rmdir "$ICONSET" "$TEMP_ROOT"
}
trap cleanup EXIT
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "error: generating ICNS requires macOS iconutil and sips" >&2
exit 1
fi
for source in "$SOURCE" "$VECTOR_SOURCE"; do
if [[ ! -f "$source" ]]; then
echo "error: source icon not found: $source" >&2
exit 1
fi
done
mkdir -p "$ICONSET"
# The large artwork has a subtle outer highlight. At 1x it collapses into a
# bright one-pixel frame, so omit only that final SVG rect for 16px/32px.
awk '
BEGIN { skip = 0 }
/<rect x="104\.0" y="104\.0"/ { skip = 1 }
!skip { print }
skip && /\/>/ { skip = 0 }
' "$VECTOR_SOURCE" > "$SMALL_VECTOR"
sips -s format png "$SMALL_VECTOR" --out "$SMALL_RASTER" >/dev/null
for size in 16 32 128 256 512; do
retina_size=$((size * 2))
if [[ "$size" = 16 || "$size" = 32 ]]; then
sips -z "$size" "$size" "$SMALL_RASTER" \
--out "$ICONSET/icon_${size}x${size}.png" >/dev/null
else
sips -z "$size" "$size" "$SOURCE" --out "$ICONSET/icon_${size}x${size}.png" >/dev/null
fi
sips -z "$retina_size" "$retina_size" "$SOURCE" \
--out "$ICONSET/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil --convert icns "$ICONSET" --output "$OUTPUT"
echo "wrote build/icon.icns"