3 # The file from which to extract *.ico files.
4 #rscFile="./KeePass.exe"
7 # A regexp that can extract the image size from the file name.
8 # sizeRegex='[^\.]+\.exe_[0-9]+_[0-9]+_[0-9]+_[0-9]+_([0-9]+x[0-9]+)x[0-9]+\.png'
14 # A regexp that can extract the name of the target image from the file name.
15 # nameRegex='([^\.]+)\.exe.+'
24 # An optional temp dir. TODO: Generate it randomly by default instead.
26 if [ "" != "$4" ]; then
32 rm -rf $tmp/png
$tmp/ico
33 mkdir
-p $tmp/png
$tmp/ico
35 # Extract the ressource file's extension.
36 rscFileExt
=`echo "$rscFile" | sed -re 's/.+\.(.+)$/\1/'`
38 # Debug ressource file extension.
39 echo "rscFileExt=$rscFileExt"
41 if [ "ico" = "$rscFileExt" ]; then
42 cp -p $rscFile $tmp/ico
44 wrestool
-x --output=$tmp/ico
-t14 $rscFile
47 icotool
--icon -x --palette-size=0 -o $tmp/png
$tmp/ico
/*.ico
51 for i
in $tmp/png
/*.png
; do
53 size
=$
(echo $fn |
sed -re 's/'${sizeRegex}'/'${sizeReplaceExp}'/')
54 name
=$
(echo $fn |
sed -re 's/'${nameRegex}'/'${nameReplaceExp}'/')
55 targetDir
=$out/share
/icons
/hicolor
/$size/apps
56 targetFile
=$targetDir/$name.png
61 rm -rf $tmp/png
$tmp/ico