-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
executable file
·887 lines (758 loc) · 30.5 KB
/
Copy pathinstall
File metadata and controls
executable file
·887 lines (758 loc) · 30.5 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
#!/usr/bin/env bash
set -e
# ---------------------------------------------------------------------------
# Colors & Logging
# ---------------------------------------------------------------------------
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${BLUE}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
success() { echo -e "${GREEN}[SUCCESS]${NC} $*"; }
# ---------------------------------------------------------------------------
# Root Guard
# ---------------------------------------------------------------------------
if [[ $EUID -eq 0 ]]; then
error "Do not run this script as root. Run it as a normal user."
exit 1
fi
# ---------------------------------------------------------------------------
# GPU Flag — Manual Override
# ./install.sh --intel | --amd | --nvidia
# ---------------------------------------------------------------------------
GPU_TYPE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--intel) GPU_TYPE="intel" ;;
--amd) GPU_TYPE="amd" ;;
--nvidia) GPU_TYPE="nvidia" ;;
*) warn "Unknown flag: $1" ;;
esac
shift
done
# ---------------------------------------------------------------------------
# Paths
# ---------------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOME_DIR="$HOME"
CONFIG_DIR="$HOME_DIR/.config"
FONTS_DIR="/usr/share/fonts"
ICONS_DIR="/usr/share/icons"
THEMES_DIR="/usr/share/themes"
WALLPAPER_DIR="/usr/share/t4n-os/wallpaper"
sudo mkdir -p "$FONTS_DIR" "$ICONS_DIR" "$THEMES_DIR" "$WALLPAPER_DIR"
mkdir -p "$CONFIG_DIR"
# ---------------------------------------------------------------------------
# Packages
# ---------------------------------------------------------------------------
PACKAGES_BASE=(
# Xorg
xorg
xf86-input-libinput
# WM
bspwm
sxhkd
# Graphics Base
mesa
mesa-dri
Vulkan-Tools
linux-firmware
# Network
network-manager-applet
# Terminal & Launcher
alacritty
xfce4-terminal
rofi
dmenu
# Panel & Compositor
polybar
picom
# File Manager
Thunar
gvfs
gvfs-mtp
thunar-archive-plugin
thunar-media-tags-plugin
# File Manager Utilities
xarchiver
zip
unzip
p7zip
unrar
# Utilities
feh
dunst
brightnessctl
xss-lock
betterlockscreen
i3lock-color
ranger
xrdb
xdg-user-dirs
polkit-gnome
gparted
lightdm-gtk3-greeter
ripgrep
tree-sitter
tree-sitter-cli
plymouth
# Monitoring
lm_sensors
htop
btop
fastfetch
playerctl
xrandr
lazygit
# Apps
firefox
flameshot
galculator
geany
timeshift
xmirror
yazi
# Other
xdg-desktop-portal
xdg-desktop-portal-gtk
lxappearance
gtk-engine-murrine
fontconfig
zramen
# Theme
arc-theme
tint
tint2
# Papirus
papirus-folders
papirus-icon-theme
# Fonts
font-awesome
font-awesome5
font-awesome6
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-sans-variable
noto-fonts-cjk-serif
noto-fonts-cjk-serif-variable
noto-fonts-cjk-variable
noto-fonts-emoji
noto-fonts-ttf
noto-fonts-ttf-extra
noto-fonts-ttf-variable
font-firacode
font-sarasa-gothic
)
PACKAGES_PIPEWIRE=(
pipewire wireplumber
libspa-bluetooth
alsa-pipewire
libjack-pipewire
pavucontrol pamixer
)
PACKAGES_SERVICES=(
dbus
elogind
NetworkManager
lightdm
rtkit
polkit
power-profiles-daemon
)
PACKAGES_ALL=(
"${PACKAGES_BASE[@]}"
"${PACKAGES_PIPEWIRE[@]}"
"${PACKAGES_SERVICES[@]}"
)
# ---------------------------------------------------------------------------
# Functions
# ---------------------------------------------------------------------------
install_packages() {
info "Updating the system and installing packages..."
sudo xbps-install -Su xbps || { error "Failed to update xbps"; exit 1; }
sudo xbps-install -y void-repo-multilib void-repo-multilib-nonfree void-repo-nonfree 2>/dev/null \
|| warn "Repository mungkin sudah ada."
sudo xbps-install -Su || { error "Failed to update system"; exit 1; }
for pkg in "${PACKAGES_ALL[@]}"; do
if ! xbps-query "$pkg" >/dev/null 2>&1; then
info "Menginstal $pkg..."
sudo xbps-install -y "$pkg" || warn "Failed to install $pkg"
else
info "Package $pkg already installed, skip."
fi
done
success "All packages are complete."
}
# ---------------------------------------------------------------------------
detect_gpu() {
# Kalau sudah di-set via flag manual, skip auto-detect
if [[ -n "$GPU_TYPE" ]]; then
info "GPU manually set to: $GPU_TYPE"
return
fi
info "Auto-detecting GPU..."
local gpu
gpu=$(lspci | grep -E "VGA|3D|Display" | tr '[:upper:]' '[:lower:]')
if echo "$gpu" | grep -q "intel"; then
GPU_TYPE="intel"
elif echo "$gpu" | grep -q "amd\|radeon"; then
GPU_TYPE="amd"
elif echo "$gpu" | grep -q "nvidia"; then
GPU_TYPE="nvidia"
else
GPU_TYPE="unknown"
warn "GPU not detected, skipping driver install."
fi
info "GPU detected: $GPU_TYPE"
}
setup_gpu() {
case "$GPU_TYPE" in
intel)
info "Installing Intel drivers..."
sudo xbps-install -y \
intel-video-accel \
intel-media-driver \
libva-utils
success "Intel driver installed."
;;
amd)
info "Installing AMD drivers..."
sudo xbps-install -y \
xf86-video-amdgpu \
mesa-vaapi \
mesa-vdpau
success "AMD driver installed."
;;
nvidia)
info "Installing Nvidia drivers..."
sudo xbps-install -y void-repo-nonfree
sudo xbps-install -Syu
sudo xbps-install -y \
nvidia \
nvidia-libs \
nvidia-libs-32bit
success "Nvidia driver installed."
;;
unknown)
warn "Skipping GPU driver install."
;;
esac
}
# ---------------------------------------------------------------------------
# ZRam Setup — Smart Auto-Config + Manual Override
# ---------------------------------------------------------------------------
# Format /etc/sv/zramen/conf (standar komunitas Void Linux):
#
# ZRAM_SIZE=<ukuran> → e.g. 4G, 8G, 2G
# ALGO=<algoritma> → zstd | lz4 | lzo | lzo-rle
#
# zramen membaca file ini saat service start via Runit.
# ---------------------------------------------------------------------------
_zram_profile() {
# $1 = total RAM dalam MB
# Output: ZRAM_SIZE ALGO SWAPPINESS label
local ram_mb="$1"
if (( ram_mb >= 16384 )); then
# 16 GB+ → Zram 4G, zstd, swappiness sangat rendah
echo "4G zstd 10 ≥16GB"
elif (( ram_mb >= 8192 )); then
# 8 GB–16 GB → Zram 4G, zstd, swappiness rendah
echo "4G zstd 20 8-16GB"
elif (( ram_mb >= 4096 )); then
# 4 GB–8 GB → Zram 2G, zstd, swappiness sedang
echo "2G zstd 60 4-8GB"
elif (( ram_mb >= 2048 )); then
# 2 GB–4 GB → Zram 2G, lz4, swappiness tinggi
echo "2G lz4 80 2-4GB"
else
# < 2 GB → Zram 1G, lz4, swappiness agresif
echo "1G lz4 100 <2GB"
fi
}
setup_zram() {
info "Memulai konfigurasi ZRam..."
# ── Deteksi RAM ──────────────────────────────────────────────────────────
local total_ram_kb total_ram_mb
total_ram_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
total_ram_mb=$(( total_ram_kb / 1024 ))
# ── Tentukan profil otomatis ─────────────────────────────────────────────
local auto_profile
auto_profile=$(_zram_profile "$total_ram_mb")
local auto_size auto_algo auto_swappiness auto_label
read -r auto_size auto_algo auto_swappiness auto_label <<< "$auto_profile"
# ── Tampilkan info & rekomendasi ─────────────────────────────────────────
echo ""
echo -e "${BOLD}${CYAN}┌─────────────────────────────────────────────────┐${NC}"
echo -e "${BOLD}${CYAN}│ Konfigurasi ZRam — T4n OS │${NC}"
echo -e "${BOLD}${CYAN}└─────────────────────────────────────────────────┘${NC}"
echo -e " RAM Terdeteksi : ${YELLOW}${total_ram_mb} MB${NC}"
echo ""
echo -e " ${GREEN}[Rekomendasi Otomatis untuk RAM ${auto_label}]${NC}"
echo -e " ┌─────────────────────────────────────┐"
echo -e " │ ZRAM_SIZE = ${CYAN}${auto_size}${NC}"
echo -e " │ ALGO = ${CYAN}${auto_algo}${NC}"
echo -e " │ Swappiness = ${CYAN}${auto_swappiness}${NC}"
echo -e " └─────────────────────────────────────┘"
echo ""
echo -e " ${YELLOW}Tabel Referensi Profil:${NC}"
echo -e " ┌──────────────┬───────────┬──────┬────────────┐"
echo -e " │ RAM │ ZRAM_SIZE │ ALGO │ Swappiness │"
echo -e " ├──────────────┼───────────┼──────┼────────────┤"
echo -e " │ ≥ 16 GB │ 4G │ zstd │ 10 │"
echo -e " │ 8 GB – 16 GB │ 4G │ zstd │ 20 │"
echo -e " │ 4 GB – 8 GB │ 2G │ zstd │ 60 │"
echo -e " │ 2 GB – 4 GB │ 2G │ lz4 │ 80 │"
echo -e " │ < 2 GB │ 1G │ lz4 │ 100 │"
echo -e " └──────────────┴───────────┴──────┴────────────┘"
echo ""
echo -e " ${BLUE}Catatan algoritma:${NC}"
echo -e " • ${CYAN}zstd${NC} → Rasio kompresi terbaik, CPU sedikit lebih berat ${GREEN}[Direkomendasikan]${NC}"
echo -e " • ${CYAN}lz4${NC} → Sangat cepat, cocok RAM kecil / CPU lemah"
echo -e " • ${CYAN}lzo${NC} → Lama, tidak disarankan kecuali kernel sangat lama"
echo ""
# ── Tanya user: auto atau manual? ───────────────────────────────────────
local choice
while true; do
echo -e " Pilih mode konfigurasi:"
echo -e " ${GREEN}[1]${NC} Gunakan rekomendasi otomatis (${auto_size} | ${auto_algo} | swappiness=${auto_swappiness})"
echo -e " ${YELLOW}[2]${NC} Atur manual"
echo -n " Pilihan [1/2]: "
read -r choice
case "$choice" in
1|"") break ;;
2) break ;;
*) warn "Masukkan 1 atau 2." ;;
esac
done
local final_size final_algo final_swappiness
if [[ "$choice" == "1" || -z "$choice" ]]; then
# ── Mode Auto ───────────────────────────────────────────────────────
final_size="$auto_size"
final_algo="$auto_algo"
final_swappiness="$auto_swappiness"
info "Menggunakan konfigurasi otomatis."
else
# ── Mode Manual ─────────────────────────────────────────────────────
echo ""
info "Mode manual. Masukkan konfigurasi ZRam:"
# Ukuran
while true; do
echo -n " ZRAM_SIZE (contoh: 1G, 2G, 4G, 8G) [default: ${auto_size}]: "
read -r input_size
input_size="${input_size:-$auto_size}"
if [[ "$input_size" =~ ^[0-9]+[GgMm]$ ]]; then
final_size="${input_size^^}"
break
else
warn "Format tidak valid. Gunakan format seperti: 2G, 4G, 512M"
fi
done
# Algoritma
while true; do
echo ""
echo -e " Pilih algoritma kompresi:"
echo -e " ${GREEN}[1]${NC} zstd — Kompresi terbaik ${GREEN}[Direkomendasikan]${NC}"
echo -e " ${CYAN}[2]${NC} lz4 — Tercepat, cocok CPU/RAM terbatas"
echo -e " ${YELLOW}[3]${NC} lzo — Lama, kompatibilitas kernel lama"
echo -e " ${YELLOW}[4]${NC} lzo-rle — Versi lzo yang lebih cepat sedikit"
echo -n " Pilihan [1-4, default: 1]: "
read -r input_algo_choice
case "${input_algo_choice:-1}" in
1) final_algo="zstd" ; break ;;
2) final_algo="lz4" ; break ;;
3) final_algo="lzo" ; break ;;
4) final_algo="lzo-rle" ; break ;;
*) warn "Masukkan angka 1-4." ;;
esac
done
# Swappiness
while true; do
echo ""
echo -e " Panduan swappiness:"
echo -e " • ${CYAN}0–20${NC} : RAM besar (≥8GB), zram jarang dipakai"
echo -e " • ${CYAN}40–70${NC} : RAM menengah (4GB–8GB), seimbang"
echo -e " • ${CYAN}80–100${NC}: RAM kecil (≤4GB), zram aktif agresif"
echo -n " vm.swappiness (0-200) [default: ${auto_swappiness}]: "
read -r input_swap
input_swap="${input_swap:-$auto_swappiness}"
if [[ "$input_swap" =~ ^[0-9]+$ ]] && (( input_swap >= 0 && input_swap <= 200 )); then
final_swappiness="$input_swap"
break
else
warn "Nilai harus angka antara 0–200."
fi
done
fi
# ── Ringkasan final ──────────────────────────────────────────────────────
echo ""
echo -e " ${GREEN}Konfigurasi yang akan diterapkan:${NC}"
echo -e " ┌─────────────────────────────────────┐"
echo -e " │ ZRAM_SIZE = ${CYAN}${final_size}${NC}"
echo -e " │ ALGO = ${CYAN}${final_algo}${NC}"
echo -e " │ Swappiness = ${CYAN}${final_swappiness}${NC}"
echo -e " └─────────────────────────────────────┘"
echo ""
# ── Load modul kernel ────────────────────────────────────────────────────
if ! lsmod | grep -q "^zram"; then
sudo modprobe zram \
&& info "Modul zram berhasil dimuat." \
|| warn "Gagal memuat modul zram."
else
info "Modul zram sudah aktif."
fi
# ── Auto-load modul saat boot ────────────────────────────────────────────
if ! grep -q "^zram" /etc/modules-load.d/zram.conf 2>/dev/null; then
echo 'zram' | sudo tee /etc/modules-load.d/zram.conf >/dev/null
info "zram dikonfigurasi untuk auto-load saat boot."
fi
# ── Aktifkan service zramen via Runit ────────────────────────────────────
if [[ ! -L /var/service/zramen ]]; then
sudo ln -s /etc/sv/zramen /var/service/
info "Service zramen diaktifkan."
else
info "Service zramen sudah aktif, skip."
fi
# ── Tulis /etc/sv/zramen/conf (standar komunitas Void Linux) ─────────────
sudo tee /etc/sv/zramen/conf >/dev/null <<EOF
# ZRam configuration — dibuat otomatis oleh T4n OS installer
# Format standar komunitas Void Linux untuk zramen
# Referensi: https://github.com/jedavies-dev/zramen
ZRAM_SIZE=${final_size}
ALGO=${final_algo}
EOF
info "Konfigurasi ditulis ke /etc/sv/zramen/conf"
# ── Tuning sysctl ────────────────────────────────────────────────────────
local sysctl_conf="/etc/sysctl.conf"
_sysctl_set() {
local key="$1" val="$2"
if grep -q "^${key}" "$sysctl_conf" 2>/dev/null; then
sudo sed -i "s|^${key}.*|${key}=${val}|" "$sysctl_conf"
else
echo "${key}=${val}" | sudo tee -a "$sysctl_conf" >/dev/null
fi
}
_sysctl_set "vm.swappiness" "$final_swappiness"
_sysctl_set "vm.vfs_cache_pressure" "50"
_sysctl_set "vm.dirty_ratio" "15"
_sysctl_set "vm.dirty_background_ratio" "5"
sudo sysctl -p >/dev/null
info "Sysctl diperbarui."
# ── Restart service agar konfigurasi baru berlaku ────────────────────────
if [[ -L /var/service/zramen ]]; then
sudo sv restart zramen 2>/dev/null || true
fi
success "ZRam aktif! (${final_size} | ${final_algo} | swappiness=${final_swappiness})"
}
# ---------------------------------------------------------------------------
setup_dbus() {
info "Configuring D-Bus..."
if getent group dbus >/dev/null; then
if ! groups "$USER" | grep -q dbus; then
sudo usermod -a -G dbus "$USER"
warn "User added to group 'dbus'. Logout/login required."
fi
fi
if [[ -L /var/service/dbus ]]; then
sv status dbus | grep -q run \
&& info "D-Bus service is running." \
|| sudo sv start dbus
else
if [[ -d /etc/sv/dbus ]]; then
sudo ln -s /etc/sv/dbus /var/service/
info "D-Bus service enabled."
else
error "D-Bus service directory not found. Is dbus installed?"
fi
fi
# dumb-runtime-dir untuk XDG_RUNTIME_DIR
if ! command -v dumb_runtime_dir >/dev/null 2>&1; then
sudo xbps-install -y dumb_runtime_dir
fi
if ! grep -q "pam_dumb_runtime_dir" /etc/pam.d/system-login 2>/dev/null; then
echo "session optional pam_dumb_runtime_dir.so" | sudo tee -a /etc/pam.d/system-login >/dev/null
fi
success "D-Bus configuration complete. (Remember: logout/login!)"
}
# ---------------------------------------------------------------------------
create_user_dirs() {
info "Creating standard user directories..."
if command -v xdg-user-dirs-update >/dev/null 2>&1; then
xdg-user-dirs-update
else
mkdir -p "$HOME"/{Documents,Downloads,Pictures,Videos,Music,Desktop,Templates,Public}
fi
success "User directories ready."
}
# ---------------------------------------------------------------------------
setup_pipewire() {
info "Configuring PipeWire..."
mkdir -p "$CONFIG_DIR/pipewire/pipewire.conf.d"
[[ -f /usr/share/examples/wireplumber/10-wireplumber.conf ]] && \
ln -sf /usr/share/examples/wireplumber/10-wireplumber.conf \
"$CONFIG_DIR/pipewire/pipewire.conf.d/"
[[ -f /usr/share/examples/pipewire/20-pipewire-pulse.conf ]] && \
ln -sf /usr/share/examples/pipewire/20-pipewire-pulse.conf \
"$CONFIG_DIR/pipewire/pipewire.conf.d/"
if [[ -d /usr/share/alsa/alsa.conf.d ]]; then
sudo mkdir -p /etc/alsa/conf.d
sudo ln -sf /usr/share/alsa/alsa.conf.d/50-pipewire.conf /etc/alsa/conf.d/
sudo ln -sf /usr/share/alsa/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
fi
if [[ -d /usr/lib/pipewire-0.3/jack ]]; then
echo "/usr/lib/pipewire-0.3/jack" | sudo tee /etc/ld.so.conf.d/pipewire-jack.conf >/dev/null
sudo ldconfig
fi
mkdir -p "$CONFIG_DIR/autostart"
[[ -f /usr/share/applications/pipewire.desktop ]] && \
ln -sf /usr/share/applications/pipewire.desktop "$CONFIG_DIR/autostart/"
[[ -f /usr/share/applications/pipewire-pulse.desktop ]] && \
ln -sf /usr/share/applications/pipewire-pulse.desktop "$CONFIG_DIR/autostart/"
sudo usermod -a -G audio,video "$USER"
success "PipeWire configured."
}
# ---------------------------------------------------------------------------
dotfiles() {
info "Copying configuration files..."
[[ -d "$SCRIPT_DIR/config" ]] && cp -r "$SCRIPT_DIR/config/"* "$CONFIG_DIR/"
if [[ -d "$SCRIPT_DIR/system/gtk" ]]; then
cp -r "$SCRIPT_DIR/system/gtk/gtk-3.0" "$CONFIG_DIR/"
cp -r "$SCRIPT_DIR/system/gtk/gtk-4.0" "$CONFIG_DIR/"
success "GTK config copied."
else
warn "GTK config not found at $SCRIPT_DIR/system/gtk, skip."
fi
[[ -d "$SCRIPT_DIR/system/lightdm" ]] && sudo cp -r "$SCRIPT_DIR/system/lightdm/"* /etc/lightdm/
[[ -d "$SCRIPT_DIR/fonts" ]] && sudo cp -r "$SCRIPT_DIR/fonts/"* "$FONTS_DIR/"
[[ -d "$SCRIPT_DIR/icons" ]] && sudo cp -r "$SCRIPT_DIR/icons/"* "$ICONS_DIR/"
[[ -d "$SCRIPT_DIR/themes" ]] && sudo cp -r "$SCRIPT_DIR/themes/"* "$THEMES_DIR/"
success "Fonts, Icons & Themes config copied."
if [[ -d "$SCRIPT_DIR/other/pipewire" ]]; then
cp -r "$SCRIPT_DIR/other/pipewire"/* "$CONFIG_DIR/pipewire/"
chmod +x "$CONFIG_DIR/pipewire/"*
fi
[[ -f "$SCRIPT_DIR/other/.bashrc" ]] && cp "$SCRIPT_DIR/other/.bashrc" "$HOME_DIR/"
[[ -d "$SCRIPT_DIR/other/xorg.conf.d" ]] && sudo cp -r "$SCRIPT_DIR/other/xorg.conf.d" /etc/X11/
[[ -f "$SCRIPT_DIR/other/resolv.conf" ]] && sudo cp "$SCRIPT_DIR/other/resolv.conf" /etc/
[[ -f "$SCRIPT_DIR/system/elogind/logind.conf" ]] && sudo cp "$SCRIPT_DIR/system/elogind/logind.conf" /etc/elogind/
# Wallpaper
if [[ -d "$SCRIPT_DIR/system/wallpaper" ]]; then
sudo mkdir -p "$WALLPAPER_DIR"
sudo cp "$SCRIPT_DIR/system/wallpaper/"*.jpg "$WALLPAPER_DIR/"
fi
[[ -f "$SCRIPT_DIR/other/.bashrc" ]] && sudo cp "$SCRIPT_DIR/other/.bashrc" /root/ 2>/dev/null || true
success "Dotfiles copied."
}
# ---------------------------------------------------------------------------
# Refresh Helpers
# ---------------------------------------------------------------------------
refresh_fonts() {
info "Refreshing font cache..."
sudo fc-cache -fv "$FONTS_DIR" >/dev/null
fc-cache -fv "$HOME/.fonts" 2>/dev/null || true
success "Font cache updated."
}
refresh_icons() {
info "Refreshing icon cache..."
for dir in "$ICONS_DIR"/*/; do
[[ -d "$dir" ]] && \
sudo gtk-update-icon-cache -f -t "$dir" 2>/dev/null || \
warn "Could not update icon cache for: $dir"
done
success "Icon cache updated."
}
refresh_themes() {
info "Refreshing GTK theme..."
sudo chmod -R a+rX "$THEMES_DIR" 2>/dev/null || true
if command -v gsettings >/dev/null 2>&1; then
local first_theme
first_theme=$(ls "$THEMES_DIR" 2>/dev/null | head -1)
[[ -n "$first_theme" ]] && \
gsettings set org.gnome.desktop.interface gtk-theme "$first_theme" 2>/dev/null || \
warn "gsettings schema tidak ditemukan, skip auto-apply theme."
fi
success "Theme refreshed."
}
refresh_grub() {
info "Regenerating GRUB config..."
if command -v update-grub >/dev/null 2>&1; then
sudo update-grub
elif command -v grub-mkconfig >/dev/null 2>&1; then
sudo grub-mkconfig -o /boot/grub/grub.cfg
else
warn "grub-mkconfig / update-grub not found. Update GRUB manually."
return 1
fi
info "Regenerating initramfs..."
if command -v dracut >/dev/null 2>&1; then
sudo dracut -f
else
warn "dracut not found. Regenerate initramfs manually."
fi
success "GRUB config & initramfs regenerated."
}
# ---------------------------------------------------------------------------
other() {
info "Configuring GRUB..."
if [[ -f "$SCRIPT_DIR/system/boot/grub" ]]; then
sudo mkdir -p /etc/default/
sudo cp "$SCRIPT_DIR/system/boot/grub" /etc/default/
else
warn "GRUB Config not found at $SCRIPT_DIR/system/boot/grub, skip."
fi
if [[ -d "$SCRIPT_DIR/system/boot/sleek" ]]; then
sudo mkdir -p /usr/share/grub/themes
sudo cp -r "$SCRIPT_DIR/system/boot/sleek" /usr/share/grub/themes/
else
warn "GRUB theme 'sleek' not found at $SCRIPT_DIR/system/boot/sleek, skip."
fi
if [[ -d "$SCRIPT_DIR/system/boot/t4n" ]]; then
sudo mkdir -p /usr/share/plymouth/themes
sudo cp -r "$SCRIPT_DIR/system/boot/t4n" /usr/share/plymouth/themes/
sudo mkdir -p /etc/dracut.conf.d/
sudo cp "$SCRIPT_DIR/system/boot/plymouth.conf" /etc/dracut.conf.d/
sudo plymouth-set-default-theme -R t4n
else
warn "Plymouth theme 't4n' not found at $SCRIPT_DIR/system/boot/t4n, skip."
fi
refresh_fonts
refresh_icons
refresh_themes
refresh_grub
success "GRUB theme & system config done."
}
# ---------------------------------------------------------------------------
setup_services() {
info "Enabling system services..."
local services=(dbus elogind NetworkManager lightdm rtkit polkit power-profiles-daemon)
for svc in "${services[@]}"; do
if [[ -d "/etc/sv/$svc" ]]; then
if [[ ! -L "/var/service/$svc" ]]; then
sudo ln -s "/etc/sv/$svc" /var/service/
info "$svc enabled."
else
info "$svc already enabled, skip."
fi
else
warn "Service $svc not found."
fi
done
success "Services activated."
}
disable_services() {
info "Disabling conflicting services..."
local services=(acpid dhcpcd wpa_supplicant)
for svc in "${services[@]}"; do
if [[ -L "/var/service/$svc" ]]; then
sudo sv down "$svc" 2>/dev/null
sudo rm -f "/var/service/$svc"
info "$svc stopped and disabled."
else
warn "$svc is not enabled or not found."
fi
done
success "Conflicting services disabled."
}
# ---------------------------------------------------------------------------
setup_additional() {
info "Applying additional configuration..."
sudo mkdir -p /etc/polkit-1/rules.d
sudo tee /etc/polkit-1/rules.d/10-bspwm.rules >/dev/null << 'EOF'
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.suspend") &&
subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
});
EOF
sudo tee /etc/polkit-1/rules.d/50-networkmanager.rules >/dev/null << 'EOF'
polkit.addRule(function(action, subject) {
if (subject.isInGroup("wheel")) {
var allowed = [
"org.freedesktop.NetworkManager.enable-disable-network",
"org.freedesktop.NetworkManager.enable-disable-wifi",
"org.freedesktop.NetworkManager.enable-disable-wwan",
"org.freedesktop.NetworkManager.network-control",
"org.freedesktop.NetworkManager.settings.modify.system"
];
if (allowed.indexOf(action.id) >= 0) {
return polkit.Result.YES;
}
}
});
EOF
sudo usermod -a -G audio,video,input,disk,wheel "$USER"
if [[ ! -w /sys/class/backlight/*/brightness ]] 2>/dev/null; then
sudo tee /etc/udev/rules.d/90-backlight.rules >/dev/null << 'EOF'
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
EOF
fi
if [[ -f /etc/resolv.conf ]]; then
sudo mkdir -p /etc/NetworkManager/conf.d
echo -e "[main]\nrc-manager=unmanaged" \
| sudo tee /etc/NetworkManager/conf.d/rc-manager.conf >/dev/null
fi
success "Additional configuration complete."
}
# ---------------------------------------------------------------------------
setup_betterlockscreen() {
info "Setting up Betterlockscreen..."
local wallpaper="$WALLPAPER_DIR/Void.jpg"
if [[ -f "$wallpaper" ]]; then
betterlockscreen -u "$wallpaper" --blur 0.8
else
warn "Wallpaper not found at $wallpaper, skip."
fi
}
# ---------------------------------------------------------------------------
final_message() {
echo ""
echo -e "${GREEN}╔══════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Setup BSPWM on Void Linux By Gh0sT4n ║${NC}"
echo -e "${GREEN}╚══════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${YELLOW}‼️ LANGKAH PALING PENTING ‼️${NC}"
echo -e " ${CYAN}1. LOGOUT dari sesi saat ini (atau reboot).${NC}"
echo -e " ${CYAN}2. LOGIN kembali agar semua perubahan grup berlaku.${NC}"
echo ""
echo -e "${BLUE}Setelah login:${NC}"
echo -e " • Cek D-Bus session: ${CYAN}echo \$DBUS_SESSION_BUS_ADDRESS${NC}"
echo -e " Harusnya: 'unix:path=/run/user/1000/bus'"
echo -e " • Cek ZRam aktif: ${CYAN}cat /proc/swaps${NC}"
echo -e " • Cek konfigurasi: ${CYAN}cat /etc/sv/zramen/conf${NC}"
echo -e " • Jika terminal gagal, buka TTY (Ctrl+Alt+F2) dan cek log:"
echo -e " ${CYAN}tail -f ~/.config/bspwm/autostart.log${NC}"
echo ""
echo -e " • Polybar cek: ${CYAN}pgrep polybar${NC}"
echo -e " • Manual: ${CYAN}~/.config/polybar/launch.sh${NC}"
echo ""
echo -e "${GREEN}Terima kasih telah menggunakan script ini.${NC}"
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
main() {
info "Memulai instalasi BSPWM T4n OS (Void Linux)..."
install_packages
detect_gpu
setup_gpu
setup_zram
setup_dbus
create_user_dirs
setup_pipewire
dotfiles
other
setup_services
disable_services
setup_additional
setup_betterlockscreen
final_message
}
main