Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1270 lines (1038 loc) · 39.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·1270 lines (1038 loc) · 39.6 KB
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
###################### PATHS ######################
DOWNLOAD_FOLDER="$HOME/Downloads";
SYSTEM_BINARIES_FOLDER="/usr/bin";
SYSTEM_SHARED_RESSOURCE_FOLDER="/usr/share";
SYSTEM_SHARED_FONT_FOLDER="$SYSTEM_SHARED_RESSOURCE_FOLDER/fonts";
SYSTEM_SHARED_ICONS_FOLDER="$SYSTEM_SHARED_RESSOURCE_FOLDER/icons";
SYSTEM_SHARED_APPLICATION_ICON_CONFIG_FOLDER="$SYSTEM_SHARED_RESSOURCE_FOLDER/applications";
SYSTEM_APT_CONFIGURATION_FOLDER="/etc/apt";
SYSTEM_APT_GPG_KEYS_FOLDER="$SYSTEM_APT_CONFIGURATION_FOLDER/trusted.gpg.d";
SYSTEM_APT_REPOSITORY_LIST_FOLDER="$SYSTEM_APT_CONFIGURATION_FOLDER/sources.list.d";
SYSTEM_APT_CACHE_FOLDER="/var/cache/apt";
USER_BINARIES_FOLDER="/usr/local/bin";
VS_CODE_CUSTOM_CONFIG_FOLDER="$HOME/.config/Code/User";
SYSTEM_STEAM_FOLDER="$HOME/.steam/steam";
SYSTEM_STEAM_CONFIG_FOLDER="$SYSTEM_STEAM_FOLDER/config";
SYSTEM_STEAM_USER_DATA_FOLDER="$SYSTEM_STEAM_FOLDER/userdata";
SSH_KEYS_FOLDER="$HOME/.ssh";
###################### UTILS ######################
function CheckScriptEnvironmentVariables()
{
function ImportEnvironmentVariables()
{
local env_variables_path="$1";
if [[ ! -f "$env_variables_path" ]];
then
return 1;
fi
source "$env_variables_path";
};
local env_variables_file=".env";
local env_variables_path="$PWD/$env_variables_file";
local required_env_variables=(
'GIT_TOKEN'
'GIT_USERNAME'
'GIT_EMAIL'
'GIT_SSH_KEY_FILE'
'GIT_SSH_KEY_TITLE'
);
if ! ImportEnvironmentVariables "$env_variables_path";
then
return 1;
fi
for required_env_variable in "${required_env_variables[@]}";
do
if [[ -z "${!required_env_variable}" ]];
then
return 1;
fi
done
return 0;
};
function IncreaseSudoEffectiveness()
{
echo "Defaults timestamp_timeout=120" | sudo tee -a /etc/sudoers.d/custom_sudo_timeout;
};
function RemoveIncreaseSudoEffectiveness()
{
sudo rm /etc/sudoers.d/custom_sudo_timeout;
};
# Check if a command exist in the system
#
# $1 : command name
function IsCommandExists()
{
command -v "$1" >/dev/null 2>&1;
};
# Add config into .zshrc (config file for zsh shell)
#
# $1 : command lines
# $2 : number of indentation (space) removed from result
# $3 : .zshrc section in which to write the command lines
function SetZshConfigFile()
{
local zshrc_file=".zshrc";
local zshrc_temp_file=".zshrc.tmp";
local zshrc_path="$PWD/$zshrc_file";
local zshrc_temp_path="$PWD/$zshrc_temp_file";
local content="$1";
local indentation="${2:-0}";
local section="$3";
if [[ -z "$section" ]] || ! grep -q "###################### $section ######################" "$zshrc_path";
then
return 1;
fi
local formatted_content="$(echo "$content" | sed -E "s/^[[:space:]]{$indentation}//")";
awk -v section="###################### $section ######################" -v content="$formatted_content" '
{
print;
if ($0 ~ section) {
getline; print content;
}
}
' "$zshrc_path" > "$zshrc_temp_path" && mv "$zshrc_temp_path" "$zshrc_path";
};
function SetZshConfigFile_Source () { SetZshConfigFile "$1" "$2" "SOURCE" ; } ;
function SetZshConfigFile_Export () { SetZshConfigFile "$1" "$2" "EXPORT" ; } ;
function SetZshConfigFile_Alias () { SetZshConfigFile "$1" "$2" "ALIAS" ; } ;
function SetZshConfigFile_EnvironmentVariables() { SetZshConfigFile "$1" "$2" "ENVIRONMENT_VARIABLES" ; } ;
function CleanAptPackagesCache()
{
local apt_packages_repository_metadata_file="pkgcache.bin";
local apt_packages_source_metadata_file="srcpkgcache.bin";
sudo rm -f "$SYSTEM_APT_CACHE_FOLDER/$apt_packages_repository_metadata_file";
sudo rm -f "$SYSTEM_APT_CACHE_FOLDER/$apt_packages_source_metadata_file";
sudo apt update;
};
###################### SCRIPT ######################
function InstallGnomeUIUtilities()
{
function InstallTweaks()
{
echo "Installing GNOME Tweaks...";
sudo apt install -y gnome-tweaks;
};
InstallTweaks;
};
function InstallApps()
{
function InstallSteam()
{
function InstallSoftware()
{
sudo add-apt-repository -y multiverse;
sudo apt update;
sudo apt install -y steam;
};
function LaunchFirstUpdate()
{
function KillSteamOnLoginWindow()
{
while true;
do
if pgrep -f steam-runtime-launcher-service >/dev/null;
then
pkill -f steam;
break;
fi
sleep 2;
done
};
nohup steam steam://open/install &> /dev/null & KillSteamOnLoginWindow;
};
echo "Installing Steam...";
InstallSoftware ;
LaunchFirstUpdate ;
};
function InstallDiscord()
{
function InstallSoftware()
{
local package_file="discord.deb";
local package_path="$DOWNLOAD_FOLDER/$package_file";
# Download .deb package file
sudo wget -O "$package_path" "https://discord.com/api/download?platform=linux&format=deb";
# Install .deb package
sudo dpkg -i "$package_path";
# Install possible missing dependencies
sudo apt install -f -y;
# Remove .deb package file
sudo rm "$package_path";
};
function LaunchFirstUpdate()
{
function KillDiscordOnLoginWindow()
{
local is_login_window_visible=false;
while true;
do
if [ "$is_login_window_visible" = false ];
then
local window_ids=$(xdotool search --onlyvisible --name "");
for window_id in $window_ids;
do
local window_name=$(xdotool getwindowname "$window_id" 2>/dev/null);
if [[ -n "$window_name" && "$window_name" =~ discordapp\.com/app\?_=([0-9]+)\ -\ Discord ]];
then
is_login_window_visible=true;
break;
fi
done
else
pkill -f discord;
break;
fi
sleep 2;
done
};
discord &> /dev/null & disown;
KillDiscordOnLoginWindow;
};
echo "Installing Discord...";
InstallSoftware ;
LaunchFirstUpdate ;
};
function InstallVsCode()
{
function InstallSoftware()
{
function AddVsCodeRepository()
{
local gpg_key_file="packages.microsoft.gpg";
local repository_list_file="vscode.list";
local gpg_key_path="$SYSTEM_APT_GPG_KEYS_FOLDER/$gpg_key_file";
local repository_list_path="$SYSTEM_APT_REPOSITORY_LIST_FOLDER/$repository_list_file";
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee "$gpg_key_path" > /dev/null;
echo "deb [arch=amd64 signed-by=$gpg_key_path] https://packages.microsoft.com/repos/code stable main" | sudo tee "$repository_list_path";
};
AddVsCodeRepository;
CleanAptPackagesCache;
sudo apt install -y code;
};
function InstallExtensions()
{
extensions=(
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
twxs.cmake
ms-vscode.cmake-tools
formulahendry.code-runner
# ms-vscode-devcontainers
ms-azuretools.vscode-docker
GitHub.vscode-pull-request-github
# ms-vscode.gradle
fabiospampinato.vscode-highlight
Ionic.ionic
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
fwcd.kotlin
mathiasfrohlich.kotlin
# yantao.vscode-markdown
pkief.material-icon-theme
ms-python.vscode-pylance
ms-python.python
# ms-vscode.remote-ssh
# ms-vscode.remote-ssh-edit
emeraldwalk.runonsave
gruntfuggly.todo-tree
# PolyMeitex.wgsl
);
for extension in "${extensions[@]}";
do
code --install-extension "$extension";
done
};
function SettingKeyboardShortcuts()
{
function ConfigKeyboardShortcut()
{
local keyboard_shortcut_path="$1";
sudo printf '
[
{
"key": "ctrl+alt+m",
"command": "editor.action.transformToUppercase",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+l",
"command": "editor.action.transformToLowercase",
"when": "editorTextFocus"
}
]' | sed 's/^ \{16\}//' | sudo tee "$keyboard_shortcut_path" > /dev/null;
};
local keyboard_shortcut_file='keybindings.json';
local keyboard_shortcut_path="$VS_CODE_CUSTOM_CONFIG_FOLDER/$keyboard_shortcut_file";
sudo mkdir -p "$VS_CODE_CUSTOM_CONFIG_FOLDER";
ConfigKeyboardShortcut "$keyboard_shortcut_path";
};
function SettingIcons()
{
local settings_file='settings.json';
local settings_temp_file="settings.json.tmp";
local settings_path="$VS_CODE_CUSTOM_CONFIG_FOLDER/$settings_file";
local settings_temp_path="$VS_CODE_CUSTOM_CONFIG_FOLDER/$settings_temp_file";
mkdir -p "$VS_CODE_CUSTOM_CONFIG_FOLDER";
if [[ ! -f "$settings_path" ]];
then
echo "{}" | sudo tee "$settings_path" > /dev/null;
fi
if ! IsCommandExists jq;
then
sudo apt install -y jq;
fi
sudo jq '. + {"workbench.iconTheme": "material-icon-theme"}' "$settings_path" > "$settings_temp_path" && mv -f "$settings_temp_path" "$settings_path";
};
echo "Installing VsCode...";
InstallSoftware ;
InstallExtensions ;
SettingKeyboardShortcuts ;
SettingIcons ;
};
function InstallVirtualMachine()
{
function InstallSoftware()
{
sudo apt install -y qemu qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager;
};
function ConfigVirtualMachineCommands()
{
echo "ConfigVirtualMachineCommands"
SetZshConfigFile_Alias '
alias vm_disk_create="bash $SETUP/virtual_machine/functions.sh vm_disk_create"
alias vm_os_install="bash $SETUP/virtual_machine/functions.sh vm_os_install"
alias vm_run="bash $SETUP/virtual_machine/functions.sh vm_run"
' 16;
};
echo "Installing VirtualMachine...";
InstallSoftware ;
ConfigVirtualMachineCommands ;
};
function InstallRetroArch()
{
function InstallSoftware()
{
sudo apt install -y retroarch;
};
echo "Installing RetroArch...";
InstallSoftware;
};
function InstallSpotify()
{
function AddSpotifyRepository()
{
local gpg_key_file="spotify.gpg";
local repository_list_file="spotify.list";
local gpg_key_path="$SYSTEM_APT_GPG_KEYS_FOLDER/$gpg_key_file";
local repository_list_path="$SYSTEM_APT_REPOSITORY_LIST_FOLDER/$repository_list_file";
curl -sS https://download.spotify.com/debian/pubkey_C85668DF69375001.gpg | gpg --dearmor | sudo tee "$gpg_key_path" > /dev/null;
echo "deb [signed-by=$gpg_key_path] http://repository.spotify.com stable non-free" | sudo tee "$repository_list_path";
};
echo "Installing Spotify...";
AddSpotifyRepository;
sudo apt update && sudo apt install -y spotify-client;
};
InstallSteam ;
InstallDiscord ;
InstallVsCode ;
InstallVirtualMachine ;
InstallRetroArch ;
InstallSpotify ;
};
function InstallCodingEcosystem()
{
function InstallGit()
{
function InstallSoftware()
{
sudo apt install -y git;
};
function ConfigLocalGit()
{
sudo git config --global user.name "$GIT_USERNAME" ;
sudo git config --global user.email "$GIT_EMAIL" ;
};
function CreateSSHKeyForGitHub()
{
function CreateSSHKey()
{
local ssh_key_path="$1";
mkdir -p "$SSH_KEYS_FOLDER";
if [[ ! -f "$ssh_key_path" ]];
then
ssh-keygen -t ed25519 -C "$GIT_EMAIL" -f "$ssh_key_path" -N "";
fi
};
function AddSSHKeyInKnownHost()
{
ssh-keyscan github.com >> $SSH_KEYS_FOLDER/known_hosts;
};
function LinkSSHKeyInGitHub()
{
local ssh_key_path="$1";
# Before all these steps add a GitHub token and add it in the .env (https://github.com/settings/tokens)
local ssh_key_content=$(cat "$ssh_key_path.pub");
local ssh_key_title="$GIT_SSH_KEY_TITLE";
local reponse=$(curl -s -o /dev/null -w "%{http_code}" -u "$GIT_USERNAME:$GIT_TOKEN" \
--request POST \
--url "https://api.github.com/user/keys" \
--header "Content-Type: application/json" \
--data "{\"title\":\"$ssh_key_title\",\"key\":\"$ssh_key_content\"}")
if [[ "$reponse" == "201" ]];
then
echo "✅ SSH key added to GitHub successfully!";
else
echo "❌ Failed to add SSH key. HTTP response: $reponse";
fi
};
local ssh_key_file="$GIT_SSH_KEY_FILE"'_ed25519';
local ssh_key_path="$SSH_KEYS_FOLDER/$ssh_key_file";
CreateSSHKey "$ssh_key_path" ;
AddSSHKeyInKnownHost ;
LinkSSHKeyInGitHub "$ssh_key_path" ;
};
echo "Installing Git...";
InstallSoftware ;
ConfigLocalGit ;
CreateSSHKeyForGitHub ;
};
function InstallNvm()
{
function InstallSoftware()
{
function ManuallySourceNvm()
{
export NVM_DIR="$HOME/.nvm";
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh";
};
# Download and install nvm
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash;
ManuallySourceNvm;
# Install NodeJs and npm version
nvm install --lts;
};
function ConfigNvmPath()
{
SetZshConfigFile_Export '
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
' 16;
};
echo "Installing Nvm toolchain (including nodeJS and npm)..."
InstallSoftware ;
ConfigNvmPath ;
};
function InstallPython()
{
function InstallSoftware()
{
sudo apt install -y python3 python3-pip python3-venv;
};
function InstallDevelopmentTools()
{
sudo pip3 install pipenv;
};
echo "Installing Python...";
InstallSoftware ;
InstallDevelopmentTools ;
};
function InstallKotlin()
{
function InstallJVM()
{
function InstallSoftware()
{
sudo apt install -y openjdk-17-jdk;
};
function ConfigJvmPath()
{
SetZshConfigFile_Export '
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
' 20;
};
InstallSoftware ;
ConfigJvmPath ;
};
function InstallKotlinToolchain()
{
function InstallSoftware()
{
function ManuallySourceSdk()
{
export SDKMAN_DIR="$HOME/.sdkman";
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh";
};
sudo curl -s "https://get.sdkman.io" | bash;
ManuallySourceSdk;
sdk install kotlin 1.8.20;
sdk install gradle 8.12;
};
function ConfigSdkManPath()
{
SetZshConfigFile_Export '
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
' 20;
};
InstallSoftware ;
ConfigSdkManPath ;
};
echo "Installing Kotlin toolchain...";
InstallJVM ;
InstallKotlinToolchain ;
};
function InstallRust()
{
function InstallSoftware()
{
function ManuallySourceNvm()
{
source $HOME/.cargo/env;
};
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y;
ManuallySourceNvm;
rustup update;
};
function ConfigNvmPath()
{
SetZshConfigFile_Export '
export PATH="$HOME/.cargo/bin:$PATH"
' 16;
};
echo "Installing Rust...";
InstallSoftware ;
ConfigNvmPath ;
};
InstallGit ;
InstallNvm ;
InstallPython ;
InstallKotlin ;
InstallRust ;
};
function ConfigSystemSettings()
{
function SettingPowerBehavior()
{
function SettingPowerBehaviors_Dconf()
{
dconf write /org/gnome/settings-daemon/plugins/power/idle-dim false ;
dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'" ;
dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-type "'nothing'" ;
dconf write /org/gnome/desktop/session/idle-delay 0 ;
dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout 0 ;
dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-timeout 0 ;
};
function SettingPowerBehaviors_GSettings()
{
gsettings set org.gnome.settings-daemon.plugins.power idle-dim false ;
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing' ;
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing' ;
gsettings set org.gnome.desktop.session idle-delay 0 ;
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0 ;
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0 ;
};
SettingPowerBehaviors_Dconf ;
SettingPowerBehaviors_GSettings ;
};
function SettingScreenBehavior()
{
function SettingScreenBehaviors_Dconf()
{
dconf write /org/gnome/desktop/screensaver/ubuntu-lock-on-suspend false ;
dconf write /org/gnome/desktop/notifications/show-in-lock-screen false ;
dconf write /org/gnome/desktop/screensaver/lock-enabled false ;
};
function SettingScreenBehaviors_GSettings()
{
gsettings set org.gnome.desktop.screensaver ubuntu-lock-on-suspend false ;
gsettings set org.gnome.desktop.notifications show-in-lock-screen false ;
gsettings set org.gnome.desktop.screensaver lock-enabled false ;
};
SettingScreenBehaviors_Dconf ;
SettingScreenBehaviors_GSettings ;
};
function SettingDesktopDock()
{
function FormatGSettingIconsList()
{
local array=("$@");
printf -v formatted "'%s'," "${array[@]}";
echo "[${formatted%,}]";
};
function CreateDockSeparator()
{
function DownloadSeparatorIcon()
{
local application_icon_path="$1";
if [[ ! -f "$application_icon_path" ]];
then
sudo wget -O "$application_icon_path" https://via.placeholder.com/1x1.png;
fi
};
function ConfigSeparatorIcon()
{
local application_icon_config_path="$1";
local application_icon_path="$2";
sudo printf "
[Desktop Entry]
Name=Spacer
Comment=Invisible spacer for Dash to Dock
Exec=true
Icon="$application_icon_path"
Terminal=false
Type=Application
Categories=Utility;
" | sed 's/^ \{20\}//' | sudo tee "$application_icon_config_path" > /dev/null;
sudo chmod 644 "$application_icon_config_path";
};
local application_icon_file="spacer.png";
local application_icon_config_file="spacer.desktop";
local application_icon_path="$SYSTEM_SHARED_ICONS_FOLDER/$icon_file";
local application_icon_config_path="$SYSTEM_SHARED_APPLICATION_ICON_CONFIG_FOLDER/$icon_config_file";
DownloadSeparatorIcon "$application_icon_path";
ConfigSeparatorIcon "$application_icon_config_path" "$application_icon_path";
};
function SettingDesktopDock_Dconf()
{
dconf write /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size 35 ;
dconf write /org/gnome/shell/extensions/dash-to-dock/manualhide false ;
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-fixed false ;
dconf write /org/gnome/shell/extensions/dash-to-dock/intellihide true ;
dconf write /org/gnome/shell/extensions/dash-to-dock/extend-height false ;
dconf write /org/gnome/shell/extensions/dash-to-dock/click-action "'minimize-or-previews'" ;
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-position "'BOTTOM'" ;
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-alignment "'CENTER'" ;
dconf write /org/gnome/shell/favorite-apps "$1";
};
function SettingDesktopDock_GSettings()
{
gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 35 ;
gsettings set org.gnome.shell.extensions.dash-to-dock manualhide false ;
gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed false ;
gsettings set org.gnome.shell.extensions.dash-to-dock intellihide true ;
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false ;
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize-or-previews' ;
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'BOTTOM' ;
gsettings set org.gnome.shell.extensions.dash-to-dock dock-alignment 'CENTER' ;
gsettings set org.gnome.shell favorite-apps "$1";
};
local dock_icons=(
'pop-cosmic-applications.desktop'
'firefox.desktop'
'spacer.desktop'
'org.gnome.Terminal.desktop'
'code.desktop'
'spacer.desktop'
'steam.desktop'
'retroarch_retroarch.desktop'
'spacer.desktop'
'discord.desktop'
'spacer.desktop'
'spotify_spotify.desktop'
'spacer.desktop'
'gnome-control-center.desktop'
);
local formatted_icons=$(FormatGSettingIconsList "${dock_icons[@]}");
CreateDockSeparator;
SettingDesktopDock_Dconf "$formatted_icons" ;
SettingDesktopDock_GSettings "$formatted_icons" ;
};
function SettingDesktop()
{
function SettingDesktop_Dconf()
{
dconf write /org/gnome/shell/extensions/pop-cosmic/show-workspaces-button false ;
dconf write /org/gnome/shell/extensions/pop-cosmic/show-applications-button false ;
dconf write /org/gnome/shell/extensions/pop-cosmic/clock-alignment "'CENTER'" ;
dconf write /org/gnome/desktop/wm/preferences/button-layout "'appmenu:minimize,maximize,close'";
};
function SettingDesktop_GSettings()
{
gsettings set org.gnome.shell.extensions.pop-cosmic show-workspaces-button false ;
gsettings set org.gnome.shell.extensions.pop-cosmic show-applications-button false ;
gsettings set org.gnome.shell.extensions.pop-cosmic clock-alignment 'CENTER' ;
gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu:minimize,maximize,close';
};
SettingDesktop_Dconf ;
SettingDesktop_GSettings ;
};
function SettingDesktopTheme()
{
function SettingDesktopTheme_Dconf()
{
dconf write /org/gnome/desktop/background/picture-uri-dark "'file:///usr/share/backgrounds/pop/nick-nazzaro-ice-cave.png'" ;
dconf write /org/gnome/desktop/screensaver/picture-uri "'file:///usr/share/backgrounds/pop/nick-nazzaro-ice-cave.png'" ;
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'" ;
dconf write /org/gnome/desktop/interface/gtk-theme "'Pop-dark'" ;
dconf write /org/gnome/gedit/preferences/editor/scheme "'pop-dark'" ;
};
function SettingDesktopTheme_GSettings()
{
gsettings set org.gnome.desktop.background picture-uri-dark 'file:///usr/share/backgrounds/pop/nick-nazzaro-ice-cave.png' ;
gsettings set org.gnome.desktop.screensaver picture-uri 'file:///usr/share/backgrounds/pop/nick-nazzaro-ice-cave.png' ;
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' ;
gsettings set org.gnome.desktop.interface gtk-theme 'Pop-dark' ;
gsettings set org.gnome.gedit.preferences.editor scheme 'pop-dark' ;
};
SettingDesktopTheme_Dconf ;
SettingDesktopTheme_GSettings ;
};
function InstallGPUDRivers()
{
function InstallNvidiaDrivers()
{
function InstallSoftware()
{
function FindMatchingGPUDriver()
{
local matching_driver=$(ubuntu-drivers devices | awk '/recommended/ {print $3}');
if [[ -z "$matching_driver" ]];
then
matching_driver=$(ubuntu-drivers devices | grep -oP 'nvidia-driver-\d+' | head -n 1);
fi
echo "$matching_driver";
};
local nvidia_driver=$(FindMatchingGPUDriver);
if [[ -n "$nvidia_driver" ]];
then
sudo apt install -y "$nvidia_driver";
fi
};
function UpdateGPUInSystem
{
sudo prime-select nvidia ;
sudo update-initramfs -u ;
};
sudo add-apt-repository -y ppa:graphics-drivers/ppa;
InstallSoftware ;
UpdateGPUInSystem ;
};
function InstallAMDDrivers()
{
function InstallSoftware()
{
function FindMatchingGPUDriver()
{
echo "$(ubuntu-drivers devices | awk '/recommended/ {print $3}')";
};
local amd_driver=$(FindMatchingGPUDriver);
if [[ -z "$amd_driver" ]];
then
sudo apt install -y mesa-utils mesa-vulkan-drivers xserver-xorg-video-amdgpu;
else
sudo apt install -y "$amd_driver";
fi
};
function UpdateGPUInSystem
{
local current_gpu=$(glxinfo | grep "OpenGL renderer string" | awk -F': ' '{print $2}');
if [[ "$current_gpu" == *"llvmpipe"* ]];
then
sudo modprobe amdgpu;
echo 'export DRI_PRIME=1' | sudo tee -a /etc/environment > /dev/null;
fi
};
sudo apt -y install mesa-utils;
InstallSoftware ;
UpdateGPUInSystem ;
};
local gpu_vendor=$(lspci -v | egrep -i 'vga|3d|2d' | awk '{print $5}' | head -n 1);
if [[ -z "$gpu_vendor" ]];
then
return 1;
fi
if [[ "$gpu_vendor" =~ .*NVIDIA.* ]];
then
InstallNvidiaDrivers;
elif [[ "$gpu_vendor" =~ .*AMD.* ]];
then
InstallAMDDrivers;
else
return 1;
fi
};
echo "Config system settings..."
SettingPowerBehavior ;
SettingScreenBehavior ;
SettingDesktopDock ;
SettingDesktop ;
SettingDesktopTheme ;
InstallGPUDRivers ;
};
function InstallTerminalUtilities()
{
function InstallZsh()
{
echo "Installing Zsh...";
sudo apt install -y zsh;
};
function InstallFzf()
{
echo "Installing Fzf...";
sudo apt install -y fzf;
};
function InstallTheFuck()
{
echo "Installing TheFuck...";
sudo apt install -y thefuck;
};
function InstallTree()
{
echo "Installing Tree...";
sudo apt install -y tree;
};
function InstallBTop()
{
echo "Installing BTop...";
sudo apt install -y btop;
};
function InstallNeofetch()
{
echo "Installing Neofetch...";
sudo apt install -y neofetch;
};
function InstallYazi()
{
function InstallSoftware()
{
cargo install --locked yazi-fm yazi-cli;
};
function MoveToBinLocation()
{
sudo mv $HOME/.cargo/bin/yazi "$USER_BINARIES_FOLDER";
};
function ConfigYazi()
{
SetZshConfigFile_Alias '
alias nav=yazi
' 16;
};
echo "Installing Yazi...";
InstallSoftware ;
MoveToBinLocation ;
};