Skip to content

Commit ded5603

Browse files
committed
icns support
1 parent 8220ec2 commit ded5603

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

build/Assets.car

0 Bytes
Binary file not shown.

build/app-icon.icns

-398 KB
Binary file not shown.

build/[email protected]

12.1 MB
Loading

forge.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const config: ForgeConfig = {
2828
],
2929
hooks: {
3030
generateAssets: async () => {
31+
// Generate ICNS from source PNG
32+
if (existsSync("build/[email protected]")) {
33+
console.log("Generating ICNS icon...");
34+
execSync("bash scripts/generate-icns.sh", { stdio: "inherit" });
35+
}
36+
3137
// Compile liquid glass icon to Assets.car
3238
if (existsSync("build/icon.icon")) {
3339
console.log("Compiling liquid glass icon...");

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"make": "electron-forge make",
1515
"publish": "electron-forge publish",
1616
"build-native": "bash scripts/build-native-modules.sh",
17+
"build-icons": "bash scripts/generate-icns.sh",
1718
"typecheck": "tsc -p tsconfig.node.json --noEmit && tsc -p tsconfig.web.json --noEmit",
1819
"lint": "biome check --write --unsafe",
1920
"format": "biome format --write",

scripts/generate-icns.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Generate ICNS file from a source PNG
4+
# Usage: bash scripts/generate-icns.sh [source.png] [output.icns]
5+
# Defaults: source=build/[email protected], output=build/app-icon.icns
6+
7+
set -e
8+
9+
SOURCE_PNG="${1:-build/icon@3x.png}"
10+
OUTPUT_ICNS="${2:-build/app-icon.icns}"
11+
ICONSET_DIR=$(mktemp -d)/icon.iconset
12+
13+
if [ ! -f "$SOURCE_PNG" ]; then
14+
echo "Error: Source PNG not found: $SOURCE_PNG"
15+
exit 1
16+
fi
17+
18+
echo "Creating iconset from $SOURCE_PNG..."
19+
20+
mkdir -p "$ICONSET_DIR"
21+
22+
# Scale factor for macOS icon guidelines: 832/1024 = 13/16 = 0.8125
23+
# This gives proper padding matching native macOS icons
24+
SCALE=0.8125
25+
26+
# Generate all required icon sizes with padding
27+
sips -z 16 16 "$SOURCE_PNG" --out "$ICONSET_DIR/icon_16x16.png" > /dev/null
28+
sips -Z $(echo "16 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/icon_16x16.png" --padToHeightWidth 16 16 > /dev/null
29+
30+
sips -z 32 32 "$SOURCE_PNG" --out "$ICONSET_DIR/[email protected]" > /dev/null
31+
sips -Z $(echo "32 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/[email protected]" --padToHeightWidth 32 32 > /dev/null
32+
33+
sips -z 32 32 "$SOURCE_PNG" --out "$ICONSET_DIR/icon_32x32.png" > /dev/null
34+
sips -Z $(echo "32 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/icon_32x32.png" --padToHeightWidth 32 32 > /dev/null
35+
36+
sips -z 64 64 "$SOURCE_PNG" --out "$ICONSET_DIR/[email protected]" > /dev/null
37+
sips -Z $(echo "64 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/[email protected]" --padToHeightWidth 64 64 > /dev/null
38+
39+
sips -z 128 128 "$SOURCE_PNG" --out "$ICONSET_DIR/icon_128x128.png" > /dev/null
40+
sips -Z $(echo "128 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/icon_128x128.png" --padToHeightWidth 128 128 > /dev/null
41+
42+
sips -z 256 256 "$SOURCE_PNG" --out "$ICONSET_DIR/[email protected]" > /dev/null
43+
sips -Z $(echo "256 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/[email protected]" --padToHeightWidth 256 256 > /dev/null
44+
45+
sips -z 256 256 "$SOURCE_PNG" --out "$ICONSET_DIR/icon_256x256.png" > /dev/null
46+
sips -Z $(echo "256 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/icon_256x256.png" --padToHeightWidth 256 256 > /dev/null
47+
48+
sips -z 512 512 "$SOURCE_PNG" --out "$ICONSET_DIR/[email protected]" > /dev/null
49+
sips -Z $(echo "512 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/[email protected]" --padToHeightWidth 512 512 > /dev/null
50+
51+
sips -z 512 512 "$SOURCE_PNG" --out "$ICONSET_DIR/icon_512x512.png" > /dev/null
52+
sips -Z $(echo "512 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/icon_512x512.png" --padToHeightWidth 512 512 > /dev/null
53+
54+
sips -z 1024 1024 "$SOURCE_PNG" --out "$ICONSET_DIR/[email protected]" > /dev/null
55+
sips -Z $(echo "1024 * $SCALE" | bc | cut -d. -f1) "$ICONSET_DIR/[email protected]" --padToHeightWidth 1024 1024 > /dev/null
56+
57+
echo "Converting iconset to ICNS..."
58+
59+
# Convert iconset to icns
60+
iconutil -c icns "$ICONSET_DIR" -o "$OUTPUT_ICNS"
61+
62+
# Clean up
63+
rm -rf "$(dirname "$ICONSET_DIR")"
64+
65+
echo "✓ Created $OUTPUT_ICNS"

0 commit comments

Comments
 (0)