-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-icons.sh
executable file
·71 lines (58 loc) · 2.15 KB
/
install-icons.sh
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
#!/bin/bash
ICON_THEME_NAME="${ICON_THEME_NAME:-ClassicOS2000}"
DEFAULT_PREFIX="/usr/share"
if [[ $EUID -ne 0 ]]; then
DEFAULT_PREFIX="$HOME/.local/share"
fi
PREFIX="${PREFIX:-${DEFAULT_PREFIX}}"
STARTING_DIR=`pwd`
if [ ! -e "$STARTING_DIR/build-icons.sh" ] ; then
echo "You must run this script from the root of the repository."
exit
fi
if [ ! -e "$STARTING_DIR/install-icons.sh" ] ; then
echo "You must run this script from the root of the repository."
exit
fi
if [ ! -e "$STARTING_DIR/src" ] ; then
echo "You must run this script from the root of the repository."
exit
fi
if [ ! -e "$STARTING_DIR/build" ] ; then
echo "You must first build the icon theme before installing"
exit
fi
if [ ! -d "$PREFIX" ]; then
echo "The prefix you chose ($PREFIX) does not exist."
read -r -p "Do you want to create it? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
mkdir -p "$PREFIX"
if [ ! $? = 0 ]; then
echo "Failed to create directory '$PREFIX'. Either create the directory yourself, or use a different install prefix."
exit
fi
else
echo "Cannot continue without '$PREFIX'. Either create the directory yourself, or use a different install prefix."
exit
fi
fi
if [ -d "$PREFIX/icons/$ICON_THEME_NAME" ]; then
echo "Old theme found at $PREFIX/icons/$ICON_THEME_NAME"
read -r -p "Do you want to remove the directory and replace it? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
rm -r "$PREFIX/icons/$ICON_THEME_NAME"
if [ ! $? = 0 ]; then
echo "Cannot remove existing folder. Either remove the directory yourself, or use a different install prefix."
exit
fi
else
echo "Cannot continue. Either remove the directory yourself, or use a different install prefix."
exit
fi
fi
echo "Installing $ICON_THEME_NAME to $PREFIX/icons/$ICON_THEME_NAME..."
# TODO: make use of the install command instead of cp
cp -r "$STARTING_DIR/build/$ICON_THEME_NAME" "$PREFIX/icons/$ICON_THEME_NAME"
echo "Updating icon cache...."
gtk-update-icon-cache "$PREFIX/icons/$ICON_THEME_NAME"
echo "Done"