forked from mig/gedit-themes
-
Notifications
You must be signed in to change notification settings - Fork 7
/
install
executable file
·128 lines (111 loc) · 2.96 KB
/
install
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
#!/bin/bash
#
# Copyright (C) 2012 Ricardo Graça
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Notes:
#
# - This script was only tested on:
# - Ubuntu 12.04 with Gedit 3.4
# - Ubuntu 16.04 with Gedit 3.18.3
# - Red Hat Enterprise Linux 6.7 with 2.28.4
# but it should work in other linux distros as well.
# default install dirs: LOCAL (in home dir) && NEW (3.x version)
LOCAL=1
LATEST=1
INSTALL_DIR_LOCAL_LATEST="$HOME/.local/share/gtksourceview-3.0/styles"
INSTALL_DIR_GLOBAL_LATEST="/usr/share/gtksourceview-3.0/styles"
INSTALL_DIR_LOCAL_2X="$HOME/.gnome2/gedit/styles"
INSTALL_DIR_GLOBAL_2X="/usr/share/gtksourceview-2.0/styles"
INSTALL_DIR="" # set in evaldir
# Print usage instructions of the script
function usage {
cat << EOF
usage: $0 [options]
This script installs the bundled theme styles for gedit.
OPTIONS:
-h Shows this message
-a Install for all users
-o Old version support (Gedit 2.x version)
EOF
}
# Check if destination directory exists and create it if it doesn't.
# Will return an error code if anything fails, stopping the script execution.
function chkdir {
if [ ! -d "$INSTALL_DIR" ]; then
if [[ $INSTALL_DIR = /usr/* ]]; then
sudo mkdir -p "$INSTALL_DIR" || { return 1; }
else
mkdir -p "$INSTALL_DIR" || { return 1; }
fi
fi
return 0
}
# Copy theme files to destination directory
function cpfiles {
if [[ $INSTALL_DIR = /usr/* ]]; then
sudo cp *.xml "$INSTALL_DIR" || { return 1; }
else
cp *.xml "$INSTALL_DIR" || { return 1; }
fi
return 0
}
function evaldir {
if [[ $LOCAL -eq 1 ]]; then
if [[ $LATEST -eq 1 ]]; then
INSTALL_DIR="$INSTALL_DIR_LOCAL_LATEST";
else
INSTALL_DIR="$INSTALL_DIR_LOCAL_2X";
fi
else
if [[ $LATEST -eq 1 ]]; then
INSTALL_DIR="$INSTALL_DIR_GLOBAL_LATEST";
else
INSTALL_DIR="$INSTALL_DIR_GLOBAL_2X";
fi
fi
}
# Loop through passed arguments
while getopts "hao" OPTION; do
case $OPTION in
h)
usage
exit 1
;;
a)
LOCAL=0
;;
o)
LATEST=0
;;
esac
done
evaldir
echo -e "Installing Gedit themes to $INSTALL_DIR\n..."
chkdir
SUCCESS=$?
if [ $SUCCESS -eq 0 ]; then
cpfiles
if [ $? -eq 0 ]; then
echo -e "...\nAll done!\n:)"
exit 0
else
echo -e "Unable to copy themes to $INSTALL_DIR\n:("
exit 1
fi
else
echo -e "The destination directory $INSTALL_DIR doesn't exist and I can't create it either!\n:("
exit 1
fi