forked from vinceliuice/Mojave-gtk-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-assets.sh
executable file
·72 lines (59 loc) · 1.92 KB
/
render-assets.sh
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env bash
set -ueo pipefail
set -o physical
INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
ASRC_DIR="${REPO_DIR}/src/assets"
# check command avalibility
has_command() {
command -v "${1}" > /dev/null 2>&1
}
if [ ! "$(which inkscape 2> /dev/null)" ]; then
echo inkscape and optipng needs to be installed to generate the assets.
if has_command zypper; then
sudo zypper in inkscape optipng
elif has_command apt; then
sudo apt install inkscape optipng
elif has_command dnf; then
sudo dnf install -y inkscape optipng
elif has_command dnf; then
sudo dnf install inkscape optipng
elif has_command pacman; then
sudo pacman -S --noconfirm inkscape optipng
elif had_command brew; then
brew install --cask inkscape
brew install optipng
else
exit 1
fi
fi
render_thumbnail() {
local dest="$1"
local color="$2"
if [ -f "$ASRC_DIR/$1/thumbnail$2.png" ]; then
echo "$ASRC_DIR/$1/thumbnail$2.png exists."
else
echo
echo "Rendering $ASRC_DIR/$1/thumbnail$2.png"
"$INKSCAPE" --export-id="thumbnail$2" \
--export-id-only \
--export-filename="$ASRC_DIR/$1/thumbnail$2.png" "$ASRC_DIR/$1/thumbnail.svg" >/dev/null
"$OPTIPNG" -o7 --quiet "$ASRC_DIR/$1/thumbnail$2.png"
fi
}
for color in '-light' '-dark' ; do
render_thumbnail "${dest:-cinnamon}" "${color}"
render_thumbnail "${dest:-gtk-3.0}" "${color}"
render_thumbnail "${dest:-metacity-1}" "${color}"
done
echo Rendering gtk-2.0 assets
cd "$ASRC_DIR/gtk-2.0" && ./render-assets.sh
echo Rendering gtk-3.0 assets
cd "$ASRC_DIR/gtk-3.0/common-assets" && ./render-assets.sh
cd "$ASRC_DIR/gtk-3.0/windows-assets" && ./render-assets.sh && ./render-alt-assets.sh
echo Rendering metacity-1 assets
cd "$ASRC_DIR/metacity-1" && ./render-assets.sh
echo Rendering xfwm4 assets
cd "$ASRC_DIR/xfwm4" && ./render-assets.sh
exit 0