-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppBuilder
executable file
·4178 lines (3687 loc) · 151 KB
/
AppBuilder
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
# Build your desktop and server apps faster for Linux
#
# WARNING:
# The installation works properly on a fresh install server,
# if you already had installed something (Nginx, MySql or something else)
# the install script may not work, or causes unwanted things.
_VERSION='1.0.0'
# Lists of application groups, what you want to manage as an application group
_APP_DESKTOP=()
_APP_MEDIA=()
_APP_NET=()
_APP_DEV=()
_APP_GAME=()
_APP_UTILS=()
_APP_FONT=()
_APP_NON_FAVORITE=()
_APP_FAVORITE=()
# Building methods (package format) for interactive selection list
#
# Usage example:
# _APP_INSTALL[packagename]="--pack" # default package format, install apt-get
# _APP_INSTALL[packagename]="--pack --flat com.app.APP --snap" # install from several package format as well, default + flat + snap
#
# On the interactive selection list:
# If you install the application in several ways (source), than you will see this on application list:
# '✔ (pack+snap) gnome-calculator'
# otherwise this (if installed with one method): '✔ (snap) gnome-calculator' or '✔ (pack) gnome-calculator'
# '✔ (pack+snap+flat) gimp'
#
# Return:
# Groups of Array, what we will send to cmd_install function.
#
declare -A _APP_INSTALL
# Desktop
_APP_DESKTOP+=( nautilus ) ; _APP_INSTALL[nautilus]="--pack"
_APP_DESKTOP+=( gedit ) ; _APP_INSTALL[gedit]="--pack"
_APP_DESKTOP+=( libreoffice ) ; _APP_INSTALL[libreoffice]="--pack"
_APP_DESKTOP+=( libreoffice-style-sifr ) ; _APP_INSTALL[libreoffice-style-sifr]="--pack" # for icons
_APP_DESKTOP+=( simple-scan ) ; _APP_INSTALL[simple-scan]="--pack"
_APP_DESKTOP+=( evince ) ; _APP_INSTALL[evince]="--pack" # GNOME document viewer
_APP_DESKTOP+=( cheese ) ; _APP_INSTALL[cheese]="--pack" # GNOME webcam
_APP_DESKTOP+=( gnome-software ) ; _APP_INSTALL[gnome-software]="--pack"
_APP_DESKTOP+=( gnome-software-plugin-snap ) ; _APP_INSTALL[gnome-software-plugin-snap]="--pack"
_APP_DESKTOP+=( flatpak ) ; _APP_INSTALL[flatpak]="--pack"
_APP_DESKTOP+=( gnome-software-plugin-flatpak ) ; _APP_INSTALL[gnome-software-plugin-flatpak]="--pack" # + flatpak if it is not exists
_APP_DESKTOP+=( gnome-shell-extensions ) ; _APP_INSTALL[gnome-shell-extensions]="--pack"
_APP_DESKTOP+=( chrome-gnome-shell ) ; _APP_INSTALL[chrome-gnome-shell]="--pack"
_APP_DESKTOP+=( gnome-weather ) ; _APP_INSTALL[gnome-weather]="--pack"
_APP_DESKTOP+=( gnome-shell-extension-weather ) ; _APP_INSTALL[gnome-shell-extension-weather]="--pack"
_APP_DESKTOP+=( gnome-calculator ) ; _APP_INSTALL[gnome-calculator]="--pack" # default: snap; add to an app list (with a different install method) and install if you want
_APP_DESKTOP+=( gnome-calendar ) ; _APP_INSTALL[gnome-calendar]="--pack"
_APP_DESKTOP+=( gnome-clocks ) ; _APP_INSTALL[gnome-clocks]="--pack"
_APP_DESKTOP+=( gnome-maps ) ; _APP_INSTALL[gnome-maps]="--pack"
_APP_DESKTOP+=( gnome-screenshot ) ; _APP_INSTALL[gnome-screenshot]="--pack"
_APP_DESKTOP+=( gnome-sushi ) ; _APP_INSTALL[gnome-sushi]="--pack" # To activate the preview (images, videos or text files), left-click the file and hit space
_APP_DESKTOP+=( gnome-session ) ; _APP_INSTALL[gnome-session]="--pack"
_APP_DESKTOP+=( gnome-terminal ) ; _APP_INSTALL[gnome-terminal]="--pack"
_APP_DESKTOP+=( default-jre ) ; _APP_INSTALL[default-jre]="--pack"
_APP_DESKTOP+=( default-jdk ) ; _APP_INSTALL[default-jdk]="--pack"
_APP_DESKTOP+=( openjdk-8-jdk ) ; _APP_INSTALL[openjdk-8-jdk]="--pack"
_APP_DESKTOP+=( ubuntu-web-launchers ) ; _APP_INSTALL[ubuntu-web-launchers]="--pack"
# Media: Photo & Audio & Video
_APP_MEDIA+=( eog ) ; _APP_INSTALL[eog]="--pack" # Eye of GNOME graphics viewer
_APP_MEDIA+=( gnome-photos ) ; _APP_INSTALL[gnome-photos]="--pack"
_APP_MEDIA+=( gimp ) ; _APP_INSTALL[gimp]="--flat org.gimp.GIMP"
_APP_MEDIA+=( digikam ) ; _APP_INSTALL[digikam]="--appimg https://download.kde.org/stable/digikam/6.1.0/digikam-6.1.0-x86-64.appimage --set digikam"
_APP_MEDIA+=( shotwell ) ; _APP_INSTALL[shotwell]="--pack"
_APP_MEDIA+=( exiftool ) ; _APP_INSTALL[exiftool]="--pack" # libimage-exiftool-perl
_APP_MEDIA+=( inkscape ) ; _APP_INSTALL[inkscape]="--pack"
_APP_MEDIA+=( librecad ) ; _APP_INSTALL[librecad]="--pack"
_APP_MEDIA+=( rhythmbox ) ; _APP_INSTALL[rhythmbox]="--pack"
_APP_MEDIA+=( picard ) ; _APP_INSTALL[picard]="--flat org.musicbrainz.Picard"
_APP_MEDIA+=( audacity ) ; _APP_INSTALL[audacity]="--flat org.audacityteam.Audacity"
_APP_MEDIA+=( spotify ) ; _APP_INSTALL[spotify]="--flat com.spotify.Client"
_APP_MEDIA+=( totem ) ; _APP_INSTALL[totem]="--pack" # GNOME Movie Player
_APP_MEDIA+=( ffmpeg ) ; _APP_INSTALL[ffmpeg]="--pack"
_APP_MEDIA+=( vlc ) ; _APP_INSTALL[vlc]="--flat org.videolan.VLC"
_APP_MEDIA+=( ubuntu-restricted-extras ) ; _APP_INSTALL[ubuntu-restricted-extras]="--pack"
_APP_MEDIA+=( libdvdnav4 ) ; _APP_INSTALL[libdvdnav4]="--pack"
_APP_MEDIA+=( libdvdread4 ) ; _APP_INSTALL[libdvdread4]="--pack"
_APP_MEDIA+=( gstreamer1.0-plugins-bad ) ; _APP_INSTALL[gstreamer1.0-plugins-bad]="--pack"
_APP_MEDIA+=( gstreamer1.0-plugins-ugly ) ; _APP_INSTALL[gstreamer1.0-plugins-ugly]="--pack"
_APP_MEDIA+=( libdvd-pkg ) ; _APP_INSTALL[libdvd-pkg]="--pack --set libdvd" # fix: sudo dpkg-reconfigure libdvd-pkg
_APP_MEDIA+=( flowblade ) ; _APP_INSTALL[lflowblade]="--deb https://github.com/jliljebl/flowblade/releases/download/v2.0/flowblade-2.0.0-1_all.deb"
# Web & Communication & News
_APP_NET+=( google-chrome ) ; _APP_INSTALL[google-chrome]="--deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
_APP_NET+=( chromium-browser ) ; _APP_INSTALL[chromium-browser]="--pack"
_APP_NET+=( brave ) ; _APP_INSTALL[brave]="--snap"
_APP_NET+=( epiphany-browser ) ; _APP_INSTALL[epiphany-browser]="--pack"
_APP_NET+=( firefox ) ; _APP_INSTALL[firefox]="--pack"
_APP_NET+=( dropbox ) ; _APP_INSTALL[dropbox]="--deb https://linux.dropboxstatic.com/packages/ubuntu/dropbox_2.10.0_amd64.deb"
_APP_NET+=( nautilus-dropbox ) ; _APP_INSTALL[nautilus-dropbox]="--pack"
_APP_NET+=( thunderbird ) ; _APP_INSTALL[thunderbird]="--pack"
_APP_NET+=( geary ) ; _APP_INSTALL[geary]="--pack"
_APP_NET+=( skype ) ; _APP_INSTALL[skype]="--flat com.skype.Client"
_APP_NET+=( remmina ) ; _APP_INSTALL[remmina]="--pack"
_APP_NET+=( filezilla ) ; _APP_INSTALL[filezilla]="--pack"
# Development
_APP_DEV+=( atom ) ; _APP_INSTALL[atom]="--set atom --snap=--classic"
_APP_DEV+=( sublimetext ) ; _APP_INSTALL[sublimetext]="--flat com.sublimetext.three"
_APP_DEV+=( git ) ; _APP_INSTALL[git]="--pack"
_APP_DEV+=( python3-pip ) ; _APP_INSTALL[python3-pip]="--pack"
# _APP_DEV+=( virtualbox ) ; _APP_INSTALL[virtualbox]="--deb https://download.virtualbox.org/virtualbox/6.0.4/virtualbox-6.0_6.0.4-128413~Ubuntu~bionic_amd64.deb"
# _APP_DEV+=( vagrant ) ; _APP_INSTALL[vagrant]="--deb https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.deb"
_APP_DEV+=( virtualbox ) ; _APP_INSTALL[virtualbox]="--fun _install_virtualbox"
_APP_DEV+=( vagrant ) ; _APP_INSTALL[vagrant]="--fun _install_vagrant"
_APP_DEV+=( node ) ; _APP_INSTALL[node]="--fun cmd_nodejs"
_APP_DEV+=( mysql-server ) ; _APP_INSTALL[mysql-server]="--fun cmd_mysql"
_APP_DEV+=( php ) ; _APP_INSTALL[php]="--fun cmd_php --force"
_APP_DEV+=( poedit ) ; _APP_INSTALL[poedit]="--pack"
_APP_DEV+=( gnome-builder ) ; _APP_INSTALL[gnome-builder]="--pack" # + sysprof
_APP_DEV+=( sass ) ; _APP_INSTALL[sass]="--fun _install_sass"
# Games
_APP_GAME+=( aisleriot ) ; _APP_INSTALL[aisleriot]="--pack"
_APP_GAME+=( gnome-mahjongg ) ; _APP_INSTALL[gnome-mahjongg]="--pack"
_APP_GAME+=( gnome-sudoku ) ; _APP_INSTALL[gnome-sudoku]="--pack"
_APP_GAME+=( gnome-mines ) ; _APP_INSTALL[gnome-mines]="--pack"
# Utilities
_APP_UTILS+=( teamviewer ) ; _APP_INSTALL[teamviewer]="--deb https://download.teamviewer.com/download/linux/teamviewer_amd64.deb"
_APP_UTILS+=( dconf-editor ) ; _APP_INSTALL[dconf-editor]="--pack"
_APP_UTILS+=( gnome-tweak-tool ) ; _APP_INSTALL[gnome-tweak-tool]="--pack"
_APP_UTILS+=( gparted ) ; _APP_INSTALL[gparted]="--pack"
_APP_UTILS+=( anki ) ; _APP_INSTALL[anki]="--flat net.ankiweb.Anki"
_APP_UTILS+=( enpass ) ; _APP_INSTALL[enpass]="--repo 'deb http://repo.sinew.in/ stable main' --key https://apt.enpass.io/keys/enpass-linux.key"
_APP_UTILS+=( gnome-notes ) ; _APP_INSTALL[gnome-notes]="--pack"
_APP_UTILS+=( bijiben ) ; _APP_INSTALL[bijiben]="--pack"
_APP_UTILS+=( gnome-todo ) ; _APP_INSTALL[gnome-todo]="--pack"
_APP_UTILS+=( gnome-documents ) ; _APP_INSTALL[gnome-documents]="--pack"
_APP_UTILS+=( gnome-disk-utility ) ; _APP_INSTALL[gnome-disk-utility]="--pack"
_APP_UTILS+=( gnome-usage ) ; _APP_INSTALL[gnome-usage]="--pack" # = yelp
_APP_UTILS+=( yelp ) ; _APP_INSTALL[yelp]="--pack"
_APP_UTILS+=( gnome-characters ) ; _APP_INSTALL[gnome-characters]="--pack" # default snap
_APP_UTILS+=( gnome-logs ) ; _APP_INSTALL[gnome-logs]="--pack" # default snap
_APP_UTILS+=( gnome-system-monitor ) ; _APP_INSTALL[gnome-system-monitor]="--pack" # default snap
_APP_UTILS+=( transmission ) ; _APP_INSTALL[transmission]="--pack"
_APP_UTILS+=( seahorse ) ; _APP_INSTALL[seahorse]="--pack"
_APP_UTILS+=( usb-creator-gtk ) ; _APP_INSTALL[usb-creator-gtk]="--pack"
_APP_UTILS+=( tlp ) ; _APP_INSTALL[tlp]="--pack --set tlp"
_APP_UTILS+=( gnome-power-manager ) ; _APP_INSTALL[gnome-power-manager]="--pack"
# Fonts App List
_APP_FONT+=( fonts-font-awesome ) ; _APP_INSTALL[fonts-font-awesome]="--pack"
_APP_FONT+=( fonts-lato ) ; _APP_INSTALL[fonts-lato]="--pack"
_APP_FONT+=( fonts-roboto ) ; _APP_INSTALL[fonts-roboto]="--pack"
_APP_FONT+=( ttf-mscorefonts-installer ) ; _APP_INSTALL[ttf-mscorefonts-installer]="--pack"
# Font packages list: apt-cache search -n '^fonts-*' | awk '{print $1}'
# Quick-start List: Non-favorite Apps
#
# If you want to mark (☠) a package then add it to your non-favorite list
#
# The non-favorite apps will not be automatically removed.
# If these apps exist on the applications lists, then they will be only UNCHECKING or
# CHECKING on the - installing or removing - lists, depending on the following.
#
# Default:
# |-----------------------------------------------|-----------------|----------------|
# | App / Package | Installing List | Removing List |
# |------------------------------------------|----|-----------------|----------------|
# | if not present on your system | ✖ | | |
# | and present on 'non-favorite list' | | unchecked | unchecked |
# | and not present on 'non-favorite list' | | unchecked | unchecked |
# | and present on 'favorite list' | | CHECKED | unchecked |
# | and not present on 'favorite list' | | unchecked | unchecked |
# |------------------------------------------|----|-----------------|----------------|
# | if present on you system | ✔ | | |
# | and present on 'non-favorite list' | | unchecked | CHECKED |
# | and not present on 'non-favorite list' | | unchecked | unchecked |
# | and present on 'favorite list' | | unchecked | unchecked |
# | and not present on 'favorite list' | | unchecked | unchecked |
# |------------------------------------------|----|-----------------|----------------|
#
_APP_NON_FAVORITE=(
ubuntu-web-launchers
transmission
gnome-characters
gnome-logs
gnome-system-monitor
gnome-builder
gnome-documents
bijiben
transmission-gtk
gnome-power-manager
gnome-weather
gnome-maps
usb-creator-gtk
gnome-clocks
gnome-todo
shotwell
seahorse
)
# Quick-start List: Favorite Apps
#
_APP_PREFER+=(
google-chrome
firefox
thunderbird
eog
skype
teamviewer
ubuntu-restricted-extras
tlp
)
_APP_PREFER+=( ${_APP_DESKTOP[@]} ${_APP_FONT[@]} ) # Add some full app list
for i in "${_APP_PREFER[@]}"; do # Remove non-favorite apps
_SKIP=""
for j in "${_APP_NON_FAVORITE[@]}"; do
[[ $i == $j ]] && { _SKIP=1; break; }
done
[[ -n $_SKIP ]] || _APP_FAVORITE+=("$i")
done
# Print short description of package (default value is disable, as it slow down the script)
_SHOW_DESC=${_SHOW_DESC:-0}
# Collect message(s) to an array and print in the end
_SCRIPT_MESSAGES=()
# Whiptail: Changing colours
#
# Return:
# Dialog box with custom colours
#
export NEWT_COLORS="checkbox=black,lightgray"
# Whiptail: Set right dimensions for your whiptail dialog box (without xterm resizing!)
#
# Usage:
# You can calculate the best box size by this: `$LINES $COLUMNS $(( $LINES - 8 ))`
#
# Variables:
# $LINES: height dimension (LINES) of current terminal window
# $COLUMS: width dimension (COLUMNS) of current terminal window
#
# Returns:
# Dimension of the current terminal window
#
_dimension() {
LINES=""; LINES=$(tput lines); COLUMNS=""; COLUMNS=$(tput cols)
}
# Check if one element value exists in a list or array
#
# Usage:
# _contains "$_element" "${_list[*]}"
#
# Args:
# $1 (required): element
# $2 (required): array/list
#
# Returns:
# 0 If the item is included in the list.
# 1 If not.
#
_contains() {
local _list=(${*:2})
for _element in "${_list[@]:-}"; do [[ "${_element}" == "${1}" ]] && return 0; done
return 1
}
# Version controll
#
# Usage:
# if _check_version "$version_1" "$version_2"; then
# echo "$version_1 is greater than $version_2!"
# fi
#
_check_version() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
}
# Spinner
#
# Usage:
# (function or command) &
# _spinner $! "Comment here..."
#
_spinner(){
local pid=$1
local delay=0.5
local spinstr='|/-\'
[[ -n $2 ]] && printf "%b\n" "$2"
printf "Please wait... "
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
printf "DONE!\n"
}
# Cheking System
#
# Returns:
# Error If the system is not Linux, or can't check which distro you are using.
# Error If the distro is not be full compatible with this script.
# Error If you want to run this script on virtual environment.
# ...otherwise the script is running.
#
_check_os_and_distro() {
# Check OS
[[ $(uname) != "Linux" ]] && printf "Sorry! This script only suports Linux!\nExiting...\n" && exit 1
# Check distribution
if [[ $(which lsb_release &>/dev/null; echo $?) -ne 0 ]]; then
printf "Sorry! Can't be checked which distribution you are using!\nExiting...\n"
exit 1
else
if ! lsb_release -ds | grep -qE '(Ubuntu|Mint|elementary|Debian)'; then
if ! (whiptail --title "Warning" --yesno "You are using a distribution that may not be full compatible with this script. Are you sure you want to continue?" 10 50); then
exit 1
fi
fi
fi
}
# Check system environment
#
# Usage:
# if ! _check_desktop; then
# echo "This function helps building apps on desktop environment. It's not recommended to run on virtual environment."
# fi
#
# Return:
# 0 Desktop, if you run this script on desktop environment.
# 1 Server, if you run this script on virtual environment.
#
_check_desktop() {
# Check chassis
if [[ ${_VAR[Environment]} == "vm" ]]; then
_CHAS_MESSAGE="This command \`${_CMD}\` helps building apps on desktop environment.\nIt's not recommended to run on server environment."
return 1
else
_CHAS_MESSAGE="This command \`${_CMD}\` helps building apps on server environment.\nIt's not recommended to run on desktop environment."
return 0
fi
}
# Check timezone
#
# Return:
# 0 If set and not equal UTC
# setting If not set or equal UTC
#
_check_timezone() {
if [[ "${_VAR[Timezone]}" == "Etc/UTC" ]] || [[ "${_VAR[Timezone]}" == "" ]]; then
printf "Current timezone on system: %s\n" "${_VAR[Timezone]}"
read -p "Do you want to set a new timezone? [y/n] " REPLY
if [[ "${REPLY:-}" =~ ^[Yy]$ ]]; then
local _SET_TIMEZONE=$(whiptail --inputbox "\nEnter the new time zone (format: Continent/City):" 8 75 --title "Timezone Setting" 3>&1 1>&2 2>&3)
if [[ $(timedatectl list-timezones | grep "${_SET_TIMEZONE}" &> /dev/null; echo $?) != "0" ]]; then
_error "invalid timezone --'${_SET_TIMEZONE}'"
else
sudo timedatectl set-timezone "${_SET_TIMEZONE}" && whiptail --title "Success" --msgbox "The timezone changed to ${_SET_TIMEZONE}." 7 80
_VAR[Timezone]="${_SET_TIMEZONE}"
fi
fi
else
return 0
fi
}
# Check git config
#
_check_git_config() {
if hash git 2>/dev/null; then
if [[ -z "$(git config user.name)" ]] || [[ -z "$(git config user.email)" ]]; then
printf "Git is installed, but missing your Git identity.\nThis is important because every Git commit uses this information.\n"
read -p "Do you want to set your user name and email address? [y/n] " REPLY
if [[ "${REPLY:-}" =~ ^[Yy]$ ]]; then
local _USER_GIT=$(whiptail --inputbox "\nEnter the name for Git user:" 8 75 --title "Git Setting" 3>&1 1>&2 2>&3)
local _EMAIL_GIT=$(whiptail --inputbox "\nEnter the e-mai adress for Git user:" 8 75 --title "Git Setting" 3>&1 1>&2 2>&3)
git config --global user.name "${_USER_GIT}"
git config --global user.email "${_EMAIL_GIT}"
fi
fi
fi
}
# Determine if a package exists
#
# Usage:
# if [[ $(_check_package_exists "packagename") == 0 ]]; then
# echo "packagename is installed."
# fi
#
# _check_package_exists --print-status "packagename"
#
# Option:
# --print-status Print package status information, if the package exists ... for example:
# ✔ (pack+snap) If the package is installed from two sources as well.
# ✔ (snap) If the package is installed.
# ✔ (~/.local/bin) If the package is present on your system, for example as an AppImage [~/.local/bin].
# ✖ () If not.
#
# Arg:
# $1 (required): Name of package
#
# Returns:
# 0 If the package is installed.
# 1 If not.
#
_check_package_exists() {
if [ $# -gt 2 ]; then
echo "Error: Too many arguments in ${FUNCNAME[0]}() function!"
exit 1
elif [ $# -eq 2 ]; then
if [ "${1}" != "--print-status" ]; then
echo "Error: Unrecognized option in ${FUNCNAME[0]}() function: \`${1}\`!"
exit 1
fi
local _PACKAGE=${2}
else
local _PACKAGE=${1}
fi
local _COUNT=0; local _SOURCE=(); local _INSTALL_STATUS="✔" # https://coolsymbol.com/
# Software Source: main, universe, restricted, multiverse, etc....
#
# Attention: `which`, `hash` or `type` are not always 100% reliable checking methods (See, for example: software-properties-common or snapd):
# `hash "${_PACKAGE}"` or `type -P "${_PACKAGE}"` or `which "${_PACKAGE}"`
#
# Use instead of them something else. Maybe this command good for us: `dpkg-query`, or use them all.
#
if [[ $(dpkg-query -W --showformat='${Status}\n' ${_PACKAGE} 2>/dev/null | grep "install ok installed" &> /dev/null; echo $?) == 0 ]]; then
let _COUNT+=1
_SOURCE+=( pack )
fi
if [[ $(type -P "${_PACKAGE}" &> /dev/null; echo $?) == 0 ]]; then
let _COUNT+=1
if [ "$(type -P "${_PACKAGE}")" == "/usr/bin/${_PACKAGE}" ]; then
if ! _contains "pack" "${_SOURCE[*]}"; then
_SOURCE+=( pack )
fi
fi
if [[ "$(type -P "${_PACKAGE}")" == *"$HOME/.local/bin"* ]]; then
_SOURCE+=( \~/.local/bin )
fi
if [[ "$(type -P "${_PACKAGE}")" == *"$HOME/.nvm"* ]]; then
_SOURCE+=( \~/.nvm )
fi
if [ -f "/usr/local/share/${_PACKAGE}/Makefile" ]; then
_SOURCE+=( complied )
fi
fi
# Software Source: Snap Store
#
# Checking:
# $(snap list 2>/dev/null | grep "" &>/dev/null; echo $?)
#
# Return:
# 0 Yes, snaps is installed.
# 1 No snaps are installed yet.
#
if [[ $(snap list 2>/dev/null | grep "" &>/dev/null; echo $?) == 0 ]]; then
if [[ $(snap list | grep "^${_PACKAGE}" &> /dev/null; echo $?) == 0 ]]; then
let _COUNT+=1
_SOURCE+=( snap )
fi
fi
# Software Source: Flat Store
if hash flatpak 2>/dev/null; then
if [[ $(flatpak list | grep "${_PACKAGE}" &> /dev/null; echo $?) == 0 ]]; then
let _COUNT+=1
_SOURCE+=( flat )
fi
fi
if [ "${1}" == "--print-status" ]; then
if [[ "${_COUNT}" -eq 0 ]]; then
_INSTALL_STATUS="✖"
_SOURCE+=( " -- " )
fi
# Print status and info of sources
(IFS="+$IFS"; printf '%s (%s)' "${_INSTALL_STATUS}" "${_SOURCE[*]}")
else
if [[ "${_COUNT}" -gt 0 ]]; then
echo 0
else
echo 1
fi
fi
}
# Script dependencies
#
_check_dependencies() {
local _MISSING_PACK=();
for _REQ_PACK in whiptail wget; do
if ! hash "${_REQ_PACK}" 2>/dev/null; then
_MISSING_PACK+=("${_REQ_PACK}")
fi
done
if [ -n "${_MISSING_PACK}" ]; then
printf "This script requires some packages,\nbut the following are not present on your system.\n"
printf " * %s\n" "${_MISSING_PACK[@]}"
read -p 'Would you like to install these packages to continue? [Y/n] ' REPLY
case $REPLY in
[Yy]*)
sudo apt install -y "${_MISSING_PACK[*]}" ;;
[Nn]*) printf "Exiting...\n" && exit ;;
* ) printf "Sorry, try again.\n" && _check_dependencies ;;
esac
fi
}
# Exit with an error and print the specified message
#
# Usage:
# _error "Error message. Variable: $0"
#
_error() {
printf "\n$(tput bold)$(tput setaf 1) ✖ Error: %s$(tput sgr0)\n\n" "${*}" 1>&2
exit 1
}
# Get commands and command functions
#
# A function will be a command if its name contains the `cmd _` prefix.
#
# Returns:
# ${_CMD_FUNCTIONS[@]} command function name in array
# ${_CMD_ALLOWED[@]} allowed name of command
#
_get_command_functions() {
local _function_list=($(printf "%s" "$(declare -F)" | sed -e "s/declare -f //g"))
for _name in "${_function_list[@]}"; do
if [[ "${_name}" =~ ^cmd_(.*) ]]; then
_CMD_FUNCTIONS+=("${_name}")
_CMD_ALLOWED+=($(printf "%s" "${_name}" | sed -e "s/cmd_//g"))
fi
done
}
# The primary function for starting the program.
#
_main() {
# Checking things
_check_os_and_distro
_check_dependencies
! _check_desktop && _check_timezone
_check_desktop && _check_git_config
# Load allowed command
_get_command_functions
# Default command
[[ -z "${_CMD:-}" ]] && _CMD=${1:-menu}
if ( [[ -n "${_CMD}" ]] && _contains "${_CMD}" "${_CMD_ALLOWED[*]}"); then
# If the command is defined, run its function...
cmd_"${_CMD}" "${@:2}"
else # If the command is not defined, run this...
# Options parser
_OPTS=$(getopt --options h,u,c,i,e,d,s,v --long help,debug,update,clean,info,error,desktop,setting,version --name "$(basename "${0}")" -- "${@}")
if [ $? != 0 ] ; then _error "invalid option(s) or missing command" ; fi
eval set -- "${_OPTS}"
while true ; do
case "${1}" in
-h|--help) cmd_help ${_CMD} ; shift ;;
--debug) set -x ; _DEBUG=true ; cmd_menu ; shift ;;
-u) _system_update ; shift ;;
--update) _script_update ; shift ;;
-c|--clean) _system_cleanup ; shift ;;
-i|--info) _system_info ; shift ;;
-e|--error) _system_error ; shift ;;
-d|--desktop) _create_desktop ; shift ;;
-s|--setting) _system_settings ; shift ;;
-v|--version)
printf "%s\n" "${_VERSION}"
shift ;;
--) shift ; break ;;
*) _error "internal option error '${1}'"
esac
done
fi
}
# COMMAND: Help
#
# Usage (optional):
# ```
# _HELP[command]=$(cat << HELPSOMETHING
# Usage: ...
# HELPSOMETHING
# )
#
# cmd_command() {
# echo -n
# }
# ```
# Declare command in array without `cmd_` prefix and use in name of function with `cmd_` prefix
#
declare -A _HELP[help]=$(cat << HELPCMD
The menu command displays the help information for '$(basename "${0}")' or
a specified command.
Usage:
$(basename "${0}") -h | --help
$(basename "${0}") help <command>
HELPCMD
)
cmd_help() {
if ( [[ $# -gt 0 ]] && [[ ! "${1}" =~ ^- ]] ); then
# Help to specific command
if _contains "${1}" "${_CMD_ALLOWED[*]}"; then
if _contains "${1}" "${!_HELP[*]}"; then
printf "%b\n\n" "${_HELP[${1}]}"
else
printf "No additional information for '%s'\n" "${1}"
fi
else
printf "Sorry, '%s' is not an allowed command!\n\nAllowed command(s):\n" "${1}"
printf " %s\n" "${_CMD_ALLOWED[@]}"
fi
else
cat << HELPDESKTOP
The $(basename "$0") is a post install script to help building and setting your system.
Usage:
Run '$(basename "${0}")' without options and arguments in interactive mode
$(basename "${0}") [commands] [options] [<arguments>...]
Options:
-u Update system
-c, --clean Cleanup system
-s, --setting Configure system
-i, --info Display system information
-e, --error Display error information (\`dmesg\`)
-d, --desktop Creating a desktop file
-v, --version Print this script version number
--update Update this script (from github)
-h, --help Display this help
--debug Run debug mode
Commands:
$(printf " %s" "${_CMD_ALLOWED[@]}")
For more information about a command, run '$(basename "${0}") help <command>'
HELPDESKTOP
fi
exit
}
# COMMAND: Whiptail Main Menu
#
# Return:
# Whiptail menu dialog box
#
_HELP[menu]=$(cat << HELPMENU
The menu command displays an interactive menu.
Usage: $(basename "${0}") | $(basename "${0}") menu
HELPMENU
)
cmd_menu(){
_dimension
if _check_desktop; then
_MENU_MAIN=$(whiptail --title "Desktop Main Menu" --menu "\n What would you like to do? Choose an option..." --cancel-button "Quit" --notags $LINES $COLUMNS $(( $LINES - 10 )) \
"cmd_menu" "SYSTEM" \
"_system_update" " Update" \
"_system_cleanup" " Cleaning" \
"_system_info" " Print Info" \
"_system_error" " Print Error" \
"cmd_menu" "" \
"cmd_menu" "QUICK START" \
"_menu_sub install _APP_FAVORITE 'Install - Favorite Apps' 'Install'" " Install Favorite Apps ▸" \
"_menu_sub remove _APP_NON_FAVORITE 'Removing - Non Favorite Apps' 'Uninstall'" " Uninstall Non-Favorite Apps ▸" \
"cmd_menu" "" \
"cmd_menu" "INSTALLING APPLICATIONS" \
"_menu_sub install _APP_DESKTOP 'Install - Desktop Application' 'Install'" " Desktop ▸" \
"_menu_sub install _APP_MEDIA 'Install - Media Application' 'Install'" " Media ▸" \
"_menu_sub install _APP_NET 'Install - Web & Communication Application' 'Install'" " Net ▸" \
"_menu_sub install _APP_UTILS 'Install - Utilities' 'Install'" " Utils ▸" \
"_menu_sub install _APP_DEV 'Install - Apps for Development' 'Install'" " Development ▸" \
"_menu_sub install _APP_GAME 'Install - Games' 'Install'" " Games ▸" \
"_menu_sub install _APP_FONT 'Install - Fonts' 'Install'" " Fonts ▸" \
"cmd_menu" "" \
"cmd_menu" "REMOVING APPLICATIONS" \
"_menu_sub remove _APP_DESKTOP 'Remove - Desktop Application' 'Uninstall'" " Desktop ▸" \
"_menu_sub remove _APP_MEDIA 'Remove - Media Application' 'Uninstall'" " Media ▸" \
"_menu_sub remove _APP_NET 'Remove - Web & Communication Application' 'Uninstall'" " Net ▸" \
"_menu_sub remove _APP_UTILS 'Remove - Utilities' 'Uninstall'" " Utils ▸" \
"_menu_sub remove _APP_DEV 'Remove - Apps for Development' 'Uninstall'" " Development ▸" \
"_menu_sub remove _APP_GAME 'Remove - Games' 'Uninstall'" " Games ▸" \
"_menu_sub remove _APP_FONT 'Remove - Fonts' 'Uninstall'" " Fonts ▸" \
"cmd_menu" "" \
"cmd_menu" "SETTINGS" \
"_menu_show_desc" " Show App Info" \
"_java_settings" " Config Java" \
"_system_settings" " Setting System" \
3>&1 1>&2 2>&3)
else
_MENU_MAIN=$(whiptail --title "Server Main Menu" --menu "\n What would you like to do? Choose an option..." --cancel-button "Quit" --notags $LINES $COLUMNS $(( $LINES - 10 )) \
"cmd_menu" "SYSTEM" \
"_system_update" " Update" \
"_system_cleanup" " Cleaning" \
"_system_info" " Print Info" \
"_system_error" " Print Error" \
"cmd_menu" "" \
"cmd_menu" "INSTALLING" \
"cmd_lemp" " LEMP Stack" \
"cmd_nginx" " Nginx" \
"cmd_mysql" " MySQL" \
"cmd_php" " Php" \
"cmd_odoo" " Odoo" \
"cmd_nodejs" " Node" \
"cmd_menu" "" \
"cmd_menu" "SETTINGS" \
"_nginx_block" " Nginx Server Block" \
"_system_settings" " Setting System" \
"_menu_purge_cache" " Purge FastCGI Cache" \
3>&1 1>&2 2>&3)
fi
if [ $? = 0 ]; then
${_MENU_MAIN}
else
echo "Bye!"
exit 0
fi
}
# Helps to build a whiptail checklist for applications
#
# Args:
# $1 (required): install or remove
# $2 (required): name of array
#
# Return:
# Checklist for whiptail submenu into ${_APP_LIST[@]}
#
_menu_checking_list() {
# Clear the previous list and create a new updated one
unset _APP_LIST
# Set list array
_LIST_ARRAY="$2[@]"
# Description for package
_APP_DESC=""
# Get length of list array for steps in process
local _STEP=0; local _LIST_LENGTH=$(echo "${!_LIST_ARRAY}" | wc -w)
# Build the list
local _PACKAGE=""
for _PACKAGE in "${!_LIST_ARRAY}"; do
# Print package's description as well
if [[ "${_SHOW_DESC}" -eq 1 ]]; then
if [[ $(apt-cache show "${_PACKAGE}" &> /dev/null; echo $?) == 0 ]]; then
_APP_DESC=" -$(apt-cache show "${_PACKAGE}" | grep "Description-en" | cut -d: -f 2)" || true
fi
fi
# Set package install status
_install_status="$(_check_package_exists --print-status "${_PACKAGE}")"
#Set checked status
_install_list_check="OFF"
_remove_list_check="OFF"
# Set, if app is present on the 'non-favorite list'
if _contains "${_PACKAGE}" "${_APP_NON_FAVORITE[@]}"; then
_mark_non_favorite=" ☠ "
[[ "${_install_status}" != "✖ ( -- )" ]] && _remove_list_check="ON"
else
_mark_non_favorite=""
fi
if _contains "${_PACKAGE}" "${_APP_FAVORITE[@]}"; then
[[ "${_install_status}" == "✖ ( -- )" ]] && _install_list_check="ON"
fi
# Create whiptail commands
if [[ "${1}" == "install" ]]; then
_APP_LIST+=("cmd_install --app ${_PACKAGE} ${_APP_INSTALL[$_PACKAGE]}" "${_install_status} ${_mark_non_favorite}${_PACKAGE}${_APP_DESC}" ${_install_list_check})
elif [[ "${1}" == "remove" ]]; then
_APP_LIST+=("cmd_remove --app ${_PACKAGE}" "${_install_status} ${_mark_non_favorite}${_PACKAGE}${_APP_DESC}" ${_remove_list_check})
else
echo "Error line $LINENO: Menu command is wrong!"; exit
fi
# Progress while building the list
# if [[ "${_SHOW_DESC}" -eq 1 ]]; then
(( _STEP+=$(( 100 / ${_LIST_LENGTH} +1 )) ))
echo XXX
echo $(( $_STEP ))
echo -e "\nUpdating package information: ${_PACKAGE}"
echo XXX
# fi
# done > >([[ "${_SHOW_DESC}" -eq 1 ]] && whiptail --title "Please wait..." --gauge "\nUpdating package information: " 8 70 0)
done > >(whiptail --title "Please wait..." --gauge "\nUpdating package information: " 8 70 0)
}
# Whiptail: Submenu for actions
#
# Usage:
# _menu_sub install _APP_COMMON 'Installing Commonly Used Application' 'Install'
#
# Args:
# $1 (required): install or remove
# $2 (required): Name of array
# $3 (required): Checklit title
# $4 (required): Checklist OK button text
#
# Return:
# Whiptail checklist, where can you start the command for installing or removing
#
_menu_sub() {
_dimension
# Keep it for the return
_preserved_command="${@}"
eval set -- "${@}"
# Build a list
_menu_checking_list "${@}"
# Checklist
_CHECK_LIST=$(whiptail --title "${3}" --checklist "\n Choose one or more apps to ${1}...\n\n installed : ✔ (sources)\n not installed : ✖ ( -- )\n non-favorite : ☠\n -------------------------------------\n" \
--separate-output --cancel-button "Back to Main Menu" --ok-button "${4}" --notags \
$LINES $COLUMNS $(( $LINES - 14 )) \
"${_APP_LIST[@]}" \
3>&1 1>&2 2>&3)
if [ ${?} = 0 ]; then
i=0
while read line; do
_SELECTED_APPS[${i}]=${line}
i=$(($i+1))
done <<< "${_CHECK_LIST}"
if [[ -z "${_SELECTED_APPS[@]}" ]]; then
whiptail --title "Info" --yes-button "Back" --no-button "Quit" --yesno "Nothing selected, so nothing happened!" 7 45 || exit
else
for _MENU_SUB in "${_SELECTED_APPS[@]}"; do
${_MENU_SUB}
done
if [[ -z "${_SCRIPT_MESSAGES[@]}" ]]; then
whiptail --title "Success" --yes-button "Back to List" --no-button "Quit" --yesno "The selected application(s) has been ${1}ed." 7 53 || exit
else
# Print message
whiptail --scrolltext --title "Script Messages" --yes-button "OK" --no-button "Quit" --yesno "$(printf "%b\n" "${_SCRIPT_MESSAGES[@]}")" 10 75 || exit
fi
fi
_menu_sub "${_preserved_command}"
else
cmd_menu
fi
}
# Whiptail: Package's description settings
#
# Return:
# Whiptail radiolist
#
_menu_show_desc() {
if [[ "$_SHOW_DESC" == 1 ]]; then
_SHOW_DESC_ENABLE="ON"; _SHOW_DESC_DISABLE="OFF"
else
_SHOW_DESC_ENABLE="OFF"; _SHOW_DESC_DISABLE="ON"
fi
_SHOW_DESC_OPTIONS=$( whiptail --notags --title "Show Packages' Description" --radiolist "\nDisplay information of applications in selection menus. Enabling slows down script execution!" 10 65 2 \
"1" "Enable" $_SHOW_DESC_ENABLE \
"0" "Disable (default)" $_SHOW_DESC_DISABLE \
3>&1 1>&2 2>&3)
if [ ${?} = 0 ]; then
_SHOW_DESC=$_SHOW_DESC_OPTIONS
fi
cmd_menu
}
# System updating
#
_system_update() {
# Enable software from Canonical's 'partner' repository
sudo sed -i "/deb http:.* partner/s/^# //" /etc/apt/sources.list
printf "Refresh repository... Please wait... "
sudo apt update -qq
if hash flatpak 2>/dev/null; then
printf "Flatpak... "
sudo flatpak update -y
fi
# Upgrading packages if necessary
if [[ $(LANG=C apt-get upgrade -s | grep -P '^\d+ upgraded'| cut -d" " -f1) != 0 ]]; then
sudo apt upgrade -y
fi
# Install translations if language support is not installed completely
if [[ -n "$(check-language-support)" ]]; then
sudo apt install -y $(check-language-support)
fi
}
# Script updating from GitHub
#
_script_update() {
local _PATH_TO_THIS_SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "$0")"
# Check if file is a symbolic link and if yes get real link
if [[ -L "${_PATH_TO_THIS_SCRIPT}" ]]; then
_PATH_TO_THIS_SCRIPT="$(readlink -f "${_PATH_TO_THIS_SCRIPT}")"
fi
# Download script file
printf "\n *** Run this command in terminal for updating $(basename "$0") ***\n\nwget -qO- https://raw.githubusercontent.com/fereber/AppBuilder/master/AppBuilder -O %s\n\n" "${_PATH_TO_THIS_SCRIPT}"
}
# System cleaning
#
_system_cleanup() {
# Remove leftover config files
if [[ -z "$(COLUMNS= dpkg -l | grep '^rc' | tr -s ' ' | cut -d ' ' -f 2)" ]]; then
printf "There aren't leftover config files.\n"
else
printf "Remove leftover config files:\n"
sudo dpkg --purge $(COLUMNS= dpkg -l | grep '^rc' | tr -s ' ' | cut -d ' ' -f 2)
fi
# Flatpak unused applications
if hash flatpak 2>/dev/null; then
printf "Unused Flatpak package(s)... "
sudo flatpak uninstall -y --unused
fi
# Clean packages cache
sudo apt clean
# Remove orphaned packages
if [[ $(LANG=C apt-get autoremove -s | grep -P '^\d+ upgraded'| cut -d" " -f6) -ne 0 ]]; then
sudo apt autoremove -y -qq
fi
}
# Configure System
#
_system_settings() {
# UFW enable
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh comment 'Connection to ssh' &>/dev/null && printf " ⇢ Ufw rule: allow SSH\n"
if [[ "${_VAR[Firewall]}" != "active" ]]; then
sudo ufw --force enable
fi
sudo ufw reload
if _check_desktop; then
# Hidde things...
[[ $(cat ~/.hidden 2> /dev/null | grep -q "snap"; echo $?) != 0 ]] && echo "snap" >> ~/.hidden
# Gsettings
gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'LEFT'
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height true
gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed true
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'
gsettings set org.gnome.shell.extensions.dash-to-dock custom-theme-running-dots-color '#dddddd'
# gsettings set org.gnome.shell enabled-extensions "['alternate-tab@gnome-shell-extensions.gcampax.github.com', 'ubuntu-appindicators@ubuntu.com', 'ubuntu-dock@ubuntu.com', 'drive-menu@gnome-shell-extensions.gcampax.github.com', 'user-theme@gnome-shell-extensions.gcampax.github.com']"
gsettings set org.gnome.desktop.interface clock-format 24h
gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.screensaver lock-delay '30'
gsettings set org.gnome.desktop.interface show-battery-percentage true
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
gsettings set org.gnome.Terminal.Legacy.Settings theme-variant 'dark'
gsettings set org.gnome.nautilus.preferences default-folder-viewer 'list-view'
gsettings set org.gnome.nautilus.list-view default-visible-columns "['name', 'size', 'date_modified_with_time', 'detailed_type']"
gsettings set org.gtk.Settings.FileChooser sort-directories-first true
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
gsettings set org.gnome.settings-daemon.plugins.color night-light-schedule-automatic true
gsettings set org.gnome.desktop.privacy remember-recent-files true
gsettings set org.gnome.desktop.privacy recent-files-max-age '14'
gsettings set org.gnome.desktop.privacy remove-old-temp-files true
gsettings set org.gnome.desktop.privacy remove-old-trash-files true
gsettings set org.gnome.desktop.privacy old-files-age '14'
gsettings set org.gnome.desktop.privacy send-software-usage-stats false
# Disabling crash dialogs
if [[ $(cat '/etc/default/apport' | grep -q 'enabled=0'; echo $?) != 0 ]]; then
sudo sed -i "s/enabled=1/enabled=0/g" /etc/default/apport
fi
# Displaying hidden startup applications
sudo sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/*.desktop
# Set swappiness, if its current value is greater than 10% [system default is 60%]
# The swap file will then only be used when the RAM usage is around 90 percent.
if [[ "$(cat /proc/sys/vm/swappiness)" -gt 10 ]]; then
if [[ "$(grep "vm.swappiness" /etc/sysctl.conf &>/dev/null; echo $?)" != 0 ]]; then
echo "vm.swappiness = 10" | sudo tee -a /etc/sysctl.conf
else
sudo sed -i "s/vm.swappiness.*/vm.swappiness = 10/g" /etc/sysctl.conf
fi
fi