#!/bin/sh # Convert IceWM Icons from KDE's # This script requires ImagemagicK # Global variables if [ "$UID" = "0" ]; then BASEDIR="/usr/share/icons" BASETARGET="/usr/share/icons" else BASEDIR="$HOME/.icons" BASETARGET="$HOME/,icewm" fi SIZES="16x16 32x32" EXCLUDES=" folder file_locked folder_cyan folder_gnome folder_yellow exec_wine file_important folder_wordprocessing file_temporary folder_txt folder_cd folder_yellow_open folder_violet shredder folder_important folder_penguin blockdevice zip folder_orange_open folder_violet_open folder_grey_open folder_cyan_open folder_sound folder_html folder_image temporary folder_grey pipe file_broken desktop folder_red_open lockoverlay socket folder_orange folder_blue_open home_white folder_kde folder folder_red services home_blue folder_midi network_local folder_locked folder_blue folder_print2 camera exec folder_man desktop2 folder_tar folder_open folder_green folder_video link folder_green_open " show_help() { echo "Usage: iconicewm [ice_icons]" echo "Convert KDE icon theme to IceWM icons" echo echo "Example" echo echo "iconicewm theme" echo " convert $BASEDIR/theme to $BASETARGET/ICE-theme" exit 0 } # substitute a theme # vars: THEMEDIR, DEFAULT, SIZES mtheme() { mkdir -p $TARGET if [ ! $? = 0 ]; then echo Can not create $TARGET, FAILED ! return 1 fi echo Converting $TARGET ... IMAGES=0 SYMLINKS=0 for DIR in apps devices filesystems; do for ICON in $THEMEDIR/32x32/$DIR/*.png ; do NAME=`basename $ICON .png` if echo "$EXCLUDES" | grep -qw $NAME; then continue fi if [ -L $ICON ]; then ICON1=`readlink $ICON` NAME1=`basename $ICON1 .png` [ ! -f $TARGET/${NAME1}_32x32.xpm ] && \ convert $THEMEDIR/32x32/$DIR/$ICON1 $TARGET/${NAME1}_32x32.xpm [ ! -f $TARGET/${NAME1}_16x16.xpm ] && \ convert $THEMEDIR/32x32/$DIR/$ICON1 -resize 16x16 $TARGET/${NAME1}_16x16.xpm echo -n '-' pushd $TARGET > /dev/null ln -sf ${NAME1}_32x32.xpm ${NAME}_32x32.xpm ln -sf ${NAME1}_16x16.xpm ${NAME}_16x16.xpm popd > /dev/null let SYMLINKS=$SYMLINKS+1 else [ ! -f "$TARGET/${NAME}_32x32.xpm" ] && convert $ICON $TARGET/${NAME}_32x32.xpm [ ! -f "$TARGET/${NAME}_16x16.xpm" ] && convert $ICON -resize 16x16 $TARGET/${NAME}_16x16.xpm echo -n '+' let IMAGES=$IMAGES+1 fi done done rm $TARGET/folder_??x??.xpm if [ ! -f $TARGET/index.icewm ]; then echo echo "#Converted from KDE Icon theme by iconicewm" > $TARGET/index.icewm echo "[IceWM Icon Theme]" >> $TARGET/index.icewm if [ -f $THEMEDIR/index.theme ]; then NAME=`grep -e "^Name=" $THEMEDIR/index.theme` echo "$NAME for IceWM" >> $TARGET/index.icewm grep -m 1 -e "^Comment=" $THEMEDIR/index.theme >> $TARGET/index.icewm elif [ -f $THEMEDIR/index.desktop ]; then NAME=`grep -e "^Name=" $THEMEDIR/index.desktop` echo "$NAME for IceWM" >> $TARGET/index.icewm grep -m 1 -e "^Comment=" $THEMEDIR/index.desktop >> $TARGET/index.icewm else NAME=`basename $THEMEDIR` echo "$NAME for IceWM" >> $TARGET/index.icewm echo "Comment=$NAME converted by iconicewm" >> $TARGET/index.icewm fi fi echo echo "Total images = $IMAGES" echo "Total symlinks = $SYMLINKS" echo "Calculating size ..." du $TARGET } ###################################################################### # Main program [ "$1" == "" ] && show_help [ "$1" == "-h" ] && show_help [ "$1" == "--help" ] && show_help if [ -d $1 ]; then THEMEDIR=$1 elif [ -d $BASEDIR/$1 ]; then THEMEDIR=$BASEDIR/$1 else echo "Cannot find icons $1" exit 1 fi if ! grep -qe "^[KDE Icon Theme]" $THEMEDIR/index.theme &> /dev/null && ! grep -qe "^[KDE Icon Theme]" $THEMEDIR/index.desktop &> /dev/null ; then echo "Excuse me, $THEMEDIR is not a KDE icon theme" exit 1 fi if [ "$2" ]; then TARGET=$2 else TARGET=`dirname $1`/ICE-`basename $1` fi mtheme