-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-icons
More file actions
executable file
·45 lines (34 loc) · 1.43 KB
/
build-icons
File metadata and controls
executable file
·45 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -e
SIZES="16 16@2 32 32@2 128 128@2 256 256@2 512"
hash yq 2>/dev/null || { echo >&2 "error: ImageMagick not found"; exit 1; }
hash magick 2>/dev/null || { echo >&2 "error: ImageMagick not found"; exit 1; }
hash optipng 2>/dev/null || { echo >&2 "error: optipng not found"; exit 1; }
BASE_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$BASE_DIR"
rm -rf icons || true
REPO_TMP=$(mktemp -d)
trap 'rm -rf "$REPO_TMP="' EXIT
repo=$(yq '(.modules[] | select(.name == "mind-work-ai-studio")).sources[0] | .url' org.MindWorkAI.AIStudio.yml)
commit=$(yq '(.modules[] | select(.name == "mind-work-ai-studio")).sources[0] | .commit' org.MindWorkAI.AIStudio.yml)
(
cd $REPO_TMP
git init
git remote add origin $repo
git fetch --depth 1 origin $commit
git checkout FETCH_HEAD
)
for def in $SIZES; do
size="${def%@*}"
[[ "$def" == *"@"* ]] && scale="${def#*@}" || scale=""
if [ -z "$scale" ]; then
target_dir="icons/hicolor/${size}x${size}/apps"
scale_size=$size
else
target_dir="icons/hicolor/${size}x${size}@$scale/apps"
scale_size=$((size * scale))
fi
mkdir -p "$target_dir"
magick "$REPO_TMP/runtime/app-icon.png" -resize ${size}x${size} "$target_dir/org.MindWorkAI.AIStudio.png" && echo -n . || echo -n "!"
optipng -silent "$target_dir/org.MindWorkAI.AIStudio.png" && echo -n . || echo -n "!"
done