-
Notifications
You must be signed in to change notification settings - Fork 13
/
install.sh
executable file
·102 lines (85 loc) · 2.46 KB
/
install.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
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
#!/bin/bash
################################ USAGE #######################################
usage=$(
cat <<EOF
Usage:
$0 [OPTION]
-h, --help show this message.
-2, --rb2 install the plugin for rhythmbox version 2.96 to 2.99 (default).
-3, --rb3 install the plugin for rhythmbox 3
-n, --no-sudo work without sudo, but requires modifications to bashrc
EOF
)
########################### OPTIONS PARSING #################################
#parse options
TMP=`getopt --name=$0 -a --longoptions=rb2,rb3,no-sudo,help -o 2,3,n,h -- $@`
if [[ $? == 1 ]]
then
echo
echo "$usage"
exit
fi
eval set -- $TMP
until [[ $1 == -- ]]; do
case $1 in
-2|--rb2)
RB=true
;;
-3|--rb3)
RB=false
;;
-n|--no-sudo)
SUDO=false
;;
-h|--help)
echo "$usage"
exit
;;
esac
shift # move the arg list to the next option or '--'
done
shift # remove the '--', now $1 positioned at first argument if any
#default values
RB=${RB:=true}
SUDO=${SUDO:=true}
########################## START INSTALLATION ################################
SCRIPT_NAME=`basename "$0"`
SCRIPT_PATH=${0%`basename "$0"`}
PLUGIN_PATH="${HOME}/.local/share/rhythmbox/plugins/RhythmboxRandomAlbumPlayer/"
GLIB_SCHEME="org.gnome.rhythmbox.plugins.randomalbumplayer.gschema.xml"
SCHEMA_FOLDER=""
if [[ $SUDO == true ]]
then
GLIB_DIR="/usr/share/glib-2.0/schemas/"
fi
if [[ $SUDO == false ]]
then
GLIB_DIR="${HOME}/.local/share/glib-2.0/schemas/"
fi
#build the dirs
mkdir -p $PLUGIN_PATH
#copy the files
cp -r "${SCRIPT_PATH}"* "$PLUGIN_PATH"
#install the plugin; the install path depends on the install mode
if [[ $RB == false ]]
then
mv "$PLUGIN_PATH"rhythmbox-random-album-player.plugin3 "$PLUGIN_PATH"rhythmbox-random-album-player.plugin
fi
#remove the install script from the dir (not needed)
rm "${PLUGIN_PATH}${SCRIPT_NAME}"
#install the glib schema
if [[ $SUDO == true ]]
then
echo "Installing the glib schema (password needed)"
sudo cp "${PLUGIN_PATH}${SCHEMA_FOLDER}${GLIB_SCHEME}" "$GLIB_DIR"
sudo glib-compile-schemas "$GLIB_DIR"
fi
if [[ $SUDO == false ]]
then
echo "Installing the glib schema"
mkdir -p $GLIB_DIR
cp "${PLUGIN_PATH}${SCHEMA_FOLDER}${GLIB_SCHEME}" "$GLIB_DIR"
glib-compile-schemas "$GLIB_DIR"
echo "Add this in your .bashrc if it is not already:"
echo "export XDG_DATA_DIRS=\$HOME/.local/share:\$XDG_DATA_DIRS"
fi