Subversion Repositories My Stuff

Rev

Rev 7 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
1
#!/bin/sh
1
#!/bin/sh
2
2
3
#####################################################################
3
#####################################################################
4
# Script to replace the standard KDE 4 start icon with Gentoo Logo 
4
# Script to replace the standard KDE 4 start icon with Gentoo Logo 
5
# The logo can be downloaded here:
5
# The logo can be downloaded here:
6
# http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg
6
# http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg
7
# This script is distributed in the hope that it will be useful,
7
# This script is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
# GNU General Public License for more details.
10
# GNU General Public License for more details.
11
# Author: Andrzej Kardaś
11
# Author: Andrzej Kardaś
12
# License: GPLv3 
12
# License: GPLv3 
13
# The full version of the licencse can be obtainted by visiting: 
13
# The full version of the licencse can be obtainted by visiting: 
14
# http://www.gnu.org/licenses/gpl.html
14
# http://www.gnu.org/licenses/gpl.html
15
#######################################################################
15
#######################################################################
16
16
17
ICON=gentoo-start-icon.svg
17
ICON=gentoo-start-icon.svg
18
RESOLUTION=(16x16 22x22 32x32 48x48 64x64 128x128 256x256)
18
RESOLUTION=(16x16 22x22 32x32 48x48 64x64 128x128 256x256)
19
URL="http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg"
19
URL="http://gentoo-art.org/CONTENT/content-files/117383-gentoo-start-icon.svg"
20
WGET=`/usr/bin/wget`
-
 
21
MV=`/bin/mv`
-
 
22
CP=`/bin/cp`
-
 
23
RM=`/bin/rm`
-
 
-
 
20
WGET="/usr/bin/wget"
-
 
21
MV="/bin/mv"
-
 
22
CP="/bin/cp"
-
 
23
RM="/bin/rm"
24
24
25
if [ "${1}" = "global" ]; then
25
if [ "${1}" = "global" ]; then
26
        PATH="/usr/share/icons/"       
26
        PATH="/usr/share/icons/"       
27
elif [ "${1}" = "local" ]; then
27
elif [ "${1}" = "local" ]; then
28
        PATH=`echo ~/.kde4/share/icons/`
28
        PATH=`echo ~/.kde4/share/icons/`
29
else
29
else
30
        echo
30
        echo
31
        echo "Usage ./kde-icon.sh local | global [theme_name] [restore]"
31
        echo "Usage ./kde-icon.sh local | global [theme_name] [restore]"
32
        echo
32
        echo
33
        echo "Examples:"
33
        echo "Examples:"
34
        echo "If you want to change the icons just run:"
34
        echo "If you want to change the icons just run:"
35
        echo "./kde-icon.sh local OxygenRefit2-black-version"
35
        echo "./kde-icon.sh local OxygenRefit2-black-version"
36
        echo
36
        echo
37
        echo "If you want to restore old icons run:"
37
        echo "If you want to restore old icons run:"
38
        echo "./kde-icon.sh local OxygenRefit2-black-version restore"
38
        echo "./kde-icon.sh local OxygenRefit2-black-version restore"
39
        echo
39
        echo
40
        exit 1
40
        exit 1
41
fi
41
fi
42
42
43
if [ "${#}" -eq 1 ]; then
43
if [ "${#}" -eq 1 ]; then
44
        echo "You didn't provide a theme_name I'm assuming we are changing the oxygen default icon theme"
44
        echo "You didn't provide a theme_name I'm assuming we are changing the oxygen default icon theme"
45
        echo
45
        echo
46
        THEME="oxygen"
46
        THEME="oxygen"
47
else
47
else
48
   THEME=${2}
48
   THEME=${2}
49
fi
49
fi
50
50
51
echo "Checking if full theme path: ${PATH}${THEME} exists"
51
echo "Checking if full theme path: ${PATH}${THEME} exists"
52
echo
52
echo
53
if [ -d ${PATH}${THEME} ]; then
53
if [ -d ${PATH}${THEME} ]; then
54
        echo "Path seems ok"
54
        echo "Path seems ok"
55
        echo
55
        echo
56
else
56
else
57
        echo "Can not find the provided path check script parameters"
57
        echo "Can not find the provided path check script parameters"
58
        echo
58
        echo
59
        exit 1
59
        exit 1
60
fi
60
fi
61
61
62
echo "Checking if you have write access to theme path"
62
echo "Checking if you have write access to theme path"
63
echo
63
echo
64
if [ -w ${PATH}${THEME} ]; then
64
if [ -w ${PATH}${THEME} ]; then
65
        echo "Your rights seems ok"
65
        echo "Your rights seems ok"
66
        echo
66
        echo
67
else
67
else
68
        echo "You do not have write access to the theme path you will not be able to change the icons" 
68
        echo "You do not have write access to the theme path you will not be able to change the icons" 
69
        echo "Maybe you should run the script as root"
69
        echo "Maybe you should run the script as root"
70
        echo
70
        echo
71
        exit 1
71
        exit 1
72
fi
72
fi
73
73
74
if [ "${3}" == "restore" ] ; then
74
if [ "${3}" == "restore" ] ; then
75
        echo "You requested restoration of previously stored icons"
75
        echo "You requested restoration of previously stored icons"
76
        echo
76
        echo
77
        echo "Checking if stored copies of old icons are available and performing restore if possible"
77
        echo "Checking if stored copies of old icons are available and performing restore if possible"
