forked from keeferrourke/la-capitaine-icon-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·194 lines (169 loc) · 7.82 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
# Copyright (c) 2015-2016 Keefer Rourke <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# this script will update various icon symlinks based on your machine's
# reported distribution and desktop environment
# function declarations
# formats text to lower and removes whitespace and non-alpha chars
format() {
name=$(awk '{print tolower($0)}' <<< $1)
name=$(sed 's/\s+//g;s/[^a-z]//g'<<< $name)
echo $name
}
# attempts to update distributor logos based on detected distro
distromatch() {
case $DISTRO in
arch) ln -sf distributor-logo-archlinux.svg distributor-logo.svg ;;
debian|raspbian) ln -sf distributor-logo-debian.svg distributor-logo.svg ;;
elementaryos|elementary) ln -sf distributor-logo-elementaryos.svg distributor-logo.svg ;;
fedora) ln -sf distributor-logo-fedora.svg distributor-logo.svg ;;
gentoo) ln -sf distributor-logo-gentoo.svg distributor-logo.svg ;;
korora) ln -sf distributor-logo-korora.svg distributor-logo.svg ;;
linuxmint) ln -sf distributor-logo-linuxmint.svg distributor-logo.svg ;;
mageia) ln -sf distributor-logo-mageia.svg distributor-logo.svg ;;
manjaro) ln -sf distributor-logo-manjaro.svg distributor-logo.svg ;;
nixos) ln -sf distributor-logo-nixos.svg distributor-logo.svg ;;
opensuse) ln -sf distributor-logo-opensuse.svg distributor-logo.svg ;;
rosa|rosafreshdesktop) ln -sf distributor-logo-rosa.svg distributor-logo.svg ;;
solus) ln -sf distributor-logo-solus.svg distributor-logo.svg ;;
ubuntu) ln -sf distributor-logo-ubuntu.svg distributor-logo.svg ;;
*) return 1 ;;
esac
}
# in case lsb_release detection fails, try /etc/os-release
alt_distromatch() {
local pattern="ID=arch:ID=opensuse:ID=raspbian:ID=ubuntu:ID=nixos:ID=solus:ID=rosa"
local IFS=:
distro_error=1
for i in $pattern; do
if $(grep -wsq "$i" /etc/os-release); then
DISTRO=${i##*=}
distromatch
distro_error=0
break
fi
done
if [ $distro_error -eq 1 ]; then
echo "Could not determine distribution logo."
ln -sf distributor-logo-gnome.svg distributor-logo.svg
fi
}
# define variables
# set distributor logo based on distro detected through lsb_release
DISTRO=$(format "$(lsb_release -si 2>/dev/null)")
DE=$(format "$XDG_CURRENT_DESKTOP")
distro_error=0
de_error=0
wd=$PWD
# update icons for dark/light GTK themes
read -p "Use icons for dark GTK+ themes? [y/N] " yn
case $yn in
[Yy]* )
rm "$wd/actions/22x22" "$wd/devices/scalable" "$wd/panel/16" \
"$wd/panel/24" "$wd/places/16x16" "$wd/status/scalable"
ln -sfr "$wd/actions/22x22-dark" "$wd/actions/22x22"
ln -sfr "$wd/devices/scalable-dark" "$wd/devices/scalable"
ln -sfr "$wd/emblems/scalable/avatar-default-dark.svg" "$wd/emblems/scalable/avatar-default.svg"
ln -sfr "$wd/places/16x16-dark" "$wd/places/16x16"
echo "Updated theme to use icons for dark GTK+ themes."
;;
* )
rm "$wd/actions/22x22" "$wd/devices/scalable" "$wd/panel/16" \
"$wd/panel/24" "$wd/places/16x16" "$wd/status/scalable"
ln -sfr "$wd/actions/22x22-light" "$wd/actions/22x22"
ln -sfr "$wd/devices/scalable-light" "$wd/devices/scalable"
ln -sfr "$wd/emblems/scalable/avatar-default-light.svg" "$wd/emblems/scalable/avatar-default.svg"
ln -sfr "$wd/places/16x16-light" "$wd/places/16x16"
echo "Updated theme to use icons for light GTK+ themes."
;;
esac
read -p "Use icons for a dark coloured panel? [y/N] " yn
case $yn in
[Yy]* )
ln -sfr "$wd/panel/16-dark" "$wd/panel/16"
ln -sfr "$wd/panel/24-dark" "$wd/panel/24"
ln -sfr "$wd/status/scalable-dark" "$wd/status/scalable"
echo "Updated theme to use dark icons for the panel."
;;
* )
ln -sfr "$wd/panel/16-light" "$wd/panel/16"
ln -sfr "$wd/panel/24-light" "$wd/panel/24"
ln -sfr "$wd/status/scalable-light" "$wd/status/scalable"
echo "Updated theme to use light icons for the panel."
;;
esac
# attempt to detect distribution and then update distributor logos
cd "$wd/places/scalable"
! distromatch && alt_distromatch
# prompt for desktop environment integration instead of distro
read -p "Use distributor logo from desktop environment? [y/N] " yn
case $yn in
[Yy]* )
case $DE in
budgie|budgiegnome) ln -sf distributor-logo-budgie.svg distributor-logo.svg ;;
gnome) ln -sf distributor-logo-gnome.svg distributor-logo.svg ;;
unity) ln -sf distributor-logo-unity.svg distributor-logo.svg ;;
xfce) ln -sf distributor-logo-xfce.svg distributor-logo.svg ;;
lxde) ln -sf distributor-logo-lxde.svg distributor-logo.svg ;;
kde) ln -sf distributor-logo-kde.svg distributor-logo.svg ;;
*)
echo "Could not determine desktop environment... Using distribution logo."
de_error=1
;;
esac
;;
* ) if [ $distro_error -eq 0 ]; then
echo "Using distribution logo."
elif [ $distro_error -eq 1 ] || [ $de_error -eq 1 ]; then
echo "Could not determine distributor logo, you may need to set this manually in places/scalable/"
fi
;;
esac
ln -sf distributor-logo.svg start-here.svg # fixes potentially broken link
cd "$wd"
ln -sfr "$wd"/places/scalable/distributor-logo.svg "$wd"/apps/scalable/cs-desktop.svg
ln -sfr "$wd"/places/scalable/distributor-logo.svg "$wd"/apps/scalable/applications-system.svg
echo "Updated distributor logo."
# update mimetypes based on distro and de
cd "$wd"/mimetypes/scalable
case $DISTRO in
opensuse) ln -sf application-x-rpm-opensuse.svg application-x-rpm.svg ;;
fedora) ln -sf application-x-rpm-fedora.svg application-x-rpm.svg ;;
debian|raspbian) ln -sf application-x-deb-debian.svg application-x-deb.svg ;;
ubuntu) ln -sf application-x-deb-ubuntu.svg application-x-deb.svg ;;
linuxmint)
ln -sf application-x-deb-linuxmint.svg application-x-deb.svg
ln -sf application-x-desktop-linuxmint.svg application-x-desktop.svg
;;
* )
ln -sf application-x-deb-debian.svg application-x-deb.svg
ln -sf application-x-rpm-redhat.svg application-x-rpm.svg
;;
esac
echo "Updated package archive icons."
case $DE in
budgie|budgiegnome) ln -sf application-x-desktop-budgie.svg application-x-desktop.svg ;;
gnome) ln -sf application-x-desktop-gnome.svg application-x-desktop.svg ;;
unity) ln -sf application-x-desktop-unity.svg application-x-desktop.svg ;;
lxde) ln -sf application-x-desktop-lxde.svg application-x-desktop.svg ;;
xfce) ln -sf application-x-desktop-xfce.svg application-x-desktop.svg ;;
kde) ln -sf application-x-desktop-kde.svg application-x-desktop.svg ;;
esac
echo "Updated desktop mimetype icons."