scripts: Simplify render-assets.sh
Don't remove, just overwrite when rendering assets.
Don't remove, just overwrite when rendering assets.
by roundabout, Wednesday, 13 June 2018, 16:22:39 (1528906959), pushed by roundabout, Sunday, 11 May 2025, 13:22:26 (1746969746)
Author identity: nana-4 <hnmaigo@gmail.com>
68cb93633bc6ed3960d36fc9fff63e640fa00f2a
gtk() (
cd src/gtk
rm assets/*.png || :
./render-assets.sh
)
gtk2_light() (
cd src/gtk-2.0
rm assets/*.png || :
./render-assets.sh light
)
gtk2_dark() (
cd src/gtk-2.0
rm assets-dark/*.png || :
./render-assets.sh dark
)
*)
echo "Unknown argument: '$1'"
echo "Use 'gtk', 'gtk2', 'gtk2-light' or 'gtk2-dark' as an argument."
exit 1
;;
esac
#! /bin/bash
#!/bin/bash
set -ueo pipefail
INKSCAPE="$(which inkscape)"
EXTRA_OPTIONS=()
fi
if [[ -f "$ASSETS_DIR/$i.png" ]]; then
echo "'$ASSETS_DIR/$i.png' exists."
else
echo "Rendering '$ASSETS_DIR/$i.png'"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-background-opacity=0 \
${EXTRA_OPTIONS+"${EXTRA_OPTIONS[@]}"} \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi
exit 0
echo "Rendering '$ASSETS_DIR/$i.png'"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
${EXTRA_OPTIONS+"${EXTRA_OPTIONS[@]}"} \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
#! /bin/bash
#!/bin/bash
set -ueo pipefail
# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if which parallel > /dev/null; then cmd=(parallel)
else cmd=(xargs -n1); fi
if [[ "$(which parallel 2> /dev/null)" ]]; then
cmd=(parallel)
else
cmd=(xargs -n1)
fi
"${cmd[@]}" ./render-asset.sh "$1" < assets.txt
#! /bin/bash
#!/bin/bash
set -ueo pipefail
INKSCAPE="$(which inkscape)"
i="$1"
if [[ -f "$ASSETS_DIR/$i.png" ]]; then
echo "'$ASSETS_DIR/$i.png' exists."
else
echo "Rendering '$ASSETS_DIR/$i.png'"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi
echo "Rendering '$ASSETS_DIR/$i.png'"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
if [[ -f "$ASSETS_DIR/$i@2.png" ]]; then
echo "'$ASSETS_DIR/$i@2.png' exists."
else
echo "Rendering '$ASSETS_DIR/$i@2.png'"
"$INKSCAPE" --export-id="$i" \
--export-dpi=192 \
--export-id-only \
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
fi
exit 0
echo "Rendering '$ASSETS_DIR/$i@2.png'"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-dpi=192 \
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
#! /bin/bash
#!/bin/bash
set -ueo pipefail
# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if which parallel > /dev/null; then cmd=(parallel)
else cmd=(xargs -n1); fi
if [[ "$(which parallel 2> /dev/null)" ]]; then
cmd=(parallel)
else
cmd=(xargs -n1)
fi
"${cmd[@]}" ./render-asset.sh < assets.txt