Friday, April 24, 2009

Script to change icons in fvwm-crystal menus

I'm using fvwm-crystle because it is:
1. light weight
2. eyecandy
3. user friendly
4. customizable
5. different

see the screenshot:

Script:


#!/bin/bash

if [[ $1 == '' ]]
then
echo "usage"
echo "$0 [comparable icon name]"
exit 0
fi

FVWM_ICON_PATH="/usr/share/fvwm-crystal/fvwm/icons/Default"
ICON_NAME=$1.png
ICON_PATH=""
ICON_PATH_ARR=""

if [[ $2 != '' ]]
then
#ICON_PATH=(`for icon in $( locate $2 | grep -e "\/$2.png" -e "\/$2.jpg" -e "\/$2.svg" ); do echo $icon; done`)
ICON_PATH_ARR=($( locate $2 | grep -e "\/$2.png" -e "\/$2.jpg" -e "\/$2.svg" ))
else
ICON_PATH_ARR=($( locate $1 | grep -e "\/$1.png" -e "\/$1.jpg" -e "\/$1.svg" ))
fi

if [[ $ICON_PATH_ARR == '' ]]
then
echo "Icon not found!!"
exit 0
fi

i=0
while true
do
[[ ${ICON_PATH_ARR[$i]} == '' ]] && break;
echo "$i. ${ICON_PATH_ARR[$i]}"
i=`expr $i + 1`
done

OPT=''
echo "Enter icon number to convert:"
read OPT
if [[ $OPT -lt $i && $OPT -ge 0 ]]
then
ICON_PATH=${ICON_PATH_ARR[$OPT]}
else
echo "wrong"
fi

if [[ $ICON_PATH != '' || $ICON_NAME != '' ]]
then

ANS=""
echo "Icon destination: $ICON_PATH"
echo "Icon name: $ICON_NAME"
echo "Continue creating icons? [y/n]: "
read ANS
if [[ $ANS == 'y' ]]
then
#convert $ICON_PATH -resize 16 -format 'png' $FVWM_ICON_PATH/16x16/$ICON_NAME
convert $ICON_PATH -resize 22 -format 'png' $FVWM_ICON_PATH/22x22/apps/$ICON_NAME
convert $ICON_PATH -resize 32 -format 'png' $FVWM_ICON_PATH/32x32/apps/$ICON_NAME
convert $ICON_PATH -resize 48 -format 'png' $FVWM_ICON_PATH/48x48/apps/$ICON_NAME
else
echo "Icons not creating!!"
fi
else
echo "Icon Not found!!!"
fi


It is easy to add icons. Save the script to a file (/usr/bin/fvwm-crystal-change-icons.sh) and make it executable (chmod +x /usr/bin/fvwm-crystal-change-icons.sh ) and then type

/usr/bin/fvwm-crystal-change-icons.sh [comparable icon name]

Here is mandatory and and it is the name of the correspoding application. [comparable icon name] is compulsary, if icon with the given name is not available give the applicationn name as and also a comparable icon name

No comments:

Post a Comment