-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
executable file
·232 lines (192 loc) · 6.35 KB
/
installer.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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/bin/sh
mkdir -p "$HOME/.config/mpv"
# Figure out distro
# From https://ilhicas.com/2018/08/08/bash-script-to-install-packages-multiple-os.html
declare -A osInfo;
# Debian, Ubuntu
osInfo[/etc/debian_version]="apt-get install -yy"
osInfo[/etc/alpine-release]="apk --update add"
osInfo[/etc/centos-release]="yum install -y"
# Fedora
osInfo[/etc/fedora-release]="dnf install -y"
# Arch
osInfo[/etc/arch-release]="pacman -S --noconfirm"
for f in ${!osInfo[@]}
do
if [[ -f $f ]];then
PKG_MANAGER=${osInfo[$f]}
fi
done
# Set Variables
CURL_IS_INSTALLED=0
WGET_IS_INSTALLED=0
XCLIP_IS_INSTALLED=0
WLC_IS_INSTALLED=0
UNZIP_IS_INSTALLED=0
ZENITY_IS_INSTALLED=0
NOTIFYSEND_IS_INSTALLED=0
YTDLP_IS_INSTALLED=0
TRASHCLI_IS_INSTALLED=0
MPV_IS_INSTALLED=0
GIT_IS_INSTALLED=0
EMPV_IS_INSTALLED=0
MPRIS_IS_INSTALLED=0
INSTALL_PACKAGES_LIST=()
INSTALL_PACKAGES=0
# Check if everything is already installed
which curl
if [[ $? == 0 ]]; then
CURL_IS_INSTALLED=1
fi
which wget
if [[ $? == 0 ]]; then
WGET_IS_INSTALLED=1
fi
which xclip
if [[ $? == 0 ]]; then
XCLIP_IS_INSTALLED=1
fi
which wl-paste
if [[ $? == 0 ]]; then
WLC_IS_INSTALLED=1
fi
which unzip
if [[ $? == 0 ]]; then
UNZIP_IS_INSTALLED=1
fi
which notify-send
if [[ $? == 0 ]]; then
NOTIFYSEND_IS_INSTALLED=1
fi
which zenity
if [[ $? == 0 ]]; then
ZENITY_IS_INSTALLED=1
fi
which yt-dlp
if [[ $? == 0 ]]; then
YTDLP_IS_INSTALLED=1
fi
which mpv
if [[ $? == 0 ]]; then
MPV_IS_INSTALLED=1
fi
which git
if [[ $? == 0 ]]; then
GIT_IS_INSTALLED=1
fi
which trash
if [[ $? == 0 ]]; then
TRASHCLI_IS_INSTALLED=1
fi
if [[ -f /etc/mpv/scripts/mpris.so ]]; then
MPRIS_IS_INSTALLED=1
fi
if [[ -f "$HOME/.config/mpv/scripts/easympv/main.js" ]]; then
EMPV_IS_INSTALLED=1
fi
# if not, add to install array
if [[ $CURL_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("curl")
INSTALL_PACKAGES=1
fi
if [[ $WGET_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("wget")
INSTALL_PACKAGES=1
fi
if [[ $XCLIP_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("xclip")
INSTALL_PACKAGES=1
fi
if [[ $WLC_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("wl-clipboard")
INSTALL_PACKAGES=1
fi
if [[ $UNZIP_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("unzip")
INSTALL_PACKAGES=1
fi
if [[ $ZENITY_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("zenity")
INSTALL_PACKAGES=1
fi
if [[ $NOTIFYSEND_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("libnotify")
INSTALL_PACKAGES=1
fi
if [[ $YTDLP_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("yt-dlp")
INSTALL_PACKAGES=1
fi
if [[ $MPV_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("mpv")
INSTALL_PACKAGES=1
fi
if [[ $GIT_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("git")
INSTALL_PACKAGES=1
fi
if [[ $TRASHCLI_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("trash-cli")
INSTALL_PACKAGES=1
fi
if [[ $MPRIS_IS_INSTALLED == 0 ]]; then
INSTALL_PACKAGES_LIST+=("mpv-mpris")
INSTALL_PACKAGES=1
fi
# install all packages in install array
if [[ $INSTALL_PACKAGES != 0 ]]; then
if [[ "$TERM" != "dumb" ]]; then
echo "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
else
if [[ $(type -P osascript) != "" ]]; then
osascript -e \'tell application "Terminal" to do script echo "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}" \'
elif [[ $(type -P gnome-terminal) != "" ]]; then
gnome-terminal -- echo "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
elif [[ $(type -P konsole) != "" ]]; then
konsole --noclose -e "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
elif [[ $(type -P lxterminal) != "" ]]; then
lxterminal --command="Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
elif [[ $(type -P rxvt) != "" ]]; then
rxvt -e "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
elif [[ $(type -P xterm) != "" ]]; then
xterm -e "Please enter your password to install all necessary dependencies.\n" && sudo $PKG_MANAGER "${INSTALL_PACKAGES_LIST[@]}"
fi
fi
fi
EMPV_VERSION=$(curl --silent "https://api.github.com/repos/JongWasTaken/easympv/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([[^"]]+)".*/\1/')
function empv_ask_install_choice() {
if [[ "$EMPV_VERSION" == "" ]]; then
EMPV_INSTALL_CHOICE="Git Master"
else
EMPV_INSTALL_CHOICE=$(zenity --list --text "Select which easympv version to install:" --radiolist --column "" --column "" --hide-header 1 Latest\ Stable\ \(recommended\) 2 Git\ Master)
if [[ "$EMPV_INSTALL_CHOICE" == "" ]]; then
empv_ask_install_choice
fi
fi
}
if [[ $EMPV_IS_INSTALLED == 0 ]]; then
empv_ask_install_choice
if [[ "$EMPV_INSTALL_CHOICE" == "Git Master" ]]; then
mkdir -p $HOME/.cache/empvtemp/
git clone https://github.com/JongWasTaken/easympv $HOME/.cache/empvtemp/git
mv $HOME/.cache/empvtemp/git/* $HOME/.config/mpv
rm -rf $HOME/.cache/empvtemp/
zenity --info --text="easympv has been installed successfully!\nmpv will now start."
else
wget --content-disposition -q -O "$HOME/.config/mpv/package.zip" https://codeload.github.com/JongWasTaken/easympv/zip/refs/tags/$EMPV_VERSION
if [[ -f "$HOME/.config/mpv/package.zip" ]]; then
unzip "$HOME/.config/mpv/package.zip" -d "$HOME/.config/mpv/"
fi
if [[ -f "$HOME/.config/mpv/package.zip" ]]; then
rm -rf "$HOME/.config/mpv/package.zip"
fi
if [[ -d "$HOME/.config/mpv/easympv-$EMPV_VERSION" ]]; then
cp -r "$HOME/.config/mpv/easympv-$EMPV_VERSION/"* "$HOME/.config/mpv/"
rm -rf "$HOME/.config/mpv/easympv-$EMPV_VERSION"
fi
zenity --info --text="easympv has been installed successfully!\nmpv will now start."
fi
fi
# launch mpv
mpv --volume=15 --player-operation-mode=pseudo-gui "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
exit 0