A fork of the Materia GTK theme.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 render-asset.sh

View raw Download
text/x-shellscript • 1.52 kiB
Bourne-Again shell script, ASCII text executable
        
            
1
#!/usr/bin/env bash
2
set -ueo pipefail
3
4
FORCE_INKSCAPE="$(echo "${FORCE_INKSCAPE-False}" | tr '[:upper:]' '[:lower:]')"
5
if [[ "${FORCE_INKSCAPE}" == "true" ]]; then
6
RENDER_SVG=""
7
else
8
RENDER_SVG="$(command -v rendersvg)" || true
9
fi
10
INKSCAPE="$(command -v inkscape)" || true
11
OPTIPNG="$(command -v optipng)" || true
12
13
if [[ -n "${INKSCAPE}" ]]; then
14
if "$INKSCAPE" --help | grep -e "--export-filename" >/dev/null; then
15
EXPORT_FILE_OPTION="--export-filename"
16
elif "$INKSCAPE" --help | grep -e "--export-file" >/dev/null; then
17
EXPORT_FILE_OPTION="--export-file"
18
elif "$INKSCAPE" --help | grep -e "--export-png" >/dev/null; then
19
EXPORT_FILE_OPTION="--export-png"
20
fi
21
fi
22
23
if [[ "$1" == "dark" ]]; then
24
SRC_FILE="assets-dark.svg"
25
ASSETS_DIR="assets-dark"
26
else
27
SRC_FILE="assets.svg"
28
ASSETS_DIR="assets"
29
fi
30
31
i="$2"
32
33
# @TODO: remove $ZOOM when it will be fixed/implemented in resvg
34
GTK2_HIDPI="$(echo "${GTK2_HIDPI-False}" | tr '[:upper:]' '[:lower:]')"
35
if [[ "${GTK2_HIDPI}" == "true" ]]; then
36
DPI=192
37
ZOOM=2
38
else
39
DPI=96
40
ZOOM=1
41
fi
42
43
echo "Rendering '$ASSETS_DIR/$i.png'"
44
45
if [[ -n "${RENDER_SVG}" ]]; then
46
# @TODO: remove --zoom when it will be fixed/implemented in resvg
47
"$RENDER_SVG" --export-id "$i" \
48
--dpi ${DPI} \
49
--zoom ${ZOOM} \
50
"$SRC_FILE" "$ASSETS_DIR/$i.png"
51
else
52
"$INKSCAPE" --export-id="$i" \
53
--export-id-only \
54
--export-dpi=${DPI} \
55
"$EXPORT_FILE_OPTION=$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
56
fi
57
58
if [[ -n "${OPTIPNG}" ]]; then
59
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
60
fi
61