-
Notifications
You must be signed in to change notification settings - Fork 45
/
setup-termux-desktop
executable file
·2968 lines (2792 loc) · 97.9 KB
/
setup-termux-desktop
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/data/data/com.termux/files/usr/bin/bash
#########################################################################
#
# Call First
#
#########################################################################
R="$(printf '\033[1;31m')"
G="$(printf '\033[1;32m')"
Y="$(printf '\033[1;33m')"
B="$(printf '\033[1;34m')"
C="$(printf '\033[1;36m')"
W="$(printf '\033[0m')"
BOLD="$(printf '\033[1m')"
termux_desktop_path="$PREFIX/etc/termux-desktop"
config_file="$termux_desktop_path/configuration"
cd $HOME
# create log
function debug() {
log_file="$HOME/termux-desktop.log"
exec > >(tee -a "$log_file") 2>&1
}
function banner() {
clear
echo "${Y} ▀█▀ █▀▀ █▀█ █▀▄▀█ █░█ ▀▄▀ █▀▄ █▀▀ █▀ █▄▀ ▀█▀ █▀█ █▀█ "${W}
echo "${Y} ░█░ ██▄ █▀▄ █░▀░█ █▄█ █░█ █▄▀ ██▄ ▄█ █░█ ░█░ █▄█ █▀▀ "${W}
echo
echo "${C}${BOLD} Install Gui Desktop In Termux"${W}
echo "${C}${BOLD} code by @sabamdrif"${W}
echo
}
# check if the script is running on termux or not
function check_termux() {
if [[ $HOME != *termux* ]]; then
echo "${R}${BOLD}Please run it inside termux"${W}
exit 0
fi
}
#########################################################################
#
# Shortcut Functions
#
#########################################################################
function check_and_create_directory() {
if [[ ! -d "$1" ]]; then
mkdir -p "$1"
fi
}
# first check then delete
function check_and_delete() {
local file
for files_folders in "$@"; do
for file in $files_folders; do
if [[ -e "$file" ]]; then
if [[ -d "$file" ]]; then
rm -rf "$file" >/dev/null 2>&1
elif [[ -f "$file" ]]; then
rm "$file" >/dev/null 2>&1
fi
fi
done
done
}
# first check then backup
function check_and_backup() {
local file
local files_folders
for files_folders in "$@"; do
for file in $files_folders; do
if [[ -e "$file" ]]; then
local date_str=$(date +"%d-%m-%Y")
local backup="${file}-${date_str}.bak"
if [[ -e "$backup" ]]; then
echo "${G}Backup file ${C}${backup} ${G}already exists"${W}
echo
fi
echo "${G}backing up file ${C}$file"${W}
mv "$1" "$backup"
fi
done
done
}
# find a backup file which end with a number pattern and restore it
function check_and_restore() {
local target_path="$1"
local dir
local base_name
dir=$(dirname "$target_path")
base_name=$(basename "$target_path")
local latest_backup
latest_backup=$(ls -1 "$dir/$base_name"-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9].bak 2>/dev/null | sort | tail -n 1)
if [[ -z "$latest_backup" ]]; then
echo "${C}No backup file found for ${target_path}.${W}"
return 1
fi
if [[ -e "$target_path" ]]; then
echo "${C}Original file or directory ${target_path} already exists.${W}"
else
mv "$latest_backup" "$target_path"
echo "${G}Restored ${latest_backup} to ${target_path}.${W}"
fi
}
# will check if the package is already installed or not, if it installed then it will reinstall it and at the end it will print success/failed message
function package_install_and_check() {
packs_list=($@)
for package_name in "${packs_list[@]}"; do
echo "${R}[${W}-${R}]${G}${BOLD} Installing package: ${C}$package_name ${W}"
if type -p pacman >/dev/null 2>&1; then
if pacman -Qi "$package_name" >/dev/null 2>&1; then
echo "${package_name}=\"already_exist\"" >> $config_file
fi
pacman -Sy --noconfirm --overwrite '*' "$package_name"
else
if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "${package_name}=\"already_exist\"" >> $config_file
pkg reinstall "$package_name" -y
else
pkg install "$package_name" -y
fi
fi
if [ $? -ne 0 ]; then
echo "${R}[${W}-${R}]${G}${BOLD} Error detected during installation of: ${C}$package_name ${W}"
if type -p pacman >/dev/null 2>&1; then
pacman -Sy --overwrite '*' $package_name
pacman -Sy --noconfirm $package_name
else
apt --fix-broken install -y
dpkg --configure -a
fi
pkg install "$package_name" -y
fi
if type -p pacman >/dev/null 2>&1; then
if pacman -Qi "$package_name" >/dev/null 2>&1; then
echo "${R}[${W}-${R}]${G} $package_name installed successfully ${W}"
else
if type -p "$package_name" &>/dev/null || [ -e "$PREFIX/bin/$package_name"* ] || [ -e "$PREFIX/bin/"*"$package_name" ]; then
echo "${R}[${W}-${R}]${C} $package_name ${G}installed successfully ${W}"
fi
fi
else
if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "${R}[${W}-${R}]${G} $package_name installed successfully ${W}"
else
if type -p "$package_name" &>/dev/null || [ -e "$PREFIX/bin/$package_name"* ] || [ -e "$PREFIX/bin/"*"$package_name" ]; then
echo "${R}[${W}-${R}]${C} $package_name ${G}installed successfully ${W}"
fi
fi
fi
done
echo ""
}
# will check the package is installed or not then remove it
function package_check_and_remove() {
packs_list=($@)
for package_name in "${packs_list[@]}"; do
if dpkg -s "$package_name" >/dev/null 2>&1; then
if [[ "$package_name" != "already_exist" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Removeing package: ${C}$package_name "${W}
apt autoremove "$package_name" -y
fi
elif pacman -Qi "$package_name" >/dev/null 2>&1; then
if [[ "$package_name" != "already_exist" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Removeing package: ${C}$package_name "${W}
pacman -Rnds --noconfirm "$package_name"
fi
fi
done
}
function get_file_name_number() {
current_file=$(basename "$0")
folder_name="${current_file%.sh}"
theme_number=$(echo "$folder_name" | grep -oE '[1-9][0-9]*')
}
function extract_zip_with_progress() {
local archive="$1"
local target_dir="$2"
if [[ ! -f "$archive" ]]; then
echo "${R}$archive doesn't exist${W}"
return 1
fi
local total_files=$(unzip -l "$archive" | grep -E '^\s+[0-9]+' | wc -l)
if [[ "$total_files" -eq 0 ]]; then
echo "${R}No files found in the archive${W}"
return 1
fi
echo "Total files to extract: $total_files"
local extracted_files=0
unzip -o "$archive" -d "$target_dir" | while read line; do
if [[ "$line" =~ inflating: ]]; then
((extracted_files++))
progress=$((extracted_files * 100 / total_files))
echo -ne "${G}Extracting: ${C}$progress% ($extracted_files/$total_files) \r"${W}
fi
done
echo -e "\n ${G}${archive} Extraction complete!"${W}
}
function extract_archive() {
local archive="$1"
if [[ ! -f "$archive" ]]; then
echo "${R}$archive doesn't exist"${W}
return
fi
total_size=$(stat -c '%s' "$archive")
case "$archive" in
*.tar.gz)
pv -s "$total_size" -p -r "$archive" | tar xzf - || { echo "${R}Failed to extract ${C}$archive${W}"; return; }
;;
*.tar.xz)
pv -s "$total_size" -p -r "$archive" | tar xJf - || { echo "${R}Failed to extract ${C}$archive${W}"; return; }
;;
*.tar)
pv -s "$total_size" -p -r "$archive" | tar xf - || { echo "${R}Failed to extract ${C}$archive${W}"; return; }
;;
*.zip)
extract_zip_with_progress "${archive}"
;;
*)
echo "${R}Unsupported archive format: ${C}$archive${W}"
return 1
;;
esac
}
# download a archive file and extract it in a folder
function download_and_extract() {
local url="$1"
local target_dir="$2"
local filename="${url##*/}"
echo "${C}${BOLD}Downloading ${G}${filename}...${W}"
sleep 1.5
cd "$target_dir" || return 1
local attempt=1
local success=false
while [[ $attempt -le 3 ]]; do
if curl -# -L "$url" -o "$filename"; then
success=true
break
else
echo "${R}Failed to download ${C}${filename}${W}"
echo "${G}Retrying... Attempt ${C}$attempt${W}"
((attempt++))
sleep 1
fi
done
if [[ "$success" = true ]]; then
if [[ -f "$filename" ]]; then
echo
echo "${R}[${W}-${R}]${G}Extacting $filename" ${W}
extract_archive "$filename"
rm "$filename"
fi
else
echo "${R}Failed to download ${C}${filename}${W}"
echo "${C}Please check your internet connection${W}"
fi
}
# count the number subfolders inside a folder in my repo
function count_subfolders() {
local owner="$1"
local repo="$2"
local path="$3"
local url="https://api.github.com/repos/$owner/$repo/contents/$path"
local response=$(curl -s "$url")
local subfolder_count=$(echo "$response" | jq -r '.[] | select(.type == "dir") | .name' | wc -l)
echo "$subfolder_count"
}
# create a yes / no confirmation prompt
function confirmation_y_or_n() {
while true; do
read -p "${R}[${W}-${R}]${Y}${BOLD} $1 ${Y}(y/n) "${W} response
response="${response:-y}"
eval "$2='$response'"
case $response in
[yY]* )
echo "${R}[${W}-${R}]${G}Continuing with answer: $response"${W}
sleep 0.2
break;;
[nN]* )
echo "${R}[${W}-${R}]${C}Skipping this setp"${W}
sleep 0.2
break;;
* )
echo "${R}[${W}-${R}]${R}Invalid input. Please enter 'y' or 'n'."${W}
;;
esac
done
}
# get the latest version from a github releases
# ex. latest_tag=$(get_latest_release "$repo_owner" "$repo_name")
function get_latest_release() {
local repo_woner="$1"
local repo_name="$2"
curl -s "https://api.github.com/repos/$repo_woner/$repo_name/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
function install_font_for_style() {
local style_number="$1"
echo "${R}[${W}-${R}]${G}Installing Fonts..."${W}
check_and_create_directory "$HOME/.fonts"
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/$de_name/look_${style_number}/font.tar.gz" "$HOME/.fonts"
fc-cache -f
cd
}
function download_github_action_artifact() {
while [[ "$#" -gt 0 ]]; do
case "$1" in
--user)
GITHUB_USER="$2"
shift 2
;;
--repo)
REPO="$2"
shift 2
;;
--workflow-name)
WORKFLOW_NAME="$2" # The name of the CI workflow
shift 2
;;
--run-name)
RUN_NAME="$2" # Specific name/description of the workflow run
shift 2
;;
--artifact-name)
ARTIFACT_NAME="$2" # Artifact name prefix (can be modified as needed)
shift 2
;;
*)
echo "Unknown option: $1"
shift
;;
esac
done
# Get the workflow ID using the workflow name
WORKFLOW_ID=$(gh api repos/$GITHUB_USER/$REPO/actions/workflows --jq ".workflows[] | select(.name == \"$WORKFLOW_NAME\") | .id")
# Check if WORKFLOW_ID is found
if [ -z "$WORKFLOW_ID" ]; then
echo "${R}[${W}-${R}]${R} Workflow '$WORKFLOW_NAME' not found."${W}
exit 1
fi
echo "${R}[${W}-${R}]${G} Workflow ID for ${W}'$WORKFLOW_NAME' ${G}is ${W}$WORKFLOW_ID"
# Get the latest workflow run ID with the specific display title
WORKFLOW_RUN_ID=$(gh api repos/$GITHUB_USER/$REPO/actions/workflows/$WORKFLOW_ID/runs --paginate --jq ".workflow_runs[] | select(.display_title == \"$RUN_NAME\") | .id" | head -n 1)
# Check if WORKFLOW_RUN_ID is obtained
if [ -z "$WORKFLOW_RUN_ID" ]; then
echo "${R}[${W}-${R}]${R} No workflow run found with the name '$RUN_NAME' for workflow '$WORKFLOW_NAME'."${W}
exit 1
fi
# List artifacts for the found run
ARTIFACT_URL=$(gh api repos/$GITHUB_USER/$REPO/actions/runs/$WORKFLOW_RUN_ID/artifacts --jq ".artifacts[] | select(.name == \"$ARTIFACT_NAME\") | .archive_download_url")
# If no exact match, look for an artifact starting with ARTIFACT_NAME
if [ -z "$ARTIFACT_URL" ]; then
echo "${R}[${W}-${R}]${C} Artifact with the exact name '$ARTIFACT_NAME' not found. Looking for artifacts starting with '$ARTIFACT_NAME'..."${W}
ARTIFACT_URL=$(gh api repos/$GITHUB_USER/$REPO/actions/runs/$WORKFLOW_RUN_ID/artifacts --jq ".artifacts[] | select(.name | startswith(\"$ARTIFACT_NAME\")) | .archive_download_url" | head -n 1)
fi
# Check if ARTIFACT_URL is found
if [ -z "$ARTIFACT_URL" ]; then
echo "${R}[${W}-${R}]${R}No artifact found starting with '$ARTIFACT_NAME'."${W}
exit 1
fi
# Download the artifact using the URL
echo "${R}[${W}-${R}]${G} Downloading artifact from run '$RUN_NAME'..."${W}
curl -# -L -H "Authorization: Bearer $(gh auth token)" -o artifact.zip "$ARTIFACT_URL"
# Extract the artifact
extract_archive "artifact.zip"
}
#########################################################################
#
# Ask Required Questions
#
#########################################################################
# check the avilable styles and create a list to type the corresponding number
# in the style readme file the name must use this'## number name :' pattern, like:- ## 1. Basic Style:
function questions_theme_select() {
local owner="sabamdarif"
local repo="termux-desktop"
local main_folder="patch/$de_name"
local subfolder_count_value=$(count_subfolders "$owner" "$repo" "$main_folder")
cd $HOME
echo "${R}[${W}-${R}]${G}Downloading list...."${W}
wget -qO ${current_path}/styles.md https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/${de_name}_styles.md
clear
if [[ -n "$subfolder_count_value" ]]; then
echo "${R}[${W}-${R}]${G}Check the $de_name styles section in github"${W}
echo
echo "${R}[${W}-${R}]${B}https://github.com/sabamdarif/termux-desktop/blob/main/${de_name}_styles.md"${W}
echo
echo "${R}[${W}-${R}]${G}Number of avilable custom styles for $de_name is: ${C}${subfolder_count_value}"${W}
echo
echo "${R}[${W}-${R}]${G}Available Styles:${W}"
echo
grep -oP '## \d+\..+?(?=(\n## \d+\.|\Z))' styles.md | while read -r style; do
echo "${Y}${style#### }${W}"
done
while true; do
echo
read -p "${R}[${W}-${R}]${Y}Type number of the style (Default 1): "${W} style_answer
style_answer=${style_answer:-1}
if [[ "$style_answer" =~ ^[0-9][0-9]*$ ]] && [[ "$style_answer" -le "$subfolder_count_value" ]]; then
style_name=$(grep -oP "^## $style_answer\..+?(?=(\n## \d+\.|\Z))" styles.md | sed -e "s/^## $style_answer\. //" -e "s/:$//")
break
else
echo
echo "${R}The entered style number is incorrect."${W}
echo
echo "${R}[${W}-${R}]${Y}Please enter a number between 0 to ${subfolder_count_value}"${W}
echo
echo "${R}[${W}-${R}]${G}Check the $de_name styles section in github"${W}
echo
echo "${R}[${W}-${R}]${B}https://github.com/sabamdarif/termux-desktop/blob/main/${de_name}_styles.md"${W}
echo
fi
done
rm ${current_path}/styles.md
else
echo "${R}Failed to get total avilable styles value."${W}
fi
}
function questions() {
banner
echo "${R}[${W}-${R}]${G}Select Desktop Environment"${W}
echo
echo "${Y}1. XFCE"${W}
echo
echo "${Y}2. LXQT"${W}
echo
echo "${Y}3. OPENBOX WM"${W}
echo
read -p "${Y}select an option (Default 1): "${W} desktop_answer
echo
desktop_answer=${desktop_answer:-1}
echo "${R}[${W}-${R}]${G}Continuing with answer: $desktop_answer"${W}
sleep 0.2
# set the location based on chosen desktop
sys_icons_folder="$PREFIX/share/icons"
if [[ "$desktop_answer" == "1" ]]; then
de_name="xfce"
themes_folder="$HOME/.themes"
icons_folder="$HOME/.icons"
de_startup="xfce4-session"
elif [[ "$desktop_answer" == "2" ]]; then
de_name="lxqt"
themes_folder="$PREFIX/share/themes"
icons_folder="$sys_icons_folder"
de_startup="startlxqt"
elif [[ "$desktop_answer" == "3" ]]; then
de_name="openbox"
themes_folder="$PREFIX/share/themes"
icons_folder="$sys_icons_folder"
de_startup="openbox-session"
fi
echo "de_startup=\"$de_startup\"" >> $config_file
echo "de_name=\"$de_name\"" >> $config_file
echo "themes_folder=\"$themes_folder\"" >> $config_file
echo "icons_folder=\"$icons_folder\"" >> $config_file
banner
questions_theme_select
echo "${R}[${W}-${R}]${G}Continuing with answer: ${style_answer}.$style_name"${W}
echo "style_answer=\"$style_answer\"" >> $config_file
echo "style_name=\"$style_name\"" >> $config_file
sleep 0.2
banner
echo "${R}[${W}-${R}]${G}${BOLD}Select browser you want to install"${W}
echo
echo "${Y}1. firefox"${W}
echo
echo "${Y}2. chromium"${W}
echo
echo "${Y}3. firefox & chromium (both)"${W}
echo
echo "${Y}4. Skip"${W}
echo
read -p "${Y}select an option (Default 1): "${W} browser_answer
browser_answer=${browser_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $browser_answer"${W}
sleep 0.2
banner
echo "${R}[${W}-${R}]${G}${BOLD}Select IDE you want to install"${W}
echo
echo "${Y}1. VS Code"${W}
echo
echo "${Y}2. Geany (lightweight IDE)"${W}
echo
echo "${Y}3. Vlc & Audacious (both)"${W}
echo
echo "${Y}4. Skip"${W}
echo
read -p "${Y}select an option (Default 1): "${W} ide_answer
ide_answer=${ide_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $ide_answer"${W}
sleep 0.2
banner
echo "${R}[${W}-${R}]${G}${BOLD}Select Media Player you want to install"${W}
echo
echo "${Y}1. Vlc"${W}
echo
echo "${Y}2. Audacious"${W}
echo
echo "${Y}3. Vlc & Audacious (both)"${W}
echo
echo "${Y}4. Skip"${W}
echo
read -p "${Y}select an option (Default 1): "${W} player_answer
player_answer=${player_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $player_answer"${W}
sleep 0.2
banner
echo "${R}[${W}-${R}]${G}${BOLD}Select Photo Editor"${W}
echo
echo "${Y}1. Gimp"${W}
echo
echo "${Y}2. Inkscape"${W}
echo
echo "${Y}3. Gimp & Inkscape (both)"${W}
echo
echo "${Y}4. Skip"${W}
echo
read -p "${Y}select an option (Default 1): "${W} photo_editor_answer
photo_editor_answer=${photo_editor_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $photo_editor_answer"${W}
sleep 0.2
banner
confirmation_y_or_n "Do you want to install a graphical package manager [Synaptic]" synaptic_answer
banner
echo "${R}[${W}-${R}]${G} By Default it only add 4 - 5 wallpaper"${W}
echo
confirmation_y_or_n "Do you want to add some more wallpaper" ext_wall_answer
banner
echo "${R}[${W}-${R}]${G}${BOLD}Do you want to install wine in termux ${C}(without proot-distro)"${W}
echo
echo "${Y}1. Natively ${C}(can run only arm64 based exe) (Default)"${W}
echo
echo "${Y}2. Using Mobox ${C}(best)"${W}
echo
echo "${R}[${W}-${R}]${B} Know More About Mobox:- https://github.com/olegos2/mobox/"${W}
echo
echo "${Y}3. Wine Hangover"${W}
echo
echo "${Y}4. Skip"${W}
echo
read -p "${R}[${W}-${R}]${Y}Select Wine Installation Method: "${W} wine_answer
wine_answer=${wine_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $wine_answer"${W}
sleep 0.2
banner
confirmation_y_or_n "Do you want to Configuring Zsh" zsh_answer
banner
confirmation_y_or_n "Do you want install some terminal utility to make better terminal exprience" terminal_utility_setup_answer
banner
echo "${R}[${W}-${R}]${G}${BOLD}Select Gui Mode"${W}
echo
echo "${Y}1. Termux:x11"${W}
echo
echo "${Y}2. Vnc"${W}
echo
echo "${Y}3. Both"${W}
echo
read -p "${Y}select an option (Default 1): "${W} gui_mode
gui_mode=${gui_mode:-1}
echo "${R}[${W}-${R}]${G}Continuing with answer: $gui_mode"${W}
sleep 0.2
banner
confirmation_y_or_n "Do you want to start the desktop at Termux startup" de_on_startup
if [[ "$de_on_startup" == "y" && "$gui_mode" == "3" ]]; then
echo "${R}[${W}-${R}]${G} You chose both vnc and termux:x11 to access gui mode"${W}
echo
echo "${R}[${W}-${R}]${G} Which will be your default"${W}
echo
echo "${Y}1. Termux:x11"${W}
echo
echo "${Y}2. Vnc"${W}
echo
read -p "${Y}select an option (1 is Recomended): "${W} autostart_gui_mode
autostart_gui_mode=${autostart_gui_mode:-1}
echo "${R}[${W}-${R}]${G}Continuing with answer: $autostart_gui_mode"${W}
sleep 0.2
fi
banner
echo "${R}[${W}-${R}]${Y}${BOLD}Do you want to add a distro container (proot distro)"${W}
echo
echo "${R}[${W}-${R}]${G} It will help you to install those app which are not avilable in termux"${W}
echo
echo "${R}[${W}-${R}]${C}You can launch those installed apps from termux like other apps"${W}
echo
confirmation_y_or_n "Do you want to continue" distro_add_answer
echo "distro_add_answer=\"$distro_add_answer\"" >> $config_file
clear
if ! type -p pacman >/dev/null 2>&1; then
echo "${R}[${W}-${R}]${R}${BOLD} Read This Carefully"${W}
echo -e "
The experimental drivers only support a few GPUs and currently use Vulkan, with no OpenGL support.\n
In my tests, I achieved 1000+ FPS in vkmark on all my devices. I tried it on an Adreno 619 (best everything work fine), Adreno 750 (usable but some apps don't launch), Adreno 720 (good overall but with few issues), and Mali G76 (similar issue like Adreno 720).\n
Also if you have Adreno GPU then please select ubuntu or debian as distro container so it can use ternip in the distro container.\n
Sadly for other then adreno, GPU might not work on the distro container./n
If you type 'n/N' then it will use the old way to setup Hardware Acceleration./n
"
confirmation_y_or_n "Do you want to enable the new Experimental Hardware Acceleration support" confirmation_exp_hwa
echo "confirmation_exp_hwa=\"$confirmation_exp_hwa\"" >> $config_file
fi
}
# distro hardware accelrration related questions
function distro_hw_questions() {
if [[ "$distro_add_answer" == "y" ]]; then
echo
echo "${R}[${W}-${R}]${G}${BOLD}Select Hardware Acceleration API For Distro Container"${W}
echo
echo "${R}[${W}-${R}]${G}If You Are Not Sure So Skip It It Will Use The Previous One"${W}
echo
if [[ "$termux_hw_answer" == "2" ]]; then
echo "${Y}1. Vulkan (ZINK)"${W}
echo
echo "${Y}2. OpenGL (VIRGL)"${W}
echo
echo "${Y}3. OpenGL ES (ZINK VIRGL)"${W}
echo
echo "${Y}4. Turnip (Adreno GPU Only)"${W}
echo
echo "${Y}5. Skip"${W}
echo
else
echo "${Y}1. Vulkan (ZINK)"${W}
echo
echo "${Y}2. OpenGL ES (ZINK VIRGL)"${W}
echo
echo "${Y}3. Turnip (Adreno GPU Only)"${W}
echo
echo "${Y}4. Skip"${W}
echo
fi
read -p "${Y}select an option : "${W} pd_hw_answer
pd_hw_answer=${pd_hw_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $pd_hw_answer"${W}
sleep 0.2
echo "pd_hw_answer=\"$pd_hw_answer\"" >> $config_file
fi
}
# hardware accelrration related questions
function exp_hwa_support() {
if [[ "$confirmation_exp_hwa" == "y" ]]; then
echo "${R}[${W}-${R}]${G} Experimental Hardware Acceleration Will Use The mesa-vulkan-icd-wrapper Package"${W}
echo "${R}[${W}-${R}]${G} It Will Use Vulkan"
echo "${R}[${W}-${R}]${G}${BOLD} Select Your Device GPU"${W}
echo
echo "${Y}1. Adreno"${W}
echo
echo "${Y}2. Mali"${W}
echo
echo "${Y}3. Xclipse"${W}
echo
echo "${Y}4. Others"${W}
echo
read -p "${Y}select an option : "${W} device_gpu_model
device_gpu_model=${device_gpu_model:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $device_gpu_model"${W}
echo "device_gpu_model=\"$device_gpu_model\"" >> $config_file
sleep 0.2
if [[ "$device_gpu_model" == "1" ]]; then
if [[ "$distro_answer" == "1" || "$distro_answer" == "2" ]]; then
pd_hw_answer="3"
fi
elif [[ "$device_gpu_model" == "4" ]]; then
echo "${R}[${W}-${R}]${C}${BOLD}For other GPUs, this might not work and could break the desktop environment"${W}
echo
sleep 2
fi
echo "${R}[${W}-${R}]${G}${BOLD}First Read This"${W}
echo
fi
}
function hw_questions() {
echo "${R}[${W}-${R}]${G}${BOLD}First Read This"${W}
echo
echo "${R}[${W}-${R}]${B}This:- https://github.com/sabamdarif/termux-desktop/blob/main/hw-acceleration.md"${W}
echo
echo "${R}[${W}-${R}]${G}${BOLD}Select Hardware Acceleration API"${W}
echo
echo "${Y}1. Vulkan (ZINK)"${W}
echo
echo "${Y}2. OpenGL (VIRGL)"${W}
echo
echo "${Y}3. OpenGL ES (ZINK VIRGL)"${W}
echo
echo "${Y}4. Freedreno ${C}(Adreno 610 And Above | didn't work for me)"${W}
echo
read -p "${Y}select an option : "${W} termux_hw_answer
termux_hw_answer=${termux_hw_answer:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $termux_hw_answer"${W}
echo "termux_hw_answer=\"$termux_hw_answer\"" >> $config_file
sleep 0.2
distro_hw_questions
}
# distro related questions
function choose_distro() {
echo "${R}[${W}-${R}]${G}${BOLD}Select Distro You Want To Add"${W}
echo
echo "${Y}1. Debian"${W}
echo
echo "${Y}2. Ubuntu"${W}
echo
echo "${Y}3. Arch"${W}
echo
echo "${Y}4. Apline"${W}
echo
echo "${Y}5. Fedora"${W}
echo
read -p "${Y}select an option (Default 1): "${W} distro_answer
distro_answer=${distro_answer:-1}
echo "distro_answer=\"$distro_answer\"" >> $config_file
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $distro_answer"${W}
sleep 0.2
}
function distro_questions() {
banner
choose_distro
banner
confirmation_y_or_n "Do you want to configure audio support for distro container" pd_audio_config_answer
if [[ "$distro_add_answer" == "y" ]] && [[ "$zsh_answer" == "y" ]]; then
banner
confirmation_y_or_n "Do you want to Configuring Zsh also for distro container ${C}(take longer time to login into distro)" distro_zsh_answer
echo "distro_zsh_answer=\"$distro_zsh_answer\"" >> $config_file
fi
if [[ "$distro_add_answer" == "y" ]] && [[ "$terminal_utility_setup_answer" == "y" ]]; then
banner
confirmation_y_or_n "Do you want install the terminal utility also for distro container" distro_terminal_utility_setup_answer
echo "distro_terminal_utility_setup_answer=\"$distro_terminal_utility_setup_answer\"" >> $config_file
fi
banner
confirmation_y_or_n "Do you want to create a normal user account ${C}(Recomended)" pd_useradd_answer
echo "pd_useradd_answer=\"$pd_useradd_answer\"" >> $config_file
echo
if [[ "$pd_useradd_answer" == "n" ]]; then
echo "${R}[${W}-${R}]${G}Skiping User Account Setup"${W}
else
echo "${R}[${W}-${R}]${G}${BOLD} Select user account type"${W}
echo
echo "${Y}1. User with no password confirmation"${W}
echo
echo "${Y}2. User with password confirmation"${W}
echo
read -p "${Y}select an option (Default 1): "${W} pd_pass_type
pd_pass_type=${pd_pass_type:-1}
echo "pd_pass_type=\"$pd_pass_type\"" >> $config_file
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $pd_pass_type"${W}
echo
sleep 0.2
if [[ "$pd_pass_type" == "1" ]]; then
while true; do
echo "${R}[${W}-${R}]${G}Default Password Will Be Set, Because Sometime It Might Ask You For Password"${W}
echo
echo "${R}[${W}-${R}]${G}Password:-${C}root"${W}
echo
read -p "${R}[${W}-${R}]${G}Input username [Lowercase]: "${W} user_name
echo
read -p "${R}[${W}-${R}]${Y}Do you want to continue with username ${C}$user_name ${Y}? (y/n) : "${W} choice
echo
choice="${choice:-y}"
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $choice"${W}
sleep 0.2
case $choice in
[yY]* )
echo "${R}[${W}-${R}]${G}Continuing with username ${C}$user_name "${W}
break;;
[nN]* )
echo "${G}Please provide username again."${W}
echo
;;
* )
echo "${R}Invalid input. Please enter 'y' or 'n'."${W}
;;
esac
done
echo "user_name=\"$user_name\"" >> $config_file
elif [[ "$pd_pass_type" == "2" ]]; then
echo
echo "${R}[${W}-${R}]${G}${BOLD} Create user account"${W}
echo
while true; do
read -p "${R}[${W}-${R}]${G}Input username [Lowercase]: "${W} user_name
echo
read -p "${R}[${W}-${R}]${G}Input Password: "${W} pass
echo
read -p "${R}[${W}-${R}]${Y}Do you want to continue with username ${C}$user_name ${Y}and password ${C}$pass${Y} ? (y/n) : "${W} choice
echo
choice="${choice:-y}"
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $choice"${W}
echo ""
sleep 0.2
case $choice in
[yY]* )
echo "${R}[${W}-${R}]${G}Continuing with username ${C}$user_name ${G}and password ${C}$pass"${W}
break;;
[nN]* )
echo "${G}Please provide username and password again."${W}
echo
;;
* )
echo "${R}Invalid input. Please enter 'y' or 'n'."${W}
;;
esac
done
echo "user_name=\"$user_name\"" >> $config_file
echo "pass=\"$pass\"" >> $config_file
fi
fi
}
#########################################################################
#
# Update System And Install Required Packages Repo And Bssic Task
#
#########################################################################
function update_sys() {
banner
echo "${R}[${W}-${R}]${G}${BOLD} Updating System...."${W}
echo
if type -p pacman >/dev/null 2>&1; then
pacman -Syu --noconfirm
else
echo "${G}${BOLD}Selecting best termux packages mirror please wait"${W}
unlink "$PREFIX/etc/termux/chosen_mirrors" &>/dev/null
ln -s "$PREFIX/etc/termux/mirrors/all" "$PREFIX/etc/termux/chosen_mirrors" &>/dev/null
pkg --check-mirror update
pkg update -y -o Dpkg::Options::="--force-confnew"
pkg upgrade -y -o Dpkg::Options::="--force-confnew"
fi
}
function install_required_packages() {
banner
echo "${R}[${W}-${R}]${Y}${BOLD} Installling required packages..."${W}
echo
if type -p pacman >/dev/null 2>&1; then
package_install_and_check "wget pv jq curl pulseaudio termux-am"
else
package_install_and_check "wget pv jq curl pulseaudio tar xz-utils gzip termux-am x11-repo tur-repo"
fi
sed -i 's/termux-am="already_exist"/ /' $config_file
update_sys
}
function install_desktop() {
banner
if [[ "$desktop_answer" == "1" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Installing Xfce4 Desktop"${W}
echo
package_install_and_check "xfce4 xfce4-goodies xwayland kvantum"
elif [[ "$desktop_answer" == "2" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Installing Lxqt Desktop"${W}
echo
package_install_and_check "lxqt openbox gtk3 papirus-icon-theme xorg-xsetroot xwayland kvantum"
elif [[ "$desktop_answer" == "3" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Installing Openbox WM"${W}
echo
package_install_and_check "openbox polybar xorg-xsetroot lxappearance wmctrl feh xwayland kvantum termux-api thunar firefox mpd rofi bmon xcompmgr xfce4-settings gtk3 gedit"
fi
# if [[ "$distro_add_answer" == "y" ]]; then
# package_install_and_check "xdg-utils"
# fi
}
#########################################################################
#
# Theme Installer
#
#########################################################################
function set_config_dir() {
if [[ "$de_name" == "xfce" ]]; then
config_dirs=(autostart cairo-dock dconf gtk-3.0 Mousepad pulse Thunar menu ristretto rofi xfce4)
elif [[ "$de_name" == "lxqt" ]]; then
config_dirs=(fontconfig gtk-3.0 lxqt pcmanfm-qt QtProject.conf glib-2.0 Kvantum openbox qterminal.org)
elif [[ "$de_name" == "openbox" ]]; then
config_dirs=(dconf gedit Kvantum openbox pulse rofi xfce4 enchant gtk-3.0 mimeapps.list polybar QtProject.conf Thunar)
fi
}
function theme_installer() {
banner
echo "${R}[${W}-${R}]${G}${BOLD} Configuring Theme: ${C}${style_name}"${W}
echo
if [[ "$de_name" == "xfce" ]] || [[ "$de_name" == "openbox" ]]; then
package_install_and_check "gnome-themes-extra"
fi
sleep 3
banner
echo "${R}[${W}-${R}]${G}${BOLD} Configuring Wallpapers..."${W}
echo
check_and_create_directory "$PREFIX/share/backgrounds"
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/${de_name}/look_${style_answer}/wallpaper.tar.gz" "$PREFIX/share/backgrounds/"
banner
check_and_create_directory "$icons_folder"
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/${de_name}/look_${style_answer}/icon.tar.gz" "$icons_folder"
if [[ "$de_name" == "xfce" ]]; then
local icons_themes_names=$(ls $icons_folder)
local icons_theme
for icons_theme in $icons_themes_names; do
if [[ -d "$icons_folder/$icons_theme" ]]; then
echo "${R}[${W}-${R}]${G}Creating icon cache..."${W}
gtk-update-icon-cache -f -t $icons_folder/$icons_theme
fi
done
fi
local sys_icons_themes_names=$(ls $sys_icons_folder)
local sys_icons_theme
for sys_icons_theme in $sys_icons_themes_names; do
if [[ -d "$sys_icons_folder/$sys_icons_theme" ]]; then
echo "${R}[${W}-${R}]${G}Creating icon cache..."${W}
gtk-update-icon-cache -f -t $sys_icons_folder/$sys_icons_theme
fi
done
echo "${R}[${W}-${R}]${G}${BOLD} Installing Theme..."${W}
echo
check_and_create_directory "$themes_folder"
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/${de_name}/look_${style_answer}/theme.tar.gz" "$themes_folder"
echo "${R}[${W}-${R}]${G} Making Additional Configuration..."${W}
echo
check_and_create_directory "$HOME/.config"
set_config_dir
for the_config_dir in "${config_dirs[@]}"; do
check_and_delete "$HOME/.config/$the_config_dir"
done
if [[ "$de_name" == "openbox" ]]; then
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/${de_name}/look_${style_answer}/config.tar.gz" "$HOME"
else
download_and_extract "https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/patch/${de_name}/look_${style_answer}/config.tar.gz" "$HOME/.config/"
fi
}
#########################################################################
#
# Install Additional Packages For Theme
#
#########################################################################
function additional_required_package_installler() {
banner
if [[ "$de_name" == "xfce" ]]; then
echo "${R}[${W}-${R}]${G}${BOLD} Installing Additional Packages If Required..."${W}
echo