#!/usr/bin/env bash # Regenerate every app icon file from assets/app-icon/notescraft.svg (the canonical vector). # # Needs: resvg (brew install resvg / cargo install resvg). On macOS, iconutil also writes the # .icns. The outputs are committed, so builds and packaging never need these tools. # # packaging/icons.sh # # notescraft.svg is the canonical vector: a tile with a note page and a wikilink bracket pair. # notescraft-small.svg is the same drawing, used for the scalable hicolor icon. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DIR="$ROOT/assets/app-icon" SVG="$DIR/notescraft.svg" ID="ai.storyteller.notescraft" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT command -v resvg >/dev/null || { echo "error: resvg not found (brew install resvg)" >&2; exit 1; } render() { resvg -w "$2" -h "$2" "$1" "$3" ||' \ -e 's|[[:space:]]*$||' "$SVG" >"$MAC" grep -q 'viewBox="0 0 1024 1024"' "$MAC" || { echo "error: unexpected header in $SVG" >&2; exit 1; } render "$SVG" 1024 "$DIR/notescraft-1024.png" # Runtime window/Dock icon on macOS (apps/notescraft/src/main.rs embeds it). render "$MAC" 512 "$DIR/notescraft-macos-512.png" # Linux hicolor theme (the 256 px one is also the runtime icon on Windows and Linux). for s in 16 24 32 48 64 128 256 512; do mkdir -p "$DIR/hicolor/${s}x${s}/apps" render "$SVG" "$s" "$DIR/hicolor/${s}x${s}/apps/$ID.png" done mkdir -p "$DIR/hicolor/scalable/apps" cp "$DIR/notescraft-small.svg" "$DIR/hicolor/scalable/apps/$ID.svg" # Windows .ico. ICO_PNGS=() for s in 16 20 24 32 40 48 64 128 256; do render "$SVG" "$s" "$TMP/ico-$s.png" ICO_PNGS+=("$TMP/ico-$s.png") done (cd "$ROOT" && cargo run -q -p xtask -- ico "$DIR/notescraft.ico" "${ICO_PNGS[@]}") # macOS .icns. if command -v iconutil >/dev/null; then SET="$TMP/notescraft.iconset" mkdir -p "$SET" for s in 16 32 128 256 512; do render "$MAC" "$s" "$SET/icon_${s}x${s}.png" render "$MAC" $((s * 2)) "$SET/icon_${s}x${s}@2x.png" done iconutil -c icns -o "$DIR/notescraft.icns" "$SET" else echo "warning: iconutil not found (macOS only); notescraft.icns not regenerated" >&2 fi echo "icons written to $DIR"