Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Optimized asset script for Mint-Y-theme, GTK3 variant
#! /bin/bash
INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"
SRC_FILE="assets.svg"
ASSETS_DIR="assets"
INDEX="assets.txt"
TEMP_INDEX="assets.tmp"
for i in `cat $INDEX`
do
if [ -f $ASSETS_DIR/$i.png ]; then
echo $ASSETS_DIR/$i.png exists.
else
echo $i >> $TEMP_INDEX
fi
done
if [ -f $TEMP_INDEX ]; then
echo Rendering...
awk \
'{ print "--export-id=" $0,
"--export-id-only",
"--export-png='$ASSETS_DIR'/" $0 ".png '$SRC_FILE'" }
{ print "--export-id=" $0,
"--export-dpi=180",
"--export-id-only",
"--export-png='$ASSETS_DIR'/" $0 "@2.png '$SRC_FILE'" }
END { print "quit" }' $TEMP_INDEX | \
$INKSCAPE --shell | awk -F":" '{ if ($1 ~ /Bitmap/) print "Exporting" $2 }'
echo Optimizing...
for i in `cat $TEMP_INDEX`
do
$OPTIPNG -o7 --quiet $ASSETS_DIR/$i.png
done
rm $TEMP_INDEX
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment