diff --git a/electron/build/create-adaptive-icon.sh b/electron/build/create-adaptive-icon.sh new file mode 100755 index 0000000..f888070 --- /dev/null +++ b/electron/build/create-adaptive-icon.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ -n "${DEBUG:-}" ]; then + set -x +fi + +# Script to create adaptive macOS icons for light/dark mode + +ICON_DIR="macos-icons" +STYLE="${1:-regular}" + +case "$STYLE" in + "clear") + LIGHT_ICON="meshsense-macOS-ClearLight-1024x1024@2x.png" + DARK_ICON="meshsense-macOS-ClearDark-1024x1024@2x.png" + OUTPUT_NAME="meshsense-clear-adaptive.icns" + ;; + "regular"|"default") + LIGHT_ICON="meshsense-macOS-Default-1024x1024@2x.png" + DARK_ICON="meshsense-macOS-Dark-1024x1024@2x.png" + OUTPUT_NAME="meshsense-regular-adaptive.icns" + ;; + "tinted") + LIGHT_ICON="meshsense-macOS-TintedLight-1024x1024@2x.png" + DARK_ICON="meshsense-macOS-TintedDark-1024x1024@2x.png" + OUTPUT_NAME="meshsense-tinted-adaptive.icns" + ;; + *) + echo "Invalid style: $STYLE" + echo "Valid options: clear, regular, tinted" + echo "Usage: $0 [clear|regular|tinted]" + exit 1 + ;; +esac + +ICONSET_NAME="${OUTPUT_NAME%.icns}.iconset" + +mkdir -p "$ICONSET_NAME" + +resize_icon() { + local source="$1" + local size="$2" + local suffix="$3" + local appearance="$4" + + if [ ! -f "$ICON_DIR/$source" ]; then + echo "Warning: Source file not found: $ICON_DIR/$source" + return + fi + + local padded_size=$((size * 81 / 100)) + + sips -z "$padded_size" "$padded_size" "$ICON_DIR/$source" --out "/tmp/temp_icon.png" 2>/dev/null + sips -p "$size" "$size" -c "$size" "$size" --padToHeightWidth "$size" "$size" "/tmp/temp_icon.png" --out "$ICONSET_NAME/icon_${size}x${size}${suffix}${appearance}.png" 2>/dev/null + rm -f "/tmp/temp_icon.png" +} + +SIZES=(16 32 64 128 256 512 1024) +SUFFIXES=("" "@2x") + +generate_icons() { + local source_icon="$1" + local appearance="$2" + + for size in "${SIZES[@]}"; do + for suffix in "${SUFFIXES[@]}"; do + # we are not supposed to generate @2x for 16px + if [ "$size" = "16" ] && [ "$suffix" = "@2x" ]; then + continue + fi + + resize_icon "$source_icon" "$size" "$suffix" "$appearance" + done + done +} + + +generate_icons "$LIGHT_ICON" "" +generate_icons "$DARK_ICON" "~dark" +iconutil -c icns "$ICONSET_NAME" -o "$OUTPUT_NAME" + +if [ $? -eq 0 ]; then + echo "Created $OUTPUT_NAME with light/dark mode support" + echo "File location: $(pwd)/$OUTPUT_NAME" + + rm -rf "$ICONSET_NAME" +else + echo "Failed to create icns file" + exit 1 +fi diff --git a/electron/build/macos-icons/meshsense-macOS-ClearDark-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-ClearDark-1024x1024@2x.png new file mode 100644 index 0000000..03fe43c Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-ClearDark-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense-macOS-ClearLight-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-ClearLight-1024x1024@2x.png new file mode 100644 index 0000000..791fbf0 Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-ClearLight-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense-macOS-Dark-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-Dark-1024x1024@2x.png new file mode 100644 index 0000000..ee1dbd7 Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-Dark-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense-macOS-Default-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-Default-1024x1024@2x.png new file mode 100644 index 0000000..1f0fc9b Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-Default-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense-macOS-TintedDark-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-TintedDark-1024x1024@2x.png new file mode 100644 index 0000000..f6f100e Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-TintedDark-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense-macOS-TintedLight-1024x1024@2x.png b/electron/build/macos-icons/meshsense-macOS-TintedLight-1024x1024@2x.png new file mode 100644 index 0000000..bfa6767 Binary files /dev/null and b/electron/build/macos-icons/meshsense-macOS-TintedLight-1024x1024@2x.png differ diff --git a/electron/build/macos-icons/meshsense.icon/Assets/icon.png b/electron/build/macos-icons/meshsense.icon/Assets/icon.png new file mode 100644 index 0000000..f540f58 Binary files /dev/null and b/electron/build/macos-icons/meshsense.icon/Assets/icon.png differ diff --git a/electron/build/macos-icons/meshsense.icon/icon.json b/electron/build/macos-icons/meshsense.icon/icon.json new file mode 100644 index 0000000..46dfa47 --- /dev/null +++ b/electron/build/macos-icons/meshsense.icon/icon.json @@ -0,0 +1,53 @@ +{ + "fill" : { + "linear-gradient" : [ + "display-p3:0.52119,0.42313,1.00000,1.00000", + "display-p3:0.46963,0.32604,0.84892,1.00000" + ] + }, + "groups" : [ + { + "blur-material" : null, + "hidden-specializations" : [ + { + "value" : false + }, + { + "appearance" : "light", + "value" : false + } + ], + "layers" : [ + { + "fill" : "none", + "glass" : true, + "hidden" : false, + "image-name" : "icon.png", + "name" : "icon", + "opacity" : 1, + "position" : { + "scale" : 1.68, + "translation-in-points" : [ + 0, + 0 + ] + } + } + ], + "lighting" : "combined", + "shadow" : { + "kind" : "neutral", + "opacity" : 0.5 + }, + "translucency" : { + "enabled" : true, + "value" : 0.5 + } + } + ], + "supported-platforms" : { + "squares" : [ + "macOS" + ] + } +} \ No newline at end of file diff --git a/electron/build/meshsense-regular-adaptive.icns b/electron/build/meshsense-regular-adaptive.icns new file mode 100644 index 0000000..8bd53bc Binary files /dev/null and b/electron/build/meshsense-regular-adaptive.icns differ diff --git a/electron/electron-builder-config.js b/electron/electron-builder-config.js index 234701a..5638f9d 100644 --- a/electron/electron-builder-config.js +++ b/electron/electron-builder-config.js @@ -39,6 +39,7 @@ const config = { }, mac: { artifactName: '${name}' + channelString + '-${arch}.${ext}', + icon: 'build/meshsense-regular-adaptive.icns', notarize: { teamId: `${process.env.APPLE_TEAM_ID}` }, diff --git a/electron/package.json b/electron/package.json index aec67bb..6fcfbbf 100644 --- a/electron/package.json +++ b/electron/package.json @@ -18,7 +18,8 @@ "build:unpack": "npm run build && electron-builder --dir", "build:win": "npm run build && electron-builder --win --config electron-builder-config.js", "build:mac": "npm run build && electron-builder --mac --config electron-builder-config.js", - "build:linux": "npm run build && electron-builder --linux --config electron-builder-config.js" + "build:linux": "npm run build && electron-builder --linux --config electron-builder-config.js", + "icon:generate": "cd build && ./create-adaptive-icon.sh" }, "dependencies": { "@electron-toolkit/preload": "^3.0.1",