forked from phoenixbyrd/Termux_XFCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
354 lines (288 loc) · 10.8 KB
/
setup.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/bin/bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'
finish() {
local ret=$?
if [ ${ret} -ne 0 ] && [ ${ret} -ne 130 ]; then
echo
echo "ERROR: Failed to setup XFCE on Termux."
echo "Please refer to the error message(s) above"
fi
}
trap finish EXIT
clear
echo ""
echo "This script will install XFCE Desktop in Termux along with a ubuntu proot"
echo ""
read -r -p "Please enter username for proot installation: " username </dev/tty
termux-setup-storage
termux-change-repo
pkg update -y -o Dpkg::Options::="--force-confold"
pkg upgrade -y -o Dpkg::Options::="--force-confold"
pkg uninstall dbus -y
pkg install wget ncurses-utils dbus proot-distro x11-repo tur-repo pulseaudio -y
#Create default directories
mkdir -p Desktop
mkdir -p Downloads
setup_proot() {
#Install ubuntu proot
proot-distro install ubuntu
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 apt update
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 apt upgrade -y
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 apt install sudo wget nala flameshot conky-all -y
#Create user
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 groupadd storage
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 groupadd wheel
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 useradd -m -g users -G wheel,audio,video,storage -s /bin/bash "$username"
#Add user to sudoers
chmod u+rw $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/etc/sudoers
echo "$username ALL=(ALL) NOPASSWD:ALL" | tee -a $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/etc/sudoers > /dev/null
chmod u-w $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/etc/sudoers
#Set proot DISPLAY
echo "export DISPLAY=:1.0" >> $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.bashrc
#Set proot aliases
echo "
alias virgl='GALLIUM_DRIVER=virpipe '
alias ls='exa -lF --icons'
alias cat='bat '
alias apt='sudo nala '
" >> $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.bashrc
#Set proot timezone
timezone=$(getprop persist.sys.timezone)
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 rm /etc/localtime
proot-distro login ubuntu --shared-tmp -- env DISPLAY=:1.0 cp /usr/share/zoneinfo/$timezone /etc/localtime
}
setup_xfce() {
#Install xfce4 desktop and additional packages
pkg install git neofetch virglrenderer-android papirus-icon-theme xfce4 xfce4-goodies pavucontrol-qt exa bat cmus nala wmctrl firefox -y
#Create .bashrc
cp $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/etc/skel/.bashrc $HOME/.bashrc
#Enable Sound
echo "
pulseaudio --start --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
" > $HOME/.sound
echo "source $HOME/.sound" >> $HOME/.bashrc
#Set aliases
echo "
alias ubuntu='proot-distro login ubuntu --user $username --shared-tmp'
alias ls='exa -lF --icons'
alias cat='bat '
alias apt='nala'
" >> $HOME/.bashrc
#Put Firefox icon on Desktop
cp $HOME/../usr/share/applications/firefox.desktop $HOME/Desktop
chmod +x $HOME/Desktop/firefox.desktop
cat <<'EOF' > ../usr/bin/prun
#!/bin/bash
varname=$(basename $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/*)
proot-distro login ubuntu --user $varname --shared-tmp -- env DISPLAY=:1.0 $@
EOF
chmod +x ../usr/bin/prun
cat <<'EOF' > ../usr/bin/cp2menu
#!/bin/bash
cd
user_dir="../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/"
# Get the username from the user directory
username=$(basename "$user_dir"/*)
selected_file=$(zenity --file-selection --title="Select .desktop File" --file-filter="*.desktop" --filename="../usr/var/lib/proot-distro/installed-rootfs/ubuntu/usr/share/applications")
if [[ -z $selected_file ]]; then
zenity --info --text="No file selected. Quitting..." --title="Operation Cancelled"
exit 0
fi
desktop_filename=$(basename "$selected_file")
cp "$selected_file" "../usr/share/applications/"
sed -i "s/^Exec=\(.*\)$/Exec=proot-distro login ubuntu --user $username --shared-tmp -- env DISPLAY=:1.0 \1/" "../usr/share/applications/$desktop_filename"
zenity --info --text="Operation completed successfully!" --title="Success"
EOF
chmod +x ../usr/bin/cp2menu
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=cp2menu
Comment=
Exec=cp2menu
Icon=edit-move
Categories=System;
Path=
Terminal=false
StartupNotify=false
" > $HOME/Desktop/cp2menu.desktop
chmod +x $HOME/Desktop/cp2menu.desktop
mv $HOME/Desktop/cp2menu.desktop $HOME/../usr/share/applications
#App Installer Utility
git clone https://github.com/phoenixbyrd/App-Installer.git
mv $HOME/App-Installer $HOME/.App-Installer
chmod +x $HOME/.App-Installer/*
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=App Installer
Comment=
Exec=/data/data/com.termux/files/home/.App-Installer/app-installer
Icon=package-install
Categories=System;
Path=
Terminal=false
StartupNotify=false
" > $HOME/Desktop/App-Installer.desktop
chmod +x $HOME/Desktop/App-Installer.desktop
cp $HOME/Desktop/App-Installer.desktop $HOME/../usr/share/applications
}
setup_termux_x11() {
# Install Termux-X11
sed -i '12s/^#//' $HOME/.termux/termux.properties
curl -sL https://nightly.link/termux/termux-x11/workflows/debug_build/master/termux-companion%20packages.zip -o termux_companion_packages.zip
unzip termux_companion_packages.zip "termux-x11-nightly*.deb"
mv termux-x11-nightly*.deb termux-x11-nightly.deb
dpkg -i termux-x11-nightly.deb
rm termux_companion_packages.zip termux-x11-nightly.deb
#curl -sL https://nightly.link/termux/termux-x11/workflows/debug_build/master/termux-x11-universal-debug.zip -o termux-x11.zip
#unzip termux-x11.zip
wget https://github.com/termux/termux-x11/releases/download/1.03.00/app-universal-debug.apk
mv app-universal-debug.apk $HOME/storage/downloads/
termux-open $HOME/storage/downloads/app-universal-debug.apk
#rm termux-x11.zip
#Create kill_termux_x11.desktop
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Kill Termux X11
Comment=
Exec=kill_termux_x11
Icon=system-shutdown
Categories=System;
Path=
StartupNotify=false
" > $HOME/Desktop/kill_termux_x11.desktop
chmod +x $HOME/Desktop/kill_termux_x11.desktop
mv $HOME/Desktop/kill_termux_x11.desktop $HOME/../usr/share/applications
#Create XFCE Start and Shutdown
cat <<'EOF' > start
#!/bin/bash
termux-x11 :1.0 &
virgl_test_server_android --angle-gl & > /dev/null 2>&1
sleep 1
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
sleep 1
env DISPLAY=:1.0 dbus-launch --exit-with-session glxfce & > /dev/null 2>&1
sleep 5
process_id=$(ps -aux | grep '[x]fce4-screensaver' | awk '{print $2}')
kill "$process_id"
EOF
chmod +x start
mv start $HOME/../usr/bin
#glxfce Hardware Acceleration XFCE Desktop
cat <<'EOF' > glxfce
#!/bin/bash
export DISPLAY=:1.0
GALLIUM_DRIVER=virpipe xfce4-session & > /dev/null 2>&1
Terminal=false
EOF
chmod +x glxfce
mv glxfce $HOME/../usr/bin
#Shutdown Utility
cat <<'EOF' > $HOME/../usr/bin/kill_termux_x11
#!/bin/bash
# Get the process IDs of Termux-X11 and XFCE sessions
termux_x11_pid=$(pgrep -f "/system/bin/app_process / com.termux.x11.Loader :1.0")
xfce_pid=$(pgrep -f "xfce4-session")
# Check if the process IDs exist
if [ -n "$termux_x11_pid" ] && [ -n "$xfce_pid" ]; then
# Kill the processes
kill -9 "$termux_x11_pid" "$xfce_pid"
echo "Termux-X11 and XFCE sessions closed."
else
echo "Termux-X11 or XFCE session not found."
fi
EOF
chmod +x $HOME/../usr/bin/kill_termux_x11
}
setup_theme() {
#Download Wallpaper
wget https://raw.githubusercontent.com/phoenixbyrd/Termux_XFCE/main/peakpx.jpg
wget https://raw.githubusercontent.com/phoenixbyrd/Termux_XFCE/main/dark_waves.png
mv peakpx.jpg $HOME/../usr/share/backgrounds/xfce/
mv dark_waves.png $HOME/../usr/share/backgrounds/xfce/
#Install WhiteSur-Dark Theme
wget https://github.com/vinceliuice/WhiteSur-gtk-theme/archive/refs/tags/2023-04-26.zip
unzip 2023-04-26.zip
tar -xf WhiteSur-gtk-theme-2023-04-26/release/WhiteSur-Dark-44-0.tar.xz
mv WhiteSur-Dark/ $HOME/../usr/share/themes/
rm -rf WhiteSur*
rm 2023-04-26.zip
#Install Fluent Cursor Icon Theme
wget https://github.com/vinceliuice/Fluent-icon-theme/archive/refs/tags/2023-02-01.zip
unzip 2023-02-01.zip
mv Fluent-icon-theme-2023-02-01/cursors/dist $HOME/../usr/share/icons/
mv Fluent-icon-theme-2023-02-01/cursors/dist-dark $HOME/../usr/share/icons/
#mkdir $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/usr/share/icons
cp -r $HOME/../usr/share/icons/dist-dark $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/usr/share/icons/dist-dark
rm -rf $HOME//Fluent*
rm 2023-02-01.zip
cat <<'EOF' > $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.Xresources
Xcursor.theme: dist-dark
EOF
#Setup Fonts
wget https://github.com/microsoft/cascadia-code/releases/download/v2111.01/CascadiaCode-2111.01.zip
mkdir .fonts
unzip CascadiaCode-2111.01.zip
mv otf/static/* .fonts/ && rm -rf otf
mv ttf/* .fonts/ && rm -rf ttf/
rm -rf woff2/ && rm -rf CascadiaCode-2111.01.zip
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Meslo.zip
unzip Meslo.zip
mv *.ttf .fonts/
rm Meslo.zip
rm LICENSE.txt
rm readme.md
#Setup Fancybash Termux
wget https://raw.githubusercontent.com/phoenixbyrd/Termux_XFCE/main/fancybash.sh
mv fancybash.sh .fancybash.sh
echo "source $HOME/.fancybash.sh" >> $HOME/.bashrc
sed -i "326s/\\\u/$username/" $HOME/.fancybash.sh
sed -i "327s/\\\h/termux/" $HOME/.fancybash.sh
#Setup Fancybash Proot
cp .fancybash.sh $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username
echo "source ~/.fancybash.sh" >> $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.bashrc
sed -i '327s/termux/proot/' $HOME/../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.fancybash.sh
wget https://github.com/phoenixbyrd/Termux_XFCE/raw/main/font.ttf
mv font.ttf .termux/font.ttf
}
setup_xfce_settings() {
wget https://github.com/phoenixbyrd/Termux_XFCE/raw/main/conky.tar.gz
tar -xvzf conky.tar.gz
rm conky.tar.gz
mkdir ../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.config
mv .config/conky/ ../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.config
mv .config/neofetch ../usr/var/lib/proot-distro/installed-rootfs/ubuntu/home/$username/.config
wget https://github.com/phoenixbyrd/Termux_XFCE/raw/main/config.tar.gz
tar -xvzf config.tar.gz
rm config.tar.gz
}
setup_proot
setup_xfce
setup_termux_x11
setup_theme
setup_xfce_settings
rm setup.sh
source .bashrc
termux-reload-settings
########
##Finish ##
########
clear -x
echo ""
echo ""
echo "Setup completed successfully!"
echo ""
echo "You can now connect to your Termux XFCE4 Desktop to open the desktop use the command start"
echo ""
echo "This will start the termux-x11 server in termux and start the XFCE Desktop and then open the installed Termux-X11 app."
echo ""
echo "To exit, double click the Kill Termux X11 icon on the desktop."
echo ""
echo "Enjoy your Termux XFCE4 Desktop experience!"
echo ""
echo ""