All pastes #422661 Raw Edit

Something

public shellscript v1 · immutable
·published 2007-04-03 16:38 UTC
rendered paste body
#!/bin/bash# (C) Nick Bargnesi nbargnesi at den-4.com# This script is distributed under the GPL.  See the file GPL.# If you make any improvements, feel free to email me any changes. nbargnesi at den-4.com# PACKAGENAME is the final tarred, compressed, iconset.PACKAGENAME="Name-of-iconset"REQUIRED_SIZES="32x32 22x22 16x16"# DEFINE NEW SIZES HERE#	These are sizes for everything except the actions folder, which contains#	menu and toolbar related stuff for KDE.  Add or remove a size here, I#	would recommend not removing the 32, 22, and 16 sizes.SIZES="96x96 72x72 64x64 48x48 128x128 $REQUIRED_SIZES"DIRS="apps devices filesystems mimetypes" # no actions directory needed, its hardcodedCONVERT_PATH=TAR_PATH=COMPRESSOR=function checkCompressor() {	echo -ne "Checking for bzip2... "	FOUND=`which bzip2`	if [ "$FOUND" != "" ]; then		echo -ne "found $FOUND\n"		COMPRESSOR=$FOUND		return	else		echo -ne " no.\n"		echo -ne "Checking for gzip... "		FOUND=`which gzip`		if [ "$FOUND" != "" ]; then			echo -ne "found $FOUND\n"			COMPRESSOR=$FOUND			return		else			echo -ne " no.\n"			echo -ne "\nNo compressor found (bzip2 | gzip).\n"			exit 1		fi	fi}function checkNeeded() {	echo -ne "Checking for tar... "	FOUND=`which tar`	if [ "$FOUND" != "" ]; then		echo -ne " found $FOUND\n"		TAR_PATH=$FOUND		echo -ne "Checking for convert... "		FOUND=`which convert`		if [ "$FOUND" != "" ]; then			echo -ne " found $FOUND\n"			CONVERT_PATH=$FOUND			return		else			echo -ne " no.\n"			echo -ne "\nNo convert found in path.\n"			exit 1		fi	else		echo -ne " no.\n"		echo -ne "\nNo tar found in path.\n"		exit 1	fi}function printFound() {	echo -ne "\nDependencies met - this script is using:\n"	echo -ne "\t\t$COMPRESSOR as compressor\n"	echo -ne "\t\t$TAR_PATH as tar path\n"	echo -ne "\t\t$CONVERT_PATH as convert path\n"}echo -ne "This script builds an installable iconset using bash and convert.\n"echocheckCompressorcheckNeededprintFound#echo#echo -ne "You get your choice of kmenu icons.  Select from: \n"#echo -ne "\n\txeyes, redhat, mandrake, suse, openbsd, or nvidia and enter it now\n"#read KMENU_ICON#echo -ne "Using $KMENU_ICON.png as your kmenu icon.\n"#if test -f 256x256/apps/$KMENU_ICON.png#	then#		cp -f 256x256/apps/$KMENU_ICON.png 256x256/apps/kmenu.png#		cp -f 256x256/apps/$KMENU_ICON.png 256x256/apps/go.png#	else#		echo -ne "Invalid selection ($KMENU_ICON), exiting...\n"#		exit 1#fiecho -ne "Ready to go!  Converting all icons! (about 15 seconds on an Athlon 64)\n"echo#Loop directory creation according to SIZES specified at startupfor size in $SIZESdo	mkdir -p $size/apps $size/devices $size/mimetypes $size/filesystemsdone# Required sizes for actionsmkdir -p 22x22/actions 16x16/actions# Mmmm... loops...for dir in $DIRSdo	cd 256x256/$dir	for icon in *	do		# Loop the specified sizes		for size in $SIZES		do			convert "$icon" -resize $size ../../$size/$dir/"$icon"		done	done	# Move from 256x256/$directory to toplevel	cd ../../done# Move from 256x256/ to 32x32/cd 32x32/actionsfor icon in *do	convert "$icon" -resize 22x22 ../../22x22/actions/"$icon"	convert "$icon" -resize 16x16 ../../16x16/actions/"$icon"done# Move to top directorycd ../../mkdir $PACKAGENAMEcp -R 256x256 $PACKAGENAMEcp -R 32x32 $PACKAGENAMEcp index.desktop $PACKAGENAME# Move/Remove the created directories so the user can rebuild if needed.rm -fr 32x32/apps 32x32/devices 32x32/mimetypes 32x32/filesystemsfor size in $SIZESdo	if [ "$size" != "32x32" ]; then # Already did the 32x32 size above		mv $size $PACKAGENAME	fidoneecho -ne "Creating Symlinks to Legacy Icon Naming Conventions (GNOME/KDE/XFCE)"for i in */*; do context=`basename $i`; path=`dirname $i`; if [ -d $i ]; then (cd $path && /usr/local/libexec/icon-name-mapping -c $context); fi; doneecho -ne "Done with conversions.\n"echo -ne "Tarring and compressing.\n"if test -f $COMPRESSOR	then		tar cf $PACKAGENAME.tar $PACKAGENAME && $COMPRESSOR $PACKAGENAME.tar		echo -ne "$PACKAGENAME has been built.  Use kcontrol to install it.\n"		echo && ls -sh $PACKAGENAME.tar* && echofiecho -ne "Removing temporary directory...\n"rm -fr $PACKAGENAMEecho -ne "\nAll done. ;)\n"