diff options
Diffstat (limited to 'tools/apbuild/make-icons')
-rwxr-xr-x | tools/apbuild/make-icons | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/apbuild/make-icons b/tools/apbuild/make-icons new file mode 100755 index 00000000..32c0c600 --- /dev/null +++ b/tools/apbuild/make-icons @@ -0,0 +1,58 @@ +#!/bin/sh + +# +# This script generates a directory and an automake fragment from an SVG +# file. It's useful when you have an SVG and want to pre-render icons of +# various sizes from it, then install them into the users icon theme. +# +# For autopackage users, put the following line in your specfile: +# +# installIcon share/icons/hicolor +# +# It uses rsvg to render the icons + +if [[ "$1" == "" ]] || [[ "$2" == "" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then + echo "Usage: make-icons myprogram.svg type" + echo + echo "Generates a subdirectory called icons with an icon theme tree" + echo "in it. Also outputs some automake code you can copy/paste". + echo "" + echo "type is the type of icon and should be one of the following:" + echo "apps, mimetypes, actions, devices, filesystems" + echo "See FDO spec for details--you most likely want apps or mimetypes" + exit 0 +fi + +if ! which rsvg >/dev/null; then + # a part of librsvg + echo "make-icons: this script needs the rsvg program installed" + exit 1 +fi + +if [ ! -e $1 ]; then + echo "make-icons: the given file does not exist" + exit 1 +fi + +if [[ "$2" != "apps" && "$2" != "mimetypes" && "$2" != "actions" && "$2" != "devices" && "$2" != "filesystems" ]]; then + echo "make-icons: $2 is not a valid icon type. type should be one of these:" + echo "apps, mimetypes, actions, devices, filesystems" + echo "See FDO spec for details--you most likely want apps or mimetypes" + exit 1 +fi +mkdir -p icons/scalable/$2 +cp $1 icons/scalable/$2 + +newname="`basename $1`" +echo "iconSVGdir = \$(datadir)/icons/hicolor/scalable/$2" +echo "iconSVG_DATA = icons/scalable/$2/$newname" + +newname="${newname/.svg/}.png" + + +for size in 128 64 48 24 16; do + mkdir -p icons/${size}x${size}/$2 + rsvg --width=$size --height=$size $1 icons/${size}x${size}/$2/$newname + echo "icon${size}dir = \$(datadir)/icons/hicolor/${size}x${size}/$2" + echo "icon${size}_DATA = icons/${size}x${size}/$2/$newname" +done |