#!/bin/sh # Resize orignal icons (64x64) to the lower size # This script requires ImagemagicK # Global variables if [ "$UID" = "0" ]; then BASEDIR="/usr/share/icons" else BASEDIR="$HOME/.icons" fi DEF_SIZES="64x64 48x48 32x32" DEF_SIZE="48x48" SIZES="48x48 32x32 16x16" DIRS="apps devices filesystems" usage() { cat << _EOF_ Completing KDE Icons by converting icons from $DEF_SIZE to $SIZES. Usage: iconsizer [icons] Example: iconsizer Original _EOF_ exit 0 } cicon() { BNAME=`basename $ICON` if [ -h $SIZE/$DIR/$BNAME ]; then rm -f $SIZE/$DIR/$BNAME fi if [ ! -f $SIZE/$DIR/$BNAME ]; then convert $ICON -resize $SIZE $SIZE/$DIR/$BNAME return 0 fi return 1 } micons() { if [ "$*" ]; then for II in $* ; do for DEF_SIZE in $DEF_SIZES; do ICON=$DEF_SIZE/$DIR/$II.png if [ -f $ICON ]; then cicon && echo -n "$BNAME " break fi done done else for ICON in $DEF_SIZE/$DIR/*.png; do cicon && echo -n "." done fi } mdir() { for DIR in $DIRS; do mkdir -p $SIZE/$DIR micons $* done } msize() { for SIZE in $SIZES; do echo -n "$SIZE: " mdir $* echo done } ###################################################################### # Main program [ "$1" == "" ] && usage [ "$1" == "-h" ] && usage [ "$1" == "--help" ] && usage if [ -d $1 ]; then THEMEDIR=$1 elif [ -d $BASEDIR/$1 ]; then THEMEDIR=$BASEDIR/$1 else echo "Cannot find icons $1" exit 1 fi shift pushd $THEMEDIR msize $* popd