-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathshortix_install.sh
245 lines (229 loc) · 7.33 KB
/
shortix_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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
#/bin/sh
# Terminal color variables:
NC='\033[0m'
CY='\033[1;96m'
RE='\033[1;91m'
YL='\033[1;93m'
PROTONTRICKS_NATIVE="protontricks"
PROTONTRICKS_FLAT="flatpak run com.github.Matoking.protontricks"
PROTONTRICKS_FLATID="com.github.Matoking.protontricks"
if [ "$(command -v kdialog)" ]; then
USEKDIALOG=true
else
USEKDIALOG=false
fi
#Check if and how protontricks is installed, if yes run, if no, stop the script
if [ "$(command -v $PROTONTRICKS_NATIVE)" ]; then
echo "Protontricks is installed natively"
elif [ "$(flatpak info "$PROTONTRICKS_FLATID" >/dev/null 2>&1 && echo "true")" ]; then
echo "Protontricks is installed as Flatpak"
else
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix installer" --error "Protontricks not found! Please install Protontricks either as Flatpak or native by using pacman or yay."
exit
else
echo -e "${RE}Protontricks could not be found! Please install it. Aborting...${NC}"
read -n 1 -s -r -p "Press any key to continue"
exit
fi
fi
if [ -d $HOME/Shortix/ ] || [ -f $HOME/.config/systemd/user/shortix.service ]; then
TYPE="updater"
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix $TYPE" --msgbox "Welcome to Shortix! This setup will update Shortix."
else
echo -e "${CY}Welcome to Shortix-$TYPE. This setup will update Shortix.${NC}"
sleep 1
fi
rm -rf $HOME/Shortix
else
TYPE="installer"
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix installer" --msgbox "Welcome to Shortix! This setup will install Shortix."
else
echo "${CY}Welcome to Shortix-$TYPE. This setup will install Shortix.${NC}"
sleep 1
fi
fi
mkdir -p $HOME/Shortix
cp /tmp/shortix/shortix.sh $HOME/Shortix
cp /tmp/shortix/remove_prefix.sh $HOME/Shortix
p /tmp/shortix/shortix_uninstall.sh $HOME/Shortix
chmod +x $HOME/Shortix/shortix.sh
chmod +x $HOME/Shortix/remove_prefix.sh
chmod +x $HOME/Shortix/shortix_uninstall.sh
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix $TYPE" --yesno "Would you like to add the prefix id to the shortcut name?\nLike this:\nGame Name (123455678)" 2> /dev/null
case $? in
0) if [ ! -f $HOME/Shortix/.id ]; then
touch $HOME/Shortix/.id
fi
;;
1) if [ -f $HOME/Shortix/.id ]; then
rm -rf $HOME/Shortix/.id
fi
;;
esac
else
read -p "Would you like to add the prefix id to the shortcut name? ike this: Game Name (123455678) " yn
case $yn in
yY) if [ ! -f $HOME/Shortix/.id ]; then
touch $HOME/Shortix/.id
fi
;;
nN) if [ -f $HOME/Shortix/.id ]; then
rm -rf $HOME/Shortix/.id
fi
;;
esac
fi
if [ $USEKDIALOG == true ]; then
if [ -f $HOME/Shortix/.id ]; then
kdialog --title "Shortix $TYPE" --yesno "Would you also like to add the size of the target directory to the shortcut name?\nLike this: \nGame Name (123455678) - 1.6G" 2> /dev/null
case $? in
0) if [ ! -f $HOME/Shortix/.size ]; then
touch $HOME/Shortix/.size
fi
;;
1) if [ -f $HOME/Shortix/.size ]; then
rm -rf $HOME/Shortix/.size
fi
;;
esac
else
kdialog --title "Shortix $TYPE" --yesno "Would you like to add the size of the target directory to the shortcut name?\nLike this:\nGame Name - 1.6G?"
case $? in
0) if [ ! -f $HOME/Shortix/.size ]; then
touch $HOME/Shortix/.size
fi
;;
1) if [ -f $HOME/Shortix/.size ]; then
rm -rf $HOME/Shortix/.size
fi
;;
esac
fi
else
if [ -f $HOME/Shortix/.id ]; then
read -p "Would you also like to add the size of the target directory to the shortcut name? Like this: Game Name (123455678) - 1.6G " yn
case $yn in
yY) if [ ! -f $HOME/Shortix/.size ]; then
touch $HOME/Shortix/.size
fi
;;
nN) if [ -f $HOME/Shortix/.size ]; then
rm -rf $HOME/Shortix/.size
fi
;;
esac
else
read -p "Would you like to add the size of the target directory to the shortcut name?\nLike this:\nGame Name - 1.6G? " yn
case $yn in
yY) if [ ! -f $HOME/Shortix/.size ]; then
touch $HOME/Shortix/.size
fi
;;
nN) if [ -f $HOME/Shortix/.size ]; then
rm -rf $HOME/Shortix/.size
fi
;;
esac
fi
fi
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix $TYPE" --yesno "Would you like to setup system service for background updates?"
case $? in
0) if [ ! -d $HOME/.config/systemd/user ]; then
mkdir -p $HOME/.config/systemd/user
fi
cp /tmp/shortix/shortix.service $HOME/.config/systemd/user
systemctl --user daemon-reload
if ! systemctl is-enabled --quiet --user shortix.service; then
systemctl --user enable shortix.service
fi
systemctl --user restart shortix.service
;;
1) if systemctl is-enabled --quiet --user shortix.service; then
systemctl --user disable shortix.service
fi
if [ -f $HOME/.config/systemd/user/shortix.service ]; then
rm $HOME/.config/systemd/user/shortix.service
fi
systemctl --user daemon-reload
;;
esac
else
read -p "Would you like to setup system service for background updates? " yn
case $yn in
yY) if [ ! -d $HOME/.config/systemd/user ]; then
mkdir -p $HOME/.config/systemd/user
fi
cp /tmp/shortix/shortix.service $HOME/.config/systemd/user
systemctl --user daemon-reload
if ! systemctl is-enabled --quiet --user shortix.service; then
systemctl --user enable shortix.service
fi
systemctl --user restart shortix.service
;;
nN) if systemctl is-enabled --quiet --user shortix.service; then
systemctl --user disable shortix.service
fi
if [ -f $HOME/.config/systemd/user/shortix.service ]; then
rm $HOME/.config/systemd/user/shortix.service
fi
systemctl --user daemon-reload
;;
esac
fi
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix Backup" --yesno "Would you like to create a backup of Shortix on a different location?\nIf yes, please select the location where the Shortix-Backup directory should be created."
case $? in
0) if [ ! -f $HOME/Shortix/.backup ]; then
touch $HOME/Shortix/.backup
fi
;;
1) if [ -f $HOME/Shortix/.backup ]; then
rm -rf $HOME/Shortix/.backup
fi
;;
esac
else
read -p "Would you like to create a backup of Shortix on a different location?" yn
case $yn in
yY) if [ ! -f $HOME/Shortix/.backup ]; then
touch $HOME/Shortix/.backup
fi
;;
nN) if [ -f $HOME/Shortix/.backup ]; then
rm -rf $HOME/Shortix/.backup
fi
;;
esac
fi
if [ $USEKDIALOG == true ]; then
if [ -f $HOME/Shortix/.backup ]; then
kdialog --getexistingdirectory . > $HOME/Shortix/.backup
mkdir -p $(cat $HOME/Shortix/.backup)/Shortix-Backup
fi
else
if [ -f $HOME/Shortix/.backup ]; then
read -p "Please enter your path where the Shortix-Backup directory should be created (like '/home/deck'): " backdir
mkdir -p $backdir/Shortix-Backup
fi
fi
if [ -f $HOME/.config/user-dirs.dirs ]; then
source $HOME/.config/user-dirs.dirs
if [ $XDG_DESKTOP_DIR/shortix_installer.desktop ]; then
sed -i 's/Install/Update/' /tmp/shortix/shortix_installer.desktop
mv /tmp/shortix/shortix_installer.desktop $XDG_DESKTOP_DIR/shortix_updater.desktop
rm -rf $XDG_DESKTOP_DIR/shortix_installer.desktop
chmod +x $XDG_DESKTOP_DIR/shortix_updater.desktop
fi
fi
if [ $USEKDIALOG == true ]; then
kdialog --title "Shortix $TYPE" --msgbox "Shortix is set up!"
else
echo -e "${YL}Short is set up!${NC}"
sleep 4
fi
[ $? = 0 ] && exit