-
Notifications
You must be signed in to change notification settings - Fork 4
/
xfce.sh
1057 lines (959 loc) · 39.5 KB
/
xfce.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
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
#!/bin/bash
#------------------------------------------------------------------------------
# GLOBALES VARIABLES
#------------------------------------------------------------------------------
USE_GUM=false
VERBOSE=false
BROWSER="chromium"
#------------------------------------------------------------------------------
# COLORS DISPLAY
#------------------------------------------------------------------------------
COLOR_BLUE='\033[38;5;33m' # Information
COLOR_GREEN='\033[38;5;82m' # Success
COLOR_GOLD='\033[38;5;220m' # Warning
COLOR_RED='\033[38;5;196m' # Error
COLOR_RESET='\033[0m' # Reset
#------------------------------------------------------------------------------
# REDIRECTION
#------------------------------------------------------------------------------
if [ "$VERBOSE" = false ]; then
REDIRECT=">/dev/null 2>&1"
else
REDIRECT=""
fi
#------------------------------------------------------------------------------
# DISPLAY HELP
#------------------------------------------------------------------------------
show_help() {
clear
echo "Help OhMyTermux"
echo
echo "Usage: $0 [OPTIONS] [username] [password]"
echo "Options:"
echo " --gum | -g Use gum for the user interface"
echo " --verbose | -v Display detailed outputs"
echo " --browser | -b Choose the browser (Chromium or Firefox)"
echo " --version | -ver Choose the installation type (minimal, recommended, custom)"
echo " --full Install all modules without confirmation"
echo " --help | -h Display this help message"
}
#------------------------------------------------------------------------------
# GLOBAL VARIABLES FOR CUSTOM INSTALLATION
#------------------------------------------------------------------------------
INSTALL_THEME=false
INSTALL_ICONS=false
INSTALL_WALLPAPERS=false
INSTALL_CURSORS=false
INSTALL_TYPE=""
SELECTED_THEME="WhiteSur"
SELECTED_THEMES=()
SELECTED_ICON_THEME="WhiteSur"
SELECTED_ICON_THEMES=()
SELECTED_WALLPAPER="Monterey.jpg"
#------------------------------------------------------------------------------
# GLOBAL VARIABLES FOR COMPLETE INSTALLATION
#------------------------------------------------------------------------------
FULL_INSTALL=false
XFCE_VERSION=""
BROWSER_CHOICE=""
INSTALL_THEME=false
INSTALL_ICONS=false
INSTALL_WALLPAPERS=false
INSTALL_CURSORS=false
SELECTED_THEME=""
SELECTED_ICON_THEME=""
SELECTED_WALLPAPER=""
#------------------------------------------------------------------------------
# ARGUMENTS MANAGEMENT
#------------------------------------------------------------------------------
for arg in "$@"; do
case $arg in
--gum|-g)
USE_GUM=true
shift
;;
--verbose|-v)
VERBOSE=true
REDIRECT=""
shift
;;
--browser|-b)
BROWSER="${2}"
shift 2
;;
--version=*)
INSTALL_TYPE="${arg#*=}"
shift
;;
--full)
FULL_INSTALL=true
XFCE_VERSION="recommandée"
BROWSER_CHOICE="chromium"
INSTALL_THEME=true
INSTALL_ICONS=true
INSTALL_WALLPAPERS=true
INSTALL_CURSORS=true
SELECTED_THEMES=("WhiteSur")
SELECTED_THEME="WhiteSur-Dark"
SELECTED_ICON_THEME="WhiteSur"
SELECTED_WALLPAPER="WhiteSur"
shift
;;
--help|-h)
show_help
exit 0
;;
*)
break
;;
esac
done
#------------------------------------------------------------------------------
# GUM CONFIRMATION
#------------------------------------------------------------------------------
gum_confirm() {
local PROMPT="$1"
if $FULL_INSTALL; then
return 0
else
gum confirm --affirmative "Oui" --negative "Non" --prompt.foreground="33" --selected.background="33" --selected.foreground="0" "$PROMPT"
fi
}
#------------------------------------------------------------------------------
# GUM UNIQUE SELECTION
#------------------------------------------------------------------------------
gum_choose() {
local PROMPT="$1"
shift
local SELECTED=""
local OPTIONS=()
local HEIGHT=10
while [[ $# -gt 0 ]]; do
case $1 in
--selected=*)
SELECTED="${1#*=}"
;;
--height=*)
HEIGHT="${1#*=}"
;;
*)
OPTIONS+=("$1")
;;
esac
shift
done
gum choose --selected.foreground="33" --header.foreground="33" --cursor.foreground="33" --height="$HEIGHT" --header="$PROMPT" --selected="$SELECTED" "${OPTIONS[@]}"
}
#------------------------------------------------------------------------------
# GUM MULTIPLE SELECTION
#------------------------------------------------------------------------------
gum_choose_multi() {
local PROMPT="$1"
shift
local SELECTED=""
local OPTIONS=()
local HEIGHT=10
while [[ $# -gt 0 ]]; do
case $1 in
--selected=*)
SELECTED="${1#*=}"
;;
--height=*)
HEIGHT="${1#*=}"
;;
*)
OPTIONS+=("$1")
;;
esac
shift
done
gum choose --no-limit --selected.foreground="33" --header.foreground="33" --cursor.foreground="33" --height="$HEIGHT" --header="$PROMPT" --selected="$SELECTED" "${OPTIONS[@]}"
}
#------------------------------------------------------------------------------
# TEXT BANNER
#------------------------------------------------------------------------------
bash_banner() {
clear
local BANNER="
╔═════════════��══════════════════════════╗
║ ║
║ OHMYTERMUX ║
║ ║
╚════════════════════════════════════════╝"
echo -e "${COLOR_BLUE}${BANNER}${COLOR_RESET}\n"
}
#------------------------------------------------------------------------------
# GRAPHIC BANNER
#------------------------------------------------------------------------------
show_banner() {
clear
if $USE_GUM; then
gum style \
--foreground 33 \
--border-foreground 33 \
--border double \
--align center \
--width 42 \
--margin "1 1 1 0" \
"" "OHMYTERMUX" ""
else
bash_banner
fi
}
#------------------------------------------------------------------------------
# ERROR MANAGEMENT
#------------------------------------------------------------------------------
finish() {
local RET=$?
if [ ${RET} -ne 0 ] && [ ${RET} -ne 130 ]; then
echo
if $USE_GUM; then
gum style --foreground 196 "ERREUR: Installation de OhMyTermux impossible."
else
echo -e "${COLOR_RED}ERREUR: Installation de OhMyTermux impossible.${COLOR_RESET}"
fi
echo -e "${COLOR_BLUE}Veuillez vous rférer au(x) message(s) d'erreur ci-dessus.${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# INFORMATION MESSAGES
#------------------------------------------------------------------------------
info_msg() {
if $USE_GUM; then
gum style "${1//$'\n'/ }" --foreground 33
else
echo -e "${COLOR_BLUE}$1${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# SUCCESS MESSAGES
#------------------------------------------------------------------------------
success_msg() {
if $USE_GUM; then
gum style "${1//$'\n'/ }" --foreground 82
else
echo -e "${COLOR_GREEN}$1${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# ERROR MESSAGES
#------------------------------------------------------------------------------
error_msg() {
if $USE_GUM; then
gum style "${1//$'\n'/ }" --foreground 196
else
echo -e "${COLOR_RED}$1${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# TITLE MESSAGES
#------------------------------------------------------------------------------
title_msg() {
if $USE_GUM; then
gum style "${1//$'\n'/ }" --foreground 220 --bold
else
echo -e "\n${COLOR_GOLD}\033[1m$1\033[0m${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# SUBTITLE MESSAGES
#------------------------------------------------------------------------------
subtitle_msg() {
if $USE_GUM; then
gum style "${1//$'\n'/ }" --foreground 33 --bold
else
echo -e "\n${COLOR_BLUE}\033[1m$1\033[0m${COLOR_RESET}"
fi
}
#------------------------------------------------------------------------------
# ERROR LOGGING
#------------------------------------------------------------------------------
log_error() {
local ERROR_MSG="$1"
local USERNAME=$(whoami)
local HOSTNAME=$(hostname)
local CWD=$(pwd)
echo "[$(date +'%d/%m/%Y %H:%M:%S')] ERREUR: $ERROR_MSG | Utilisateur: $USERNAME | Machine: $HOSTNAME | Répertoire: $CWD" >> "$HOME/.config/OhMyTermux/install.log"
}
#------------------------------------------------------------------------------
# DYNAMIC RESULT DISPLAY OF A COMMAND
#------------------------------------------------------------------------------
execute_command() {
local COMMAND="$1"
local INFO_MSG="$2"
local SUCCESS_MSG="✓ $INFO_MSG"
local ERROR_MSG="✗ $INFO_MSG"
local ERROR_DETAILS
if $USE_GUM; then
if gum spin --spinner.foreground="33" --title.foreground="33" --spinner dot --title "$INFO_MSG" -- bash -c "$COMMAND $REDIRECT"; then
gum style "$SUCCESS_MSG" --foreground 82
else
ERROR_DETAILS="Command: $COMMAND, Redirect: $REDIRECT, Time: $(date +'%d/%m/%Y %H:%M:%S')"
gum style "$ERROR_MSG" --foreground 196
log_error "$ERROR_DETAILS"
return 1
fi
else
tput sc
info_msg "$INFO_MSG"
if eval "$COMMAND $REDIRECT"; then
tput rc
tput el
success_msg "$SUCCESS_MSG"
else
tput rc
tput el
ERROR_DETAILS="Command: $COMMAND, Redirect: $REDIRECT, Time: $(date +'%d/%m/%Y %H:%M:%S')"
error_msg "$ERROR_MSG"
log_error "$ERROR_DETAILS"
return 1
fi
fi
}
#------------------------------------------------------------------------------
# FILE DOWNLOAD
#------------------------------------------------------------------------------
download_file() {
local URL=$1
local MESSAGE=$2
execute_command "wget $URL" "$MESSAGE"
}
trap finish EXIT
#------------------------------------------------------------------------------
# XFCE CONFIGURATION
#------------------------------------------------------------------------------
configure_xfce() {
local CONFIG_DIR="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml"
local INSTALL_TYPE="$1"
local BROWSER_DESKTOP
# Set the browser .desktop file
if [ "$BROWSER" = "firefox" ]; then
BROWSER_DESKTOP="firefox"
elif [ "$BROWSER" = "chromium" ]; then
BROWSER_DESKTOP="chromium"
else
BROWSER_DESKTOP="$BROWSER"
fi
# Create the configuration directory if it doesn't exist
mkdir -p "$CONFIG_DIR" >/dev/null 2>&1
# Configure the default browser
cat > "$CONFIG_DIR/xfce4-mime-settings.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-mime-settings" version="1.0">
<property name="last" type="empty">
<property name="window-width" type="int" value="550"/>
<property name="window-height" type="int" value="400"/>
<property name="mime-width" type="int" value="300"/>
<property name="status-width" type="int" value="75"/>
<property name="default-width" type="int" value="150"/>
</property>
<property name="default" type="empty">
<property name="x-scheme-handler/http" type="string" value="$BROWSER_DESKTOP.desktop"/>
<property name="x-scheme-handler/https" type="string" value="$BROWSER_DESKTOP.desktop"/>
</property>
</channel>
EOF
# Create the mimeapps.list file
mkdir -p "$HOME/.config" >/dev/null 2>&1
cat > "$HOME/.config/mimeapps.list" << EOF
[Default Applications]
x-scheme-handler/http=$BROWSER_DESKTOP.desktop
x-scheme-handler/https=$BROWSER_DESKTOP.desktop
text/html=$BROWSER_DESKTOP.desktop
application/xhtml+xml=$BROWSER_DESKTOP.desktop
[Added Associations]
x-scheme-handler/http=$BROWSER_DESKTOP.desktop
x-scheme-handler/https=$BROWSER_DESKTOP.desktop
text/html=$BROWSER_DESKTOP.desktop
application/xhtml+xml=$BROWSER_DESKTOP.desktop
EOF
# Configure xfce4-terminal
mkdir -p "$HOME/.config/xfce4/terminal" >/dev/null 2>&1
cat > "$HOME/.config/xfce4/terminal/terminalrc" << EOF
[Configuration]
FontName=Monospace 11
MiscAlwaysShowTabs=FALSE
MiscBell=FALSE
MiscBellUrgent=FALSE
MiscBordersDefault=TRUE
MiscCursorBlinks=FALSE
MiscCursorShape=TERMINAL_CURSOR_SHAPE_BLOCK
MiscDefaultGeometry=120x30
MiscInheritGeometry=FALSE
MiscMenubarDefault=FALSE
MiscMouseAutohide=FALSE
MiscMouseWheelZoom=TRUE
MiscToolbarDefault=FALSE
MiscConfirmClose=TRUE
MiscCycleTabs=TRUE
MiscTabCloseButtons=TRUE
MiscTabCloseMiddleClick=TRUE
MiscTabPosition=GTK_POS_TOP
MiscHighlightUrls=TRUE
MiscMiddleClickOpensUri=FALSE
MiscRightClickAction=TERMINAL_RIGHT_CLICK_ACTION_CONTEXT_MENU
MiscCopyOnSelect=FALSE
MiscShowRelaunchDialog=TRUE
MiscRewrapOnResize=TRUE
MiscUseShiftArrowsToScroll=FALSE
MiscSlimTabs=FALSE
MiscNewTabAdjacent=FALSE
ScrollingBar=TERMINAL_SCROLLBAR_NONE
BackgroundMode=TERMINAL_BACKGROUND_TRANSPARENT
BackgroundDarkness=0.800000
TitleMode=TERMINAL_TITLE_HIDE
ScrollingLines=10000
ColorForeground=#c0caf5
ColorBackground=#1a1b26
ColorCursor=#c0caf5
ColorPalette=#15161e;#f7768e;#9ece6a;#e0af68;#7aa2f7;#bb9af7;#7dcfff;#a9b1d6;#414868;#f7768e;#9ece6a;#e0af68;#7aa2f7;#bb9af7;#7dcfff;#c0caf5
EOF
# Configure xfce4-panel.xml if whiskermenu is not installed
if ! command -v xfce4-popup-whiskermenu &> /dev/null; then
sed -i 's/<property name="plugin-5" type="string" value="whiskermenu">/<property name="plugin-5" type="string" value="applicationsmenu">/' "$CONFIG_DIR/xfce4-panel.xml" >/dev/null 2>&1
sed -i '/<property name="plugin-5".*whiskermenu/,/<\/property>/c\ <property name="plugin-5" type="string" value="applicationsmenu"/>' "$CONFIG_DIR/xfce4-panel.xml" >/dev/null 2>&1
fi
case "$INSTALL_TYPE" in
"recommandée")
# Complete configuration with all elements
cat > "$CONFIG_DIR/xsettings.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xsettings" version="1.0">
<property name="Net" type="empty">
<property name="ThemeName" type="string" value="WhiteSur-Dark"/>
<property name="IconThemeName" type="string" value="WhiteSur-dark"/>
</property>
<property name="Gtk" type="empty">
<property name="CursorThemeName" type="string" value="dist-dark"/>
<property name="CursorThemeSize" type="int" value="32"/>
</property>
</channel>
EOF
cat > "$CONFIG_DIR/xfwm4.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfwm4" version="1.0">
<property name="general" type="empty">
<property name="theme" type="string" value="WhiteSur-Dark"/>
</property>
</channel>
EOF
;;
"minimale"|"personnalisée")
# Base configuration
local THEME_VALUE="Default"
local ICON_VALUE="Adwaita"
local CURSOR_VALUE="default"
local WALLPAPER="/data/data/com.termux/files/usr/share/backgrounds/xfce/xfce-stripes.png"
# Adjust according to custom choices
if [ "$INSTALL_THEME" = true ]; then
case $SELECTED_THEME in
"WhiteSur") THEME_VALUE="WhiteSur-Dark" ;;
"Fluent") THEME_VALUE="Fluent-dark-compact" ;;
"Lavanda") THEME_VALUE="Lavanda-dark-compact" ;;
esac
fi
if [ "$INSTALL_ICONS" = true ]; then
case $SELECTED_ICON_THEME in
"WhiteSur") ICON_VALUE="WhiteSur-dark" ;;
"McMojave-circle") ICON_VALUE="McMojave-circle-dark" ;;
"Tela") ICON_VALUE="Tela-dark" ;;
"Fluent") ICON_VALUE="Fluent-dark" ;;
"Qogir") ICON_VALUE="Qogir-dark" ;;
esac
fi
[ "$INSTALL_CURSORS" = true ] && CURSOR_VALUE="dist-dark"
[ "$INSTALL_WALLPAPERS" = true ] && WALLPAPER="/data/data/com.termux/files/usr/share/backgrounds/whitesur/${SELECTED_WALLPAPER}.jpg"
# Generate xsettings.xml
cat > "$CONFIG_DIR/xsettings.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xsettings" version="1.0">
<property name="Net" type="empty">
<property name="ThemeName" type="string" value="$THEME_VALUE"/>
<property name="IconThemeName" type="string" value="$ICON_VALUE"/>
</property>
<property name="Gtk" type="empty">
<property name="CursorThemeName" type="string" value="$CURSOR_VALUE"/>
<property name="CursorThemeSize" type="int" value="32"/>
</property>
</channel>
EOF
# Generate xfwm4.xml
cat > "$CONFIG_DIR/xfwm4.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfwm4" version="1.0">
<property name="general" type="empty">
<property name="theme" type="string" value="$THEME_VALUE"/>
</property>
</channel>
EOF
# Generate xfce4-desktop.xml
cat > "$CONFIG_DIR/xfce4-desktop.xml" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-desktop" version="1.0">
<property name="backdrop" type="empty">
<property name="screen0" type="empty">
<property name="monitorBuiltinDisplay" type="empty">
<property name="workspace0" type="empty">
<property name="image-style" type="int" value="5"/>
<property name="last-image" type="string" value="$WALLPAPER"/>
</property>
</property>
</property>
</property>
<property name="desktop-icons" type="empty">
<property name="file-icons" type="empty">
<property name="show-home" type="bool" value="false"/>
<property name="show-filesystem" type="bool" value="false"/>
<property name="show-trash" type="bool" value="false"/>
</property>
</property>
</channel>
EOF
;;
esac
# Apply permissions
chmod 644 "$CONFIG_DIR"/*.xml >/dev/null 2>&1
}
#------------------------------------------------------------------------------
# THEME CONFIGURATION SAVE
#------------------------------------------------------------------------------
save_theme_config() {
mkdir -p "$HOME/.config/OhMyTermux"
cat > "$HOME/.config/OhMyTermux/theme_config.tmp" << EOF
INSTALL_THEME=$INSTALL_THEME
INSTALL_ICONS=$INSTALL_ICONS
INSTALL_WALLPAPERS=$INSTALL_WALLPAPERS
INSTALL_CURSORS=$INSTALL_CURSORS
SELECTED_THEME="$SELECTED_THEME"
SELECTED_ICON_THEME="$SELECTED_ICON_THEME"
SELECTED_WALLPAPER="$SELECTED_WALLPAPER"
EOF
}
#------------------------------------------------------------------------------
# THEME INSTALLATION
#------------------------------------------------------------------------------
install_theme_pack() {
local THEME_NAME="$1"
local DOWNLOAD_URL="$2"
local INSTALL_MESSAGE="$3"
local ARCHIVE="theme.zip"
# Download the archive
execute_command "wget -O $ARCHIVE '$DOWNLOAD_URL'" "Download theme $THEME_NAME"
# Extract the archive
execute_command "unzip -o $ARCHIVE" "Extraction of theme $THEME_NAME"
# Detect the name of the extracted directory
local EXTRACTED_DIR=$(ls -d */ | grep -i "$THEME_NAME" | head -n 1)
# Install theme
case $THEME_NAME in
"WhiteSur")
execute_command "cd '$EXTRACTED_DIR' && \
tar -xf release/WhiteSur-Dark.tar.xz && \
mv WhiteSur-Dark/ $PREFIX/share/themes/ && \
cd .. && \
rm -rf '$EXTRACTED_DIR' $ARCHIVE" "$INSTALL_MESSAGE"
;;
*)
execute_command "cd '$EXTRACTED_DIR' && \
./install.sh -d $PREFIX/share/themes -c dark -s compact && \
cd .. && \
rm -rf '$EXTRACTED_DIR' $ARCHIVE" "$INSTALL_MESSAGE"
;;
esac
}
install_themes() {
if $INSTALL_THEME; then
# If it's a complete installation, set WhiteSur as the default theme
if $FULL_INSTALL; then
SELECTED_THEMES=("WhiteSur")
SELECTED_THEME="WhiteSur"
fi
# Installation of selected themes
for THEME in "${SELECTED_THEMES[@]}"; do
case $THEME in
"WhiteSur")
install_theme_pack "WhiteSur" "https://github.com/vinceliuice/WhiteSur-gtk-theme/archive/refs/tags/2024-11-18.zip" "Install theme WhiteSur"
;;
"Fluent")
install_theme_pack "Fluent" "https://github.com/vinceliuice/Fluent-gtk-theme/archive/refs/heads/master.zip" "Install theme Fluent"
;;
"Lavanda")
install_theme_pack "Lavanda" "https://github.com/vinceliuice/Lavanda-gtk-theme/archive/refs/heads/main.zip" "Install theme Lavanda"
;;
esac
done
fi
}
#------------------------------------------------------------------------------
# ICON INSTALLATION
#------------------------------------------------------------------------------
install_icon_pack() {
local ICON_NAME="$1"
local DOWNLOAD_URL="$2"
local INSTALL_MESSAGE="$3"
local ARCHIVE="$ICON_NAME-icons.zip"
# Télécharger l'archive
execute_command "wget -O $ARCHIVE '$DOWNLOAD_URL'" "Download icons $ICON_NAME"
# Extract the archive
execute_command "unzip -o $ARCHIVE" "Extraction of icons $ICON_NAME"
# Detect the name of the extracted directory
local EXTRACTED_DIR=$(ls -d */ | grep -i "$ICON_NAME" | head -n 1)
# Install icons
execute_command "cd '$EXTRACTED_DIR' && \
./install.sh -d $PREFIX/share/icons && \
cd .. && \
rm -rf '$EXTRACTED_DIR' $ARCHIVE" "$INSTALL_MESSAGE"
}
install_icons() {
if $INSTALL_ICONS; then
# If it's a complete installation, set WhiteSur as the default icon theme
if $FULL_INSTALL; then
SELECTED_ICON_THEMES=("WhiteSur")
SELECTED_ICON_THEME="WhiteSur"
fi
# Installation of selected icon themes
for ICON_THEME in "${SELECTED_ICON_THEMES[@]}"; do
case $ICON_THEME in
"WhiteSur")
install_icon_pack "WhiteSur" "https://github.com/vinceliuice/WhiteSur-icon-theme/archive/refs/heads/master.zip" "Install icons WhiteSur"
;;
"McMojave-circle")
install_icon_pack "McMojave-circle" "https://github.com/vinceliuice/McMojave-circle/archive/refs/heads/master.zip" "Install icons McMojave-circle"
;;
"Tela")
install_icon_pack "Tela" "https://github.com/vinceliuice/Tela-icon-theme/archive/refs/heads/master.zip" "Install icons Tela"
;;
"Fluent")
install_icon_pack "Fluent" "https://github.com/vinceliuice/Fluent-icon-theme/archive/refs/heads/master.zip" "Install icons Fluent"
;;
"Colloid")
install_icon_pack "Colloid" "https://github.com/vinceliuice/Colloid-icon-theme/archive/refs/heads/main.zip" "Install icons Colloid"
;;
"Qogir")
install_icon_pack "Qogir" "https://github.com/vinceliuice/Qogir-icon-theme/archive/refs/heads/master.zip" "Install icons Qogir"
;;
esac
done
fi
}
#------------------------------------------------------------------------------
# WALLPAPER INSTALLATION
#------------------------------------------------------------------------------
install_wallpapers() {
if $INSTALL_WALLPAPERS; then
ARCHIVE="2023-06-11.zip"
download_file "https://github.com/vinceliuice/WhiteSur-wallpapers/archive/refs/tags/2023-06-11.zip" "Download wallpapers"
execute_command "unzip $ARCHIVE && \
cd WhiteSur-wallpapers-2023-06-11 && \
./install-wallpapers.sh && \
cd .. && \
rm -rf WhiteSur-wallpapers-2023-06-11 $ARCHIVE" "Install wallpapers"
fi
}
#------------------------------------------------------------------------------
# CURSOR INSTALLATION
#------------------------------------------------------------------------------
install_cursors() {
if $INSTALL_CURSORS; then
ARCHIVE="2024-02-25.zip"
download_file "https://github.com/vinceliuice/Fluent-icon-theme/archive/refs/tags/2024-02-25.zip" "Download cursors"
execute_command "unzip $ARCHIVE && \
mv Fluent-icon-theme-2024-02-25/cursors/dist $PREFIX/share/icons/ && \
mv Fluent-icon-theme-2024-02-25/cursors/dist-dark $PREFIX/share/icons/ && \
rm -rf Fluent-icon-theme-2024-02-25 $ARCHIVE" "Install cursors"
fi
}
#------------------------------------------------------------------------------
# MAIN FUNCTION
#------------------------------------------------------------------------------
main() {
# Installation de gum si nécessaire
if $USE_GUM && ! command -v gum &> /dev/null; then
echo -e "${COLOR_BLUE}Installation of gum${COLOR_RESET}"
pkg update -y > /dev/null 2>&1 && pkg install gum -y > /dev/null 2>&1
fi
title_msg "❯ Installation of XFCE"
execute_command "pkg update -y && pkg upgrade -y" "Update packages"
# Base packages
BASE_PKGS=(
'termux-x11-nightly' # X11 server for Termux
'virglrenderer-android' # Graphics acceleration
'xfce4' # Graphical interface
'xfce4-terminal' # Terminal
)
# Recommended packages
RECOMMENDED_PKGS=(
'pavucontrol-qt' # Sound control
'wmctrl' # Window manager
'netcat-openbsd' # Network utility
'thunar-archive-plugin' # Archive manager
'xfce4-whiskermenu-plugin' # Menu Whisker
'xfce4-notifyd' # Notifications
'xfce4-screenshooter' # Screenshot
'xfce4-taskmanager' # Task manager
)
# Optional packages
EXTRA_PKGS=(
'gigolo' # File manager
'jq' # JSON utility
'mousepad' # Text editor
'netcat-openbsd' # Network utility
'parole' # Media player
'pavucontrol-qt' # Sound control
'ristretto' # Image manager
'thunar-archive-plugin' # Archive manager
'thunar-media-tags-plugin' # Media manager
'wmctrl' # Window manager
'xfce4-artwork' # Artwork
'xfce4-battery-plugin' # Battery
'xfce4-clipman-plugin' # Clipboard manager
'xfce4-cpugraph-plugin' # CPU graph
'xfce4-datetime-plugin' # Date and time
'xfce4-dict' # Dictionary
'xfce4-diskperf-plugin' # Disk performance
'xfce4-fsguard-plugin' # Disk monitoring
'xfce4-genmon-plugin' # Generic widgets
'xfce4-mailwatch-plugin' # Mail monitoring
'xfce4-netload-plugin' # Network load
'xfce4-notes-plugin' # Notes
'xfce4-notifyd' # Notifications
'xfce4-places-plugin' # Locations
'xfce4-screenshooter' # Screenshot
'xfce4-taskmanager' # Task manager
'xfce4-systemload-plugin' # System load
'xfce4-timer-plugin' # Timer
'xfce4-wavelan-plugin' # Wi-Fi
'xfce4-weather-plugin' # Weather information
'xfce4-whiskermenu-plugin' # Menu Whisker
)
case "$INSTALL_TYPE" in
"minimal")
PKGS=("${BASE_PKGS[@]}")
;;
"recommended")
INSTALL_THEME=true
INSTALL_ICONS=true
INSTALL_WALLPAPERS=true
INSTALL_CURSORS=true
SELECTED_THEMES=("WhiteSur")
SELECTED_ICON_THEMES=("WhiteSur")
SELECTED_THEME="WhiteSur"
SELECTED_ICON_THEME="WhiteSur"
SELECTED_WALLPAPER="Monterey"
PKGS=("${BASE_PKGS[@]}" "${RECOMMENDED_PKGS[@]}")
;;
"customized")
PKGS=("${BASE_PKGS[@]}")
if $USE_GUM; then
SELECTED_EXTRA=($(gum_choose_multi "Select with SPACE the packages to install :" --height=10 "${EXTRA_PKGS[@]}"))
if [ ${#SELECTED_EXTRA[@]} -gt 0 ]; then
PKGS+=("${SELECTED_EXTRA[@]}")
fi
SELECTED_UI=($(gum_choose_multi "Select with SPACE the graphical elements :" --height=6\
"Themes" \
"Icons" \
"Wallpapers" \
"Cursors"))
if [[ " ${SELECTED_UI[*]} " =~ "Themes" ]]; then
SELECTED_THEMES=($(gum_choose_multi "Select with SPACE the themes to install :" --height=5 \
"WhiteSur" \
"Fluent" \
"Lavanda"))
if [ ${#SELECTED_THEMES[@]} -gt 0 ]; then
INSTALL_THEME=true
if [ ${#SELECTED_THEMES[@]} -gt 1 ]; then
SELECTED_THEME=$(gum_choose "Select the theme to apply :" "${SELECTED_THEMES[@]}" --height=5)
else
SELECTED_THEME="${SELECTED_THEMES[0]}"
fi
fi
fi
if [[ " ${SELECTED_UI[*]} " =~ "Icônes" ]]; then
SELECTED_ICON_THEMES=($(gum_choose_multi "Select with SPACE the icons to install :" --height=8 \
"WhiteSur" \
"McMojave-circle" \
"Tela" \
"Fluent" \
"Colloid" \
"Qogir"))
if [ ${#SELECTED_ICON_THEMES[@]} -gt 0 ]; then
INSTALL_ICONS=true
if [ ${#SELECTED_ICON_THEMES[@]} -gt 1 ]; then
SELECTED_ICON_THEME=$(gum_choose "Select the icons to apply :" "${SELECTED_ICON_THEMES[@]}" --height=8)
else
SELECTED_ICON_THEME="${SELECTED_ICON_THEMES[0]}"
fi
fi
fi
if [[ " ${SELECTED_UI[*]} " =~ "Wallpapers" ]]; then
INSTALL_WALLPAPERS=true
SELECTED_WALLPAPER=$(gum_choose "Select the wallpaper to apply :" --height=13 \
"Monterey" \
"Monterey-dark" \
"Monterey-light" \
"Monterey-morning" \
"Sonoma-dark" \
"Sonoma-light" \
"Ventura-dark" \
"Ventura-light" \
"WhiteSur" \
"WhiteSur-dark" \
"WhiteSur-light")
fi
[[ " ${SELECTED_UI[*]} " =~ "Curseurs" ]] && INSTALL_CURSORS=true
else
echo -e "\n${COLOR_BLUE}Additional packages available :${COLOR_RESET}"
for i in "${!EXTRA_PKGS[@]}"; do
echo "$((i+1))) ${EXTRA_PKGS[i]}"
done
echo
printf "${COLOR_GOLD}Select the packages to install (separated by spaces, or 'a' for all) : ${COLOR_RESET}"
read -r CHOICES
if [ "$CHOICES" = "a" ]; then
PKGS+=("${EXTRA_PKGS[@]}")
else
for choice in $CHOICES; do
if [ "$choice" -ge 1 ] && [ "$choice" -le "${#EXTRA_PKGS[@]}" ]; then
PKGS+=("${EXTRA_PKGS[$((choice-1))]}")
fi
done
fi
echo -e "\n${COLOR_BLUE}Graphical elements available :${COLOR_RESET}"
echo "1) Themes"
echo "2) Icons"
echo "3) Wallpapers"
echo "4) Cursors"
echo
printf "${COLOR_GOLD}Select the graphical elements to install (separated by spaces) : ${COLOR_RESET}"
read -r UI_CHOICES
if [[ $UI_CHOICES =~ 1 ]]; then
echo -e "\n${COLOR_BLUE}Themes available :${COLOR_RESET}"
echo "1) WhiteSur"
echo "2) Fluent"
echo "3) Lavanda"
echo
printf "${COLOR_GOLD}Select the themes to install (separated by spaces) : ${COLOR_RESET}"
read -r THEME_CHOICES
for choice in $THEME_CHOICES; do
case $choice in
1) SELECTED_THEMES+=("WhiteSur") ;;
2) SELECTED_THEMES+=("Fluent") ;;
3) SELECTED_THEMES+=("Lavanda") ;;
esac
done
if [ ${#SELECTED_THEMES[@]} -gt 0 ]; then
INSTALL_THEME=true
if [ ${#SELECTED_THEMES[@]} -gt 1 ]; then
echo -e "\n${COLOR_BLUE}Themes selected :${COLOR_RESET}"
for i in "${!SELECTED_THEMES[@]}"; do
echo "$((i+1))) ${SELECTED_THEMES[i]}"
done
echo
printf "${COLOR_GOLD}Select the theme to apply (1-${#SELECTED_THEMES[@]}) : ${COLOR_RESET}"
read -r THEME_CHOICE
SELECTED_THEME="${SELECTED_THEMES[$((THEME_CHOICE-1))]}"
else
SELECTED_THEME="${SELECTED_THEMES[0]}"
fi
fi
fi
if [[ $UI_CHOICES =~ 2 ]]; then
echo -e "\n${COLOR_BLUE}Icon packs available :${COLOR_RESET}"
echo "1) WhiteSur"
echo "2) McMojave-circle"
echo "3) Tela"
echo "4) Fluent"
echo "5) Qogir"
echo
printf "${COLOR_GOLD}Select the icon packs to install (separated by spaces) : ${COLOR_RESET}"
read -r ICON_CHOICES
for choice in $ICON_CHOICES; do
case $choice in
1) SELECTED_ICON_THEMES+=("WhiteSur") ;;
2) SELECTED_ICON_THEMES+=("McMojave-circle") ;;
3) SELECTED_ICON_THEMES+=("Tela") ;;
4) SELECTED_ICON_THEMES+=("Fluent") ;;
5) SELECTED_ICON_THEMES+=("Qogir") ;;
esac
done
if [ ${#SELECTED_ICON_THEMES[@]} -gt 0 ]; then
INSTALL_ICONS=true
if [ ${#SELECTED_ICON_THEMES[@]} -gt 1 ]; then
echo -e "\n${COLOR_BLUE}Icon packs selected :${COLOR_RESET}"
for i in "${!SELECTED_ICON_THEMES[@]}"; do
echo "$((i+1))) ${SELECTED_ICON_THEMES[i]}"
done
echo
printf "${COLOR_GOLD}Select the icon pack to apply (1-${#SELECTED_ICON_THEMES[@]}) : ${COLOR_RESET}"
read -r ICON_CHOICE
SELECTED_ICON_THEME="${SELECTED_ICON_THEMES[$((ICON_CHOICE-1))]}"
else
SELECTED_ICON_THEME="${SELECTED_ICON_THEMES[0]}"
fi
fi
fi
if [[ $UI_CHOICES =~ 3 ]]; then
INSTALL_WALLPAPERS=true
echo -e "\n${COLOR_BLUE}Wallpapers available :${COLOR_RESET}"
echo "1) Monterey"
echo "2) Monterey-dark"
echo "3) Monterey-light"
echo "4) Monterey-morning"
echo "5) Sonoma-dark"
echo "6) Sonoma-light"
echo "7) Ventura-dark"
echo "8) Ventura-light"
echo "9) WhiteSur"
echo "10) WhiteSur-dark"
echo "11) WhiteSur-light"
echo
printf "${COLOR_GOLD}Select the wallpaper to apply (1-11) : ${COLOR_RESET}"
read -r WALLPAPER_CHOICE