mkdir -p $PKG/usr/share/icons
cp -rf FlatWoken $PKG/usr/share/icons

cat ${CWD}/index.theme > ${PKG}/usr/share/icons/FlatWoken/index.theme

svg2png(){
for file in *.svg ; do 
	if [ "$(ls -l ${file} | grep "^l")" ] ; then
		linktarget="$(ls -l ${file} | sed -e 's/.* -> \(.*\)$/\1/')"
		unlink ${file}
		ln -s ${linktarget%%.svg}.png ${file%%.svg}.png 
		continue
	fi
	inkscape --export-width=${1} --export-png=${file%%.svg}.png ${file}
	echo ${file%%.svg}.png 
done
}



(
cd ${PKG}/usr/share/icons/FlatWoken
	(
		cd 22x22
		for dir in ./* ; do
			mkdir -p ${PKG}/usr/share/icons/FlatWoken/scalable/$(basename ${dir})
			cp $(basename ${dir})/* ${PKG}/usr/share/icons/FlatWoken/scalable/$(basename ${dir})/
		done
	)
	for size in 16 22 24 32 48 64 96 128 ; do 
		rm -rf ${size}x${size}
		cp -rf scalable ${size}x${size} 
		(
			cd ${size}x${size}
			for dir in ./* ; do
				(
					cd ${dir}
					svg2png ${size}
					rm *.svg
				)
			done
		)
	done
	rm -rf scalable
)
