Subversion Repositories My Stuff

Rev

Rev 7 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/sh

#####################################################################
# Script to replace the standard KDE 4 start icon with Gentoo Logo
# The logo can be downloaded here:
# http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# Author: Andrzej Kardaƛ
# License: GPLv3
# The full version of the licencse can be obtainted by visiting:
# http://www.gnu.org/licenses/gpl.html
#######################################################################

ICON=gentoo-start-icon.svg
RESOLUTION=(16x16 22x22 32x32 48x48 64x64 128x128 256x256)
URL="http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg"
WGET="/usr/bin/wget"
MV="/bin/mv"
CP="/bin/cp"
RM="/bin/rm"

if [ "${1}" = "global" ]; then
        PATH="/usr/share/icons/"       
elif [ "${1}" = "local" ]; then
        PATH=`echo ~/.kde4/share/icons/`
else
        echo
        echo "Usage ./kde-icon.sh local | global [theme_name] [restore]"
        echo
        echo "Examples:"
        echo "If you want to change the icons just run:"
        echo "./kde-icon.sh local OxygenRefit2-black-version"
        echo
        echo "If you want to restore old icons run:"
        echo "./kde-icon.sh local OxygenRefit2-black-version restore"
        echo
        exit 1
fi

if [ "${#}" -eq 1 ]; then
        echo "You didn't provide a theme_name I'm assuming we are changing the oxygen default icon theme"
        echo
        THEME="oxygen"
else
   THEME=${2}
fi

echo "Checking if full theme path: ${PATH}${THEME} exists"
echo
if [ -d ${PATH}${THEME} ]; then
        echo "Path seems ok"
        echo
else
        echo "Can not find the provided path check script parameters"
        echo
        exit 1
fi

echo "Checking if you have write access to theme path"
echo
if [ -w ${PATH}${THEME} ]; then
        echo "Your rights seems ok"
        echo
else
        echo "You do not have write access to the theme path you will not be able to change the icons" 
        echo "Maybe you should run the script as root"
        echo
        exit 1
fi

if [ "${3}" == "restore" ] ; then
        echo "You requested restoration of previously stored icons"
        echo
        echo "Checking if stored copies of old icons are available and performing restore if possible"
        for i in  "${RESOLUTION[@]}";
        do
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png.bak ]; then
                        if  [ -w ${PATH}${THEME}/$i/places/start-here-kde.svg ]; then
                                echo "Removing svg icon: ${PATH}${THEME}/$i/places/start-here-kde.svg"
                                ${RM} ${PATH}${THEME}/$i/places/start-here-kde.svg
                                echo
                        fi
                        echo "Restoring old icons"
                        ${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png.bak ${PATH}/${THEME}/$i/places/start-here-kde.png
                        echo
                else
                        echo "Can't find ${PATH}${THEME}/$i/places/start-here-kde.png.bak or you do not have write access to file"
                        echo
                fi
        done
        echo "Finished"
        echo "To see the changes you need to change the icon set using KDE system settings"
        echo
else
        echo "Downloading the logo icon"
        echo
        ${WGET} --output-document=${ICON} ${URL} || die "downloading of the icon failed"

        echo "Making backup of existing icons"
        echo
        for i in  "${RESOLUTION[@]}";
        do
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png ]; then
                        if (${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png ${PATH}/${THEME}/$i/places/start-here-kde.png.bak) then
                                echo "Storing ${PATH}${THEME}/$i/places/start-here-kde.png as ${PATH}/${THEME}/$i/places/start-here-kde.png.bak succsesfull"
                                echo
                        else
                                echo "There was error while storing icon ${PATH}${THEME}/$i/places/start-here-kde.png"
                        fi
                else
                        echo "Icon ${PATH}${THEME}/$i/places/start-here-kde.png dosn't exist or you don't have the write access to it!"
                        echo "I have nothing to do here"
                        echo
                fi
        done

        echo
        echo "Placing new Icon"
        echo
        for i in  "${RESOLUTION[@]}";
        do
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.svg
                if (${CP} ${ICON} ${PATH}${THEME}/$i/places/start-here-kde.svg) then
                        echo "Placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg succsesfull"
                        echo
                else
                        echo "There was error while placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg"
                        echo
                fi
        done
        echo "I'm Removing the downloaded icon"
        ${RM} -f ${ICON}
        echo
        echo "That's all!"
        echo "To see the changes you need to change the icon set using KDE system settings"
        echo
fi