mirror of
https://github.com/horst3180/arc-icon-theme
synced 2024-10-27 19:34:01 +00:00
Add filtered rendering
Instead of rendering out everything in an svg-file, the render script now takes in a regular expression that is uses to search all the object-IDs inside each of the svg-files for a match and only renders those. To make the search go faster all object-IDs are stored in files named ".<svg-file-name>.cache" after every full render of an svg-file or if none exist.
This commit is contained in:
parent
525b4a2663
commit
d37d54fd87
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ install-sh
|
|||||||
missing
|
missing
|
||||||
*.tmp
|
*.tmp
|
||||||
*_timestamp
|
*_timestamp
|
||||||
|
*.cache
|
||||||
|
@ -35,17 +35,15 @@ cp -ru animations $THEMEDIR/.
|
|||||||
cp -ru panel $THEMEDIR/.
|
cp -ru panel $THEMEDIR/.
|
||||||
|
|
||||||
|
|
||||||
# Generates inkscape export commands for the given
|
# Takes in an svg-file and an object-id and formats it
|
||||||
# svg-file that can be piped to inkscape.
|
# to an inkscape export shell command that inkscape can
|
||||||
genInkscapeCmds() {
|
# then execute.
|
||||||
|
formatInkscapeCmd() {
|
||||||
|
|
||||||
local CONTEXT=$1
|
local CONTEXT=$1
|
||||||
|
local OBJECT_ID=$2
|
||||||
|
local SIZE=$(sed -r 's/.*\_([0-9]+).*$/\1/' <<< $OBJECT_ID)
|
||||||
|
|
||||||
for SIZE in ${SIZES[@]}
|
|
||||||
do
|
|
||||||
echo "Rendering icons $CONTEXT.svg @$SIZE" >&2
|
|
||||||
for OBJECT_ID in `cat <($INKSCAPE -S $CONTEXT.svg | grep -E "_$SIZE" | sed 's/\,.*$//')`
|
|
||||||
do
|
|
||||||
local ICON_NAME=$(sed "s/\_$SIZE.*$//" <<< $OBJECT_ID)
|
local ICON_NAME=$(sed "s/\_$SIZE.*$//" <<< $OBJECT_ID)
|
||||||
|
|
||||||
echo \
|
echo \
|
||||||
@ -58,12 +56,55 @@ genInkscapeCmds() {
|
|||||||
"--export-dpi=180" \
|
"--export-dpi=180" \
|
||||||
"--export-id-only" \
|
"--export-id-only" \
|
||||||
"--export-png=$THEMEDIR/$CONTEXT/$SIZE@2x/$ICON_NAME.png $CONTEXT.svg"
|
"--export-png=$THEMEDIR/$CONTEXT/$SIZE@2x/$ICON_NAME.png $CONTEXT.svg"
|
||||||
done
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for CONTEXT in ${TYPES[@]}
|
# Generates inkscape export commands for the given
|
||||||
do
|
# svg-file that can be piped to inkscape.
|
||||||
|
genInkscapeCmds() {
|
||||||
|
|
||||||
|
local CONTEXT=$1
|
||||||
|
|
||||||
|
for SIZE in ${SIZES[@]}
|
||||||
|
do
|
||||||
|
for OBJECT_ID in `cat <($INKSCAPE -S $CONTEXT.svg | grep -E "_$SIZE" | sed 's/\,.*$//')`
|
||||||
|
do
|
||||||
|
echo $OBJECT_ID >> .$CONTEXT.cache.tmp
|
||||||
|
formatInkscapeCmd $CONTEXT $OBJECT_ID
|
||||||
|
done
|
||||||
|
done
|
||||||
|
mv .$CONTEXT.cache.tmp .$CONTEXT.cache
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generates inkscape export commands that matches
|
||||||
|
# the provided regex pattern.
|
||||||
|
genInkscapeCmdsFiltered() {
|
||||||
|
|
||||||
|
local CONTEXT=$1
|
||||||
|
local REGEX=$2
|
||||||
|
|
||||||
|
while read -r OBJECT_ID
|
||||||
|
do
|
||||||
|
echo "Match: $OBJECT_ID" >&2
|
||||||
|
formatInkscapeCmd $CONTEXT $OBJECT_ID
|
||||||
|
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
|
# Only render out the icons if the svg-file has been modified
|
||||||
# since we finished rendering it out last.
|
# since we finished rendering it out last.
|
||||||
if [[ $CONTEXT.svg -nt .${CONTEXT}_timestamp ]]
|
if [[ $CONTEXT.svg -nt .${CONTEXT}_timestamp ]]
|
||||||
@ -73,7 +114,8 @@ do
|
|||||||
else
|
else
|
||||||
echo "No changes to $CONTEXT.svg, skipping..."
|
echo "No changes to $CONTEXT.svg, skipping..."
|
||||||
fi
|
fi
|
||||||
done
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user