@ -35,6 +35,29 @@ cp -ru animations $THEMEDIR/.
cp -ru panel $THEMEDIR /.
cp -ru panel $THEMEDIR /.
# Takes in an svg-file and an object-id and formats it
# to an inkscape export shell command that inkscape can
# then execute.
formatInkscapeCmd( ) {
local CONTEXT = $1
local OBJECT_ID = $2
local SIZE = $( sed -r 's/.*\_([0-9]+).*$/\1/' <<< $OBJECT_ID )
local ICON_NAME = $( sed " s/\_ $SIZE .* $// " <<< $OBJECT_ID )
echo \
" --export-id= $OBJECT_ID " \
"--export-id-only" \
" --export-png= $THEMEDIR / $CONTEXT / $SIZE / $ICON_NAME .png $CONTEXT .svg "
echo \
" --export-id= $OBJECT_ID " \
"--export-dpi=180" \
"--export-id-only" \
" --export-png= $THEMEDIR / $CONTEXT / $SIZE @2x/ $ICON_NAME .png $CONTEXT .svg "
}
# Generates inkscape export commands for the given
# Generates inkscape export commands for the given
# svg-file that can be piped to inkscape.
# svg-file that can be piped to inkscape.
genInkscapeCmds( ) {
genInkscapeCmds( ) {
@ -43,37 +66,56 @@ genInkscapeCmds() {
for SIZE in ${ SIZES [@] }
for SIZE in ${ SIZES [@] }
do
do
echo " Rendering icons $CONTEXT .svg @ $SIZE " >& 2
for OBJECT_ID in ` cat <( $INKSCAPE -S $CONTEXT .svg | grep -E " _ $SIZE " | sed 's/\,.*$//' ) `
for OBJECT_ID in ` cat <( $INKSCAPE -S $CONTEXT .svg | grep -E " _ $SIZE " | sed 's/\,.*$//' ) `
do
do
local ICON_NAME = $( sed " s/\_ $SIZE .* $// " <<< $OBJECT_ID )
echo $OBJECT_ID >> .$CONTEXT .cache.tmp
formatInkscapeCmd $CONTEXT $OBJECT_ID
echo \
" --export-id= $OBJECT_ID " \
"--export-id-only" \
" --export-png= $THEMEDIR / $CONTEXT / $SIZE / $ICON_NAME .png $CONTEXT .svg "
echo \
" --export-id= $OBJECT_ID " \
"--export-dpi=180" \
"--export-id-only" \
" --export-png= $THEMEDIR / $CONTEXT / $SIZE @2x/ $ICON_NAME .png $CONTEXT .svg "
done
done
done
done
mv .$CONTEXT .cache.tmp .$CONTEXT .cache
}
}
for CONTEXT in ${ TYPES [@] }
# Generates inkscape export commands that matches
do
# the provided regex pattern.
# Only render out the icons if the svg-file has been modified
genInkscapeCmdsFiltered( ) {
# since we finished rendering it out last.
if [ [ $CONTEXT .svg -nt .${ CONTEXT } _timestamp ] ]
local CONTEXT = $1
then
local REGEX = $2
echo " Rendering icons from $CONTEXT .svg "
genInkscapeCmds $CONTEXT | java SplitJob $INKSCAPE --shell && touch .${ CONTEXT } _timestamp
while read -r OBJECT_ID
else
do
echo " No changes to $CONTEXT .svg, skipping... "
echo " Match: $OBJECT_ID " >& 2
fi
formatInkscapeCmd $CONTEXT $OBJECT_ID
done
done < <( grep -E $REGEX .$CONTEXT .cache)
}
if [ [ ! -z $1 ] ]
then
echo "Rendering objects with IDs matching regex"
for CONTEXT in ${ TYPES [@] }
do
if [ [ -f .$CONTEXT .cache ] ] || { [ [ ! -f .$CONTEXT .cache ] ] && ( $INKSCAPE -S $CONTEXT .svg | grep -E "_[0-9]+" | sed 's/\,.*$//' > .$CONTEXT .cache.tmp) ; }
then
mv .$CONTEXT .cache.tmp .$CONTEXT .cache 2> /dev/null
genInkscapeCmdsFiltered $CONTEXT $1 | java SplitJob $INKSCAPE --shell
else
echo " Failed creating creating object-ID cache for $CONTEXT .svg "
fi
done
else
for CONTEXT in ${ TYPES [@] }
do
# Only render out the icons if the svg-file has been modified
# since we finished rendering it out last.
if [ [ $CONTEXT .svg -nt .${ CONTEXT } _timestamp ] ]
then
echo " Rendering icons from $CONTEXT .svg "
genInkscapeCmds $CONTEXT | java SplitJob $INKSCAPE --shell && touch .${ CONTEXT } _timestamp
else
echo " No changes to $CONTEXT .svg, skipping... "
fi
done
fi
# Remove all empty directories from the theme folder.
# Remove all empty directories from the theme folder.
find $THEMEDIR -type d -empty -delete
find $THEMEDIR -type d -empty -delete