78
        for i in  "${RESOLUTION[@]}";
78
        for i in  "${RESOLUTION[@]}";
79
        do
79
        do
80
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
80
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
81
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png.bak ]; then
81
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png.bak ]; then
82
                        if  [ -w ${PATH}${THEME}/$i/places/start-here-kde.svg ]; then
82
                        if  [ -w ${PATH}${THEME}/$i/places/start-here-kde.svg ]; then
83
                                echo "Removing svg icon: ${PATH}${THEME}/$i/places/start-here-kde.svg"
83
                                echo "Removing svg icon: ${PATH}${THEME}/$i/places/start-here-kde.svg"
84
                                ${RM} ${PATH}${THEME}/$i/places/start-here-kde.svg
84
                                ${RM} ${PATH}${THEME}/$i/places/start-here-kde.svg
85
                                echo
85
                                echo
86
                        fi
86
                        fi
87
                        echo "Restoring old icons"
87
                        echo "Restoring old icons"
88
                        ${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png.bak ${PATH}/${THEME}/$i/places/start-here-kde.png
88
                        ${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png.bak ${PATH}/${THEME}/$i/places/start-here-kde.png
89
                        echo
89
                        echo
90
                else
90
                else
91
                        echo "Can't find ${PATH}${THEME}/$i/places/start-here-kde.png.bak or you do not have write access to file"
91
                        echo "Can't find ${PATH}${THEME}/$i/places/start-here-kde.png.bak or you do not have write access to file"
92
                        echo
92
                        echo
93
                fi
93
                fi
94
        done
94
        done
95
        echo "Finished"
95
        echo "Finished"
96
        echo "To see the changes you need to change the icon set using KDE system settings"
96
        echo "To see the changes you need to change the icon set using KDE system settings"
97
        echo
97
        echo
98
else
98
else
99
        echo "Downloading the logo icon"
99
        echo "Downloading the logo icon"
100
        echo
100
        echo
101
        ${WGET} --output-document=${ICON} ${URL} || die "downloading of the icon failed"
101
        ${WGET} --output-document=${ICON} ${URL} || die "downloading of the icon failed"
102
102
103
        echo "Making backup of existing icons"
103
        echo "Making backup of existing icons"
104
        echo
104
        echo
105
        for i in  "${RESOLUTION[@]}";
105
        for i in  "${RESOLUTION[@]}";
106
        do
106
        do
107
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
107
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.png
108
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png ]; then
108
                if [ -w ${PATH}${THEME}/$i/places/start-here-kde.png ]; then
109
                        if (${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png ${PATH}/${THEME}/$i/places/start-here-kde.png.bak) then
109
                        if (${MV} -f ${PATH}${THEME}/$i/places/start-here-kde.png ${PATH}/${THEME}/$i/places/start-here-kde.png.bak) then
110
                                echo "Storing ${PATH}${THEME}/$i/places/start-here-kde.png as ${PATH}/${THEME}/$i/places/start-here-kde.png.bak succsesfull"
110
                                echo "Storing ${PATH}${THEME}/$i/places/start-here-kde.png as ${PATH}/${THEME}/$i/places/start-here-kde.png.bak succsesfull"
111
                                echo
111
                                echo
112
                        else
112
                        else
113
                                echo "There was error while storing icon ${PATH}${THEME}/$i/places/start-here-kde.png"
113
                                echo "There was error while storing icon ${PATH}${THEME}/$i/places/start-here-kde.png"
114
                        fi
114
                        fi
115
                else
115
                else
116
                        echo "Icon ${PATH}${THEME}/$i/places/start-here-kde.png dosn't exist or you don't have the write access to it!"
116
                        echo "Icon ${PATH}${THEME}/$i/places/start-here-kde.png dosn't exist or you don't have the write access to it!"
117
                        echo "I have nothing to do here"
117
                        echo "I have nothing to do here"
118
                        echo
118
                        echo
119
                fi
119
                fi
120
        done
120
        done
121
121
122
        echo
122
        echo
123
        echo "Placing new Icon"
123
        echo "Placing new Icon"
124
        echo
124
        echo
125
        for i in  "${RESOLUTION[@]}";
125
        for i in  "${RESOLUTION[@]}";
126
        do
126
        do
127
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.svg
127
                echo processing ${PATH}${THEME}/$i/places/start-here-kde.svg
128
                if (${CP} ${ICON} ${PATH}${THEME}/$i/places/start-here-kde.svg) then
128
                if (${CP} ${ICON} ${PATH}${THEME}/$i/places/start-here-kde.svg) then
129
                        echo "Placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg succsesfull"
129
                        echo "Placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg succsesfull"
130
                        echo
130
                        echo
131
                else
131
                else
132
                        echo "There was error while placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg"
132
                        echo "There was error while placing icon ${PATH}${THEME}/$i/places/start-here-kde.svg"
133
                        echo
133
                        echo
134
                fi
134
                fi
135
        done
135
        done
136
        echo "I'm Removing the downloaded icon"
136
        echo "I'm Removing the downloaded icon"
137
        ${RM} -f ${ICON}
137
        ${RM} -f ${ICON}
138
        echo
138
        echo
139
        echo "That's all!"
139
        echo "That's all!"
140
        echo "To see the changes you need to change the icon set using KDE system settings"
140
        echo "To see the changes you need to change the icon set using KDE system settings"
141
        echo
141
        echo
142
fi
142
fi