-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1217 lines (976 loc) · 31 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·1217 lines (976 loc) · 31 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
#!/usr/bin/env bash
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_DIR="$SCRIPT_DIR"
BACKUP_ROOT="$HOME/.local/state/linux-configs-backups"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
BACKUP_DIR="$BACKUP_ROOT/$TIMESTAMP"
TEMP_DIR=""
MONITOR_SETUP_MODE=""
INSTALL_GRUB_THEME=false
INSTALL_DEVICE_TYPE="desktop"
REQUIRED_PACMAN_PACKAGES=(
# Dev utilities
alacritty
git
base-devel
yad
neovim
jq
fzf
# Zsh
zsh
zsh-autosuggestions
zsh-syntax-highlighting
# Fonts
ttf-nerd-fonts-symbols
ttf-roboto
otf-font-awesome
noto-fonts-cjk
# System apps
firefox
gnome-calendar
gnome-disk-utility
seahorse
celluloid
loupe
resources
nautilus
nwg-look
# Desktop components
waybar
swaync
swayosd
# Hyprland utilities
hypridle
hyprland
hyprlock
hyprpaper
hyprpicker
hyprshot
# Audio
pavucontrol
pipewire-pulse
playerctl
# System services
polkit-gnome
gnome-keyring
brightnessctl
xdg-desktop-portal-hyprland
# Hyprpm dependencies
cmake
cpio
# Fluent theme dependencies
gnome-themes-extra
sassc
# Other utilities
keyd
qt6ct
wireplumber
wtype
socat
)
LAPTOP_PACMAN_PACKAGES=(
power-profiles-daemon
)
REQUIRED_AUR_PACKAGES=(
# VS Code
visual-studio-code-bin
# Cursor
rose-pine-hyprcursor
# Fonts
otf-apple-sf-pro
ttf-apple-emoji
# Nautilus extensions
nautilus-dropbox
nautilus-admin-gtk4
actions-for-nautilus-git
nautilus-open-any-terminal
# Fluent theme dependencies
gtk-engine-murrine
# Other utilities
vicinae-bin
hyprhalt
)
OPTIONAL_PACKAGE_SUGGESTIONS=(
ghostty
chromium
telegram-desktop
github-desktop-bin
dropbox
libreoffice-still
fastfetch
obs-studio
teamspeak3
vesktop
)
OPTIONAL_PACKAGES=()
HYPRPM_PLUGIN_SOURCES=(
https://github.com/sandwichfarm/hyprexpo
https://github.com/virtcode/hypr-dynamic-cursors
)
HYPRPM_ENABLED_PLUGINS=(
hyprexpo
dynamic-cursors
)
USER_SYMLINKS=(
"$REPO_DIR/hypr:$HOME/.config/hypr"
"$REPO_DIR/hyprhalt:$HOME/.config/hyprhalt"
"$REPO_DIR/swaync:$HOME/.config/swaync"
"$REPO_DIR/swayosd:$HOME/.config/swayosd"
"$REPO_DIR/vicinae:$HOME/.config/vicinae"
"$REPO_DIR/waybar:$HOME/.config/waybar"
"$REPO_DIR/zsh/.zshrc:$HOME/.zshrc"
"$REPO_DIR/zsh/.p10k.zsh:$HOME/.p10k.zsh"
"$REPO_DIR/ghostty:$HOME/.config/ghostty"
"$REPO_DIR/alacritty/alacritty.toml:$HOME/.config/alacritty/alacritty.toml"
"$REPO_DIR/actions-for-nautilus/config.json:$HOME/.local/share/actions-for-nautilus/config.json"
"$REPO_DIR/qt6ct/qt6ct.conf:$HOME/.config/qt6ct/qt6ct.conf"
"$REPO_DIR/Templates:$HOME/Templates"
)
SYSTEM_SYMLINKS=(
"$REPO_DIR/keyd:/etc/keyd"
)
start () {
CheckEnvironment
StartingInstallation
PromptConfigurationOptions
ConfirmReadyToStart
PrepareWorkspace
InstallYAY
InstallPacmanPackages
InstallAURPackages
InstallOptionalPackages
SetupZSH
SetupAlacrittyTheme
SetupGPU
SetupUserSymlinks
SetupDesktopEntries
SetupSystemSymlinks
SetupMonitors
SetupHyprlandPlugins
SetupFluentGTKTheme
SetupFluentIconTheme
[[ $INSTALL_GRUB_THEME == true ]] && InstallGrubTheme
ConfigureNautilusExtensions
ConfigureWaybar
SetupServices
RefreshDesktopDatabase
ValidateInstallation
Cleanup
InstallationCompleted
PromptForManualVicinaeExtensions
PromptForHyprlandRestart
}
StartingInstallation () {
printf "\n\n--- (-.-) Oh, hi there, little buddy (-.-) ---\n"
printf "\nYou are a meme-big-boy looser, aren't ya? Don't got no arch hyprland config of your own, huh? Gotta snatch someone elses, huh? What a looser. What an animal. What a permanent underclass. If I were you I'd kill myself already. But hey, here you are, stealing my dot files. Good luck fixing anything when it breaks. What a disappointment you are. Disgrace.\n"
printf "\nOkay, first things first, give me your sudo password, bitch (>_<)=O.\n\n"
run sudo -v
}
CheckEnvironment () {
logInfo 'Checking installer environment'
if [[ ! -f /etc/arch-release ]]; then
logError 'This installer only supports Arch Linux.'
exit 1
fi
if [[ $EUID -eq 0 ]]; then
logError 'Run this script as your normal user, not as root.'
exit 1
fi
commandExists sudo || {
logError 'sudo is required to install packages and create system symlinks.'
exit 1
}
commandExists hyprctl || {
logError 'hyprctl is required. Run this installer from an active Hyprland session.'
exit 1
}
if [[ -z ${HYPRLAND_INSTANCE_SIGNATURE:-} ]]; then
logError 'This installer must be run from an active Hyprland session.'
exit 1
fi
}
PromptConfigurationOptions () {
PromptForDeviceType
PromptForMonitorSetupMode
PromptForGrubTheme
PromptForOptionalPackages
}
ConfirmReadyToStart () {
local confirmationOptions=(
'Start'
'Cancel'
)
local countdown
local selectedConfirmation=()
selectOptions confirmationOptions selectedConfirmation single true "Ready to start installation? This will make changes to your system which cannot be undone automatically. Backups will be created in $BACKUP_ROOT."
if [[ ${selectedConfirmation[0]} != 'Start' ]]; then
logInfo 'Installation cancelled before making changes.'
exit 0
fi
logInfo 'Starting installation in 5 seconds. Press Ctrl+C to abort.'
for ((countdown = 5; countdown > 0; countdown--)); do
printf 'Starting in %d...\r' "$countdown"
sleep 1
done
printf '%s\n' 'Starting now.'
}
PromptForOptionalPackages () {
local optionalPackageOptions=("${OPTIONAL_PACKAGE_SUGGESTIONS[@]}" 'Provide custom packages [enter manually]')
local selectedOptions=()
local customPackages=()
local selectedOption
local selectionLabel='Select optional packages that you would like to install, you lazy dweeb.'
selectOptions optionalPackageOptions selectedOptions multiple false "$selectionLabel"
OPTIONAL_PACKAGES=()
for selectedOption in "${selectedOptions[@]}"; do
if [[ $selectedOption == 'Provide custom packages [enter manually]' ]]; then
promptForPackageList 'Enter additional packages to install with yay [optional, space-separated, idiota]: ' customPackages
BuildUniquePackageList OPTIONAL_PACKAGES "${OPTIONAL_PACKAGES[@]}" "${customPackages[@]}"
continue
fi
OPTIONAL_PACKAGES+=("$selectedOption")
done
BuildUniquePackageList OPTIONAL_PACKAGES "${OPTIONAL_PACKAGES[@]}"
}
PromptForDeviceType () {
local deviceOptions=(
'Desktop'
'Laptop'
)
local selectedDeviceOption=()
selectOptions deviceOptions selectedDeviceOption single true 'Are you installing this on a laptopor a desktop?'
[[ ${selectedDeviceOption[0]} == 'Laptop' ]] && INSTALL_DEVICE_TYPE='laptop'
}
PromptForMonitorSetupMode () {
local monitorOptions=(
"Keep monitor configuration from the repo, I'm stupid and scared to change anything."
"Auto-generate monitor configuration, I'm lazy and want to die."
"Provide custom configuration, I like to eat my own shit."
)
local selectedMonitorOption=()
selectOptions monitorOptions selectedMonitorOption single true 'How you would like mommy to configure your monitors, big boy?'
case "${selectedMonitorOption[0]}" in
"Keep monitor configuration from the repo, I'm stupid and scared to change anything.")
MONITOR_SETUP_MODE='keep'
;;
"Auto-generate monitor configuration, I'm lazy and want to die.")
MONITOR_SETUP_MODE='auto'
;;
"Provide custom configuration, I like to eat my own shit.")
MONITOR_SETUP_MODE='custom'
;;
*)
logError 'Unknown monitor setup option selected.'
exit 1
;;
esac
}
PromptForGrubTheme () {
local grubThemeOptions=(
'Hell yeah, install the sick-ass GRUB theme'
'No, I want the boring default GRUB vibe'
)
local selectedGrubThemeOption=()
selectOptions grubThemeOptions selectedGrubThemeOption single true 'Do you want to install the included GRUB theme?'
[[ ${selectedGrubThemeOption[0]} == 'Hell yeah, install the sick-ass GRUB theme' ]] && INSTALL_GRUB_THEME=true
}
PrepareWorkspace () {
logInfo 'Preparing installer workspace'
TEMP_DIR=$(mktemp -d)
run mkdir -p "$HOME/.config"
run mkdir -p "$HOME/.local/share/applications"
run mkdir -p "$BACKUP_DIR"
}
InstallYAY () {
commandExists yay && {
logInfo 'YAY is already installed'
return
}
logInfo 'Installing YAY'
run sudo pacman -S --needed --noconfirm git base-devel
run git clone https://aur.archlinux.org/yay-bin.git "$TEMP_DIR/yay-bin"
pushd "$TEMP_DIR/yay-bin" >/dev/null || {
logError 'Failed to enter temporary YAY build directory.'
exit 1
}
run makepkg -si --noconfirm
popd >/dev/null || true
run yay -Sy
}
InstallPacmanPackages () {
local packages=()
if [[ $INSTALL_DEVICE_TYPE == 'laptop' ]]; then
BuildUniquePackageList packages "${REQUIRED_PACMAN_PACKAGES[@]}" "${LAPTOP_PACMAN_PACKAGES[@]}"
else
BuildUniquePackageList packages "${REQUIRED_PACMAN_PACKAGES[@]}"
fi
logInfo 'Installing pacman packages required by this configuration'
run sudo pacman -S --needed --noconfirm "${packages[@]}"
}
InstallAURPackages () {
local packages=()
BuildUniquePackageList packages "${REQUIRED_AUR_PACKAGES[@]}"
[[ ${#packages[@]} -eq 0 ]] && return
logInfo 'Installing AUR packages required by this configuration'
run yay -S --needed --noconfirm "${packages[@]}" --mflags --skipchecksums
}
InstallOptionalPackages () {
local packages=()
BuildUniquePackageList packages "${OPTIONAL_PACKAGES[@]}"
[[ ${#packages[@]} -eq 0 ]] && return
logInfo 'Installing optional packages selected for this machine'
run yay -S --needed --noconfirm "${packages[@]}"
}
SetupZSH () {
local ohMyZshDirectory="$HOME/.oh-my-zsh"
local themeDirectory="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
local autosuggestionsDirectory="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions"
local syntaxHighlightingDirectory="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
if [[ ! -d $ohMyZshDirectory ]]; then
logInfo 'Installing Oh My Zsh'
run sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
else
logInfo 'Oh My Zsh is already installed'
fi
if [[ -d $themeDirectory ]]; then
logInfo 'Powerlevel10k theme is already installed'
else
logInfo 'Installing Powerlevel10k theme for ZSH'
run git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$themeDirectory"
fi
if [[ -d $autosuggestionsDirectory ]]; then
logInfo 'zsh-autosuggestions plugin is already installed'
else
logInfo 'Installing zsh-autosuggestions plugin for ZSH'
run git clone https://github.com/zsh-users/zsh-autosuggestions "$autosuggestionsDirectory"
fi
if [[ -d $syntaxHighlightingDirectory ]]; then
logInfo 'zsh-syntax-highlighting plugin is already installed'
else
logInfo 'Installing zsh-syntax-highlighting plugin for ZSH'
run git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$syntaxHighlightingDirectory"
fi
logInfo 'Setting zsh as the default shell'
run chsh -s $(which zsh)
}
SetupAlacrittyTheme() {
local themeDirectory="$HOME/.config/alacritty/themes"
logInfo 'Installing Alacritty themes'
run mkdir -p "$themeDirectory"
run git clone --depth=1 https://github.com/alacritty/alacritty-theme "$themeDirectory"
}
SetupFluentGTKTheme () {
local themeRepositoryDirectory="$TEMP_DIR/Fluent-gtk-theme"
local themeColorsFilePath="$themeRepositoryDirectory/src/_sass/_colors.scss"
logInfo 'Installing customized Fluent GTK theme'
run git clone --depth=1 https://github.com/vinceliuice/Fluent-gtk-theme.git "$themeRepositoryDirectory"
CustomizeFluentGTKThemeColors "$themeColorsFilePath"
pushd "$themeRepositoryDirectory" >/dev/null || {
logError 'Failed to enter Fluent GTK theme directory.'
exit 1
}
run ./install.sh -t grey -n Fluent-dark -c dark -l -s standard -i default --tweaks round square
popd >/dev/null || true
}
SetupFluentIconTheme () {
local iconRepositoryDirectory="$TEMP_DIR/Fluent-icon-theme"
logInfo 'Installing Fluent icon theme'
run git clone --depth=1 https://github.com/vinceliuice/Fluent-icon-theme.git "$iconRepositoryDirectory"
pushd "$iconRepositoryDirectory" >/dev/null || {
logError 'Failed to enter Fluent icon theme directory.'
exit 1
}
run ./install.sh
popd >/dev/null || true
}
InstallGrubTheme () {
local themeRepositoryDirectory="$TEMP_DIR/Particle-circle-grub-theme"
local screenSize
logInfo 'Installing Particle Circle GRUB theme'
screenSize=$(hyprctl monitors -j | jq -r '
[.[] | select((.disabled // false) | not)]
| max_by(.width * .height)
| if (.width >= 3840 or .height >= 2160) then "4k"
elif (.width >= 2560 or .height >= 1440) then "2k"
else "1080p"
end
')
logInfo "Installing GRUB theme with $screenSize screen size."
run git clone --depth=1 https://github.com/yeyushengfan258/Particle-circle-grub-theme.git "$themeRepositoryDirectory"
pushd "$themeRepositoryDirectory" >/dev/null || {
logError 'Failed to enter Particle Circle GRUB theme directory.'
exit 1
}
run sudo ./install.sh -s "$screenSize"
popd >/dev/null || true
}
CustomizeFluentGTKThemeColors () {
local colorsFilePath=$1
local tempFile
if [[ ! -f $colorsFilePath ]]; then
logError "Fluent GTK theme color customization failed: expected colors file at $colorsFilePath"
exit 1
fi
logInfo 'Customizing Fluent GTK theme dark colors'
tempFile=$(mktemp)
awk '
/^\$background:[[:space:]]+if\(\$variant == '\''light'\'', #F2F2F2, #333333\);$/ {
print "$background: if($variant == '\''light'\'', #F2F2F2, #161616);"
next
}
/^\$surface:[[:space:]]+if\(\$variant == '\''light'\'', #FFFFFF, #3C3C3C\);$/ {
print "$surface: if($variant == '\''light'\'', #FFFFFF, #1e1e1e);"
next
}
/^\$base:[[:space:]]+if\(\$variant == '\''light'\'', #FFFFFF, #2B2B2B\); \/\/ semi-surface with 1dp elevation$/ {
print "$base: if($variant == '\''light'\'', #FFFFFF, #0f0f0f); // semi-surface with 1dp elevation"
next
}
/^\$base-alt:[[:space:]]+if\(\$variant == '\''light'\'', #FAFAFA, #303030\);$/ {
print "$base-alt: if($variant == '\''light'\'', #FAFAFA, #141414);"
next
}
{ print }
' "$colorsFilePath" > "$tempFile"
run mv "$tempFile" "$colorsFilePath"
}
SetupUserSymlinks () {
local mapping source target
logInfo 'Creating user config symlinks'
for mapping in "${USER_SYMLINKS[@]}"; do
source=${mapping%%:*}
target=${mapping#*:}
BackupTargetIfNeeded "$source" "$target"
EnsureParentDirectory "$target"
run ln -sfnT "$source" "$target"
done
}
SetupGPU () {
local envConfigPath aqDrmDevicesPattern tempFile
envConfigPath="$REPO_DIR/hypr/configs/env.conf"
aqDrmDevicesPattern='^[[:space:]]*env[[:space:]]*=[[:space:]]*AQ_DRM_DEVICES,'
if [[ ! -f $envConfigPath ]]; then
logError "GPU setup failed: expected env config at $envConfigPath"
exit 1
fi
if ! grep -Eq "$aqDrmDevicesPattern" "$envConfigPath"; then
logInfo 'No AQ_DRM_DEVICES override found in env.conf'
return
fi
logInfo 'Removing AQ_DRM_DEVICES override from env.conf because its system specific.'
tempFile=$(mktemp)
awk '!match($0, /^[[:space:]]*env[[:space:]]*=[[:space:]]*AQ_DRM_DEVICES,/) { print }' "$envConfigPath" > "$tempFile"
run mv "$tempFile" "$envConfigPath"
}
SetupDesktopEntries () {
local desktopFile targetFile
logInfo 'Creating .desktop files symlinks'
for desktopFile in "$REPO_DIR"/hypr/apps/*.desktop; do
targetFile="$HOME/.local/share/applications/$(basename "$desktopFile")"
BackupTargetIfNeeded "$desktopFile" "$targetFile"
EnsureParentDirectory "$targetFile"
run ln -sfnT "$desktopFile" "$targetFile"
done
}
SetupSystemSymlinks () {
local mapping source target
logInfo 'Creating system config symlinks'
for mapping in "${SYSTEM_SYMLINKS[@]}"; do
source=${mapping%%:*}
target=${mapping#*:}
BackupTargetIfNeeded "$source" "$target"
EnsureParentDirectory "$target"
run sudo ln -sfnT "$source" "$target"
done
}
SetupMonitors () {
local monitorsJson monitorRows monitorConfig
case "$MONITOR_SETUP_MODE" in
keep)
logInfo 'Keeping monitor configuration from the repo'
return
;;
auto)
logInfo 'Auto-generating monitor configuration from current Hyprland session'
;;
custom)
logInfo 'Collecting custom monitor configuration from current Hyprland session'
;;
*)
logError 'Monitor setup mode was not configured.'
exit 1
;;
esac
monitorsJson=$(hyprctl monitors -j 2>/dev/null) || {
logError 'Failed to read monitor information from hyprctl monitors -j.'
exit 1
}
monitorRows=$(printf '%s\n' "$monitorsJson" | jq -r '.[] | select((.disabled // false) | not) | [.name, .width, .height, .refreshRate] | @tsv')
if [[ -z $monitorRows ]]; then
logError 'No active monitors were reported by hyprctl monitors -j.'
exit 1
fi
case "$MONITOR_SETUP_MODE" in
auto)
monitorConfig=$(BuildAutoMonitorConfiguration "$monitorRows")
;;
custom)
monitorConfig=$(BuildCustomMonitorConfiguration "$monitorRows")
;;
esac
printf '%s\n' "$monitorConfig" > "$REPO_DIR/hypr/configs/monitors.conf"
logInfo 'Updated hypr/configs/monitors.conf'
}
SetupHyprlandPlugins () {
local pluginSource pluginName
commandExists hyprpm || {
logError 'hyprpm is required to install Hyprland plugins.'
exit 1
}
logInfo 'Updating Hyprland plugin registry'
run hyprpm update
for pluginSource in "${HYPRPM_PLUGIN_SOURCES[@]}"; do
logInfo "Adding Hyprland plugin source: $pluginSource"
run hyprpm add "$pluginSource"
done
for pluginName in "${HYPRPM_ENABLED_PLUGINS[@]}"; do
logInfo "Enabling Hyprland plugin: $pluginName"
run hyprpm enable "$pluginName"
done
}
ConfigureNautilusExtensions () {
run gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal alacritty
}
ConfigureWaybar () {
local waybarConfigPath monitorsJson monitorNamesJson tempConfigFile
waybarConfigPath="$REPO_DIR/waybar/config.jsonc"
logInfo 'Configuring Waybar outputs from active monitors'
monitorsJson=$(hyprctl monitors -j 2>/dev/null) || {
logError 'Failed to read monitor information from hyprctl monitors -j for Waybar configuration.'
exit 1
}
monitorNamesJson=$(printf '%s\n' "$monitorsJson" | jq -c '[.[] | select((.disabled // false) | not) | .name]') || {
logError 'Failed to parse active monitor names for Waybar configuration.'
exit 1
}
if [[ $monitorNamesJson == '[]' ]]; then
logError 'No active monitors were reported by hyprctl monitors -j for Waybar configuration.'
exit 1
fi
tempConfigFile=$(mktemp)
JsoncToJson "$waybarConfigPath" | jq --argjson monitors "$monitorNamesJson" --arg device "$INSTALL_DEVICE_TYPE" '
def with_power($modules):
($modules - ["group/power"]) as $clean
| if $device != "laptop" then
$clean
else
(($clean | index("group/settings")) // -1) as $index
| if $index < 0 then
$clean
else
$clean[0:($index + 1)] + ["group/power"] + $clean[($index + 1):]
end
end;
(.[0] // error("waybar/config.jsonc must contain at least one array element")) as $primary
| ((.[1] // .[0])) as $secondary
| ($primary | ."modules-right" = with_power(.["modules-right"] // [])) as $primary
| [($primary | .output = $monitors[0])] + [$monitors[1:][] | ($secondary | .output = .)]
' > "$tempConfigFile" || {
rm -f "$tempConfigFile"
logError 'Failed to rebuild Waybar monitor configuration.'
exit 1
}
run mv "$tempConfigFile" "$waybarConfigPath"
logInfo 'Updated waybar/config.jsonc outputs for active monitors'
}
JsoncToJson () {
local jsoncFile=$1
sed -E '/^[[:space:]]*\/\//d; s/[[:space:]]*\/\/.*$//' "$jsoncFile" | perl -0pe 's/,(\s*[\]}])/$1/g'
}
BuildAutoMonitorConfiguration () {
local monitorRows=$1
local output width height refresh
{
printf '# Auto-generated by install.sh using `hyprctl monitors -j`\n\n'
while IFS=$'\t' read -r output width height refresh; do
[[ -z $output ]] && continue
printf 'monitorv2 {\n'
printf ' output = %s\n' "$output"
printf ' mode = %sx%s@%s\n' "$width" "$height" "$refresh"
printf ' position = auto\n'
printf ' scale = 1\n'
printf '}\n'
done <<< "$monitorRows"
printf '\n'
BuildWorkspaceAssignments "$monitorRows"
}
}
BuildCustomMonitorConfiguration () {
local monitorRows=$1
local output width height refresh positionX positionY scale
{
printf '# Auto-generated by install.sh using `hyprctl monitors -j` with user-provided positions\n\n'
while IFS=$'\t' read -r output width height refresh; do
[[ -z $output ]] && continue
PromptForMonitorCoordinate "$output" 'X' positionX
PromptForMonitorCoordinate "$output" 'Y' positionY
PromptForMonitorScale "$output" scale
printf 'monitorv2 {\n'
printf ' output = %s\n' "$output"
printf ' mode = %sx%s@%s\n' "$width" "$height" "$refresh"
printf ' position = %sx%s\n' "$positionX" "$positionY"
printf ' scale = %s\n' "$scale"
printf '}\n'
done <<< "$monitorRows"
printf '\n'
BuildWorkspaceAssignments "$monitorRows"
}
}
BuildWorkspaceAssignments () {
local monitorRows=$1
local output workspaceIndex workspaceCountI
workspaceIndex=1
while IFS=$'\t' read -r output _; do
[[ -z $output ]] && continue
workspaceCount=0
while (( workspaceCount < 4 )); do
printf 'workspace = %d, monitor:%s, persistent:true\n' "$workspaceIndex" "$output"
((workspaceIndex++))
((workspaceCount++))
done
done <<< "$monitorRows"
}
PromptForMonitorCoordinate () {
local output=$1
local axis=$2
local -n resultRef=$3
while true; do
promptForValue "Enter ${axis} position for monitor ${output}: " resultRef
if [[ $resultRef =~ ^-?[0-9]+$ ]]; then
return
fi
logError 'Please enter an integer value.'
done
}
PromptForMonitorScale () {
local output=$1
local -n resultRef=$2
while true; do
promptForValue "Enter scale for monitor ${output} [default: 1]: " resultRef
if [[ -z $resultRef ]]; then
resultRef=1
return
fi
if [[ $resultRef =~ ^[0-9]+([.][0-9]+)?$ ]]; then
return
fi
logError 'Please enter a numeric scale value.'
done
}
SetupServices () {
logInfo 'Enabling required services'
run sudo systemctl enable --now keyd
}
RefreshDesktopDatabase () {
commandExists update-desktop-database || return
logInfo 'Refreshing desktop database'
run update-desktop-database "$HOME/.local/share/applications"
}
ValidateInstallation () {
local mapping source target desktopFile targetFile
logInfo 'Validating symlinks and required artifacts'
for mapping in "${USER_SYMLINKS[@]}"; do
source=${mapping%%:*}
target=${mapping#*:}
EnsureSymlinkMatches "$source" "$target"
done
for desktopFile in "$REPO_DIR"/hypr/apps/*.desktop; do
targetFile="$HOME/.local/share/applications/$(basename "$desktopFile")"
EnsureSymlinkMatches "$desktopFile" "$targetFile"
done
for mapping in "${SYSTEM_SYMLINKS[@]}"; do
source=${mapping%%:*}
target=${mapping#*:}
EnsureSymlinkMatches "$source" "$target"
done
if [[ ! -f "$HOME/.config/waybar/hypr-ws-apps/libhypr_ws_apps.so" ]]; then
logError 'Waybar CFFI module artifact is missing at ~/.config/waybar/hypr-ws-apps/libhypr_ws_apps.so'
exit 1
fi
if ! systemctl is-enabled keyd >/dev/null 2>&1; then
logError 'keyd service is not enabled.'
exit 1
fi
logInfo 'Installer validation completed successfully'
}
InstallationCompleted () {
printf "\n\n--- Installation completed ---\n"
printf "\nGo ahead, enjoy the fruits of my labor, you little stupid fucking bitch. Don't forget that you are nobody, you are worthless, you are incapable of an original thought. Amoeba. Your dad would not be proud.\n"
printf "\nBackups are located in '$BACKUP_DIR', but not like you had anything worthy saving anyway.\n"
printf "\nRestart your computer to ensure all changes take effect and fuck off.\n"
printf "\n8=============D\n"
}
PromptForManualVicinaeExtensions () {
local acknowledgementOptions=(
"Yes, master, I'll do as you say, don't hit me T_T"
)
local selectedAcknowledgement=()
selectOptions acknowledgementOptions selectedAcknowledgement single true "Also, before I forget, I can't do everything for you. Go install the 'Wifi Commander' and 'Bluetooth' Vicinae extensions manually, bitch."
}
PromptForHyprlandRestart () {
local restartOptions=(
"Waaaah, do everything for me, daddy, restart now, please!"
"Restart later, I like to play in mud."
)
local selectedRestartOption=()
selectOptions restartOptions selectedRestartOption single true 'Restart computer now?'
if [[ ${selectedRestartOption[0]} == 'Waaaah, do everything for me, daddy, restart now, please!' ]]; then
logInfo 'Restarting computer now'
run reboot
return
fi
logInfo 'Skipped Hyprland restart. Restart later to apply all changes.'
}
Cleanup () {
[[ -n $TEMP_DIR && -d $TEMP_DIR ]] || return
logInfo 'Cleaning up temporary files'
run rm -rf "$TEMP_DIR"
}
BackupTargetIfNeeded () {
local source=$1
local target=$2
local backupPath
if SymlinkAlreadyMatches "$source" "$target"; then
return
fi
if ! PathExists "$target"; then
return
fi
backupPath="$BACKUP_DIR/${target#/}"
logInfo "Backing up $target to $backupPath"
EnsureBackupParentDirectory "$backupPath"
if IsSystemPath "$target"; then
run sudo mv "$target" "$backupPath"
else
run mv "$target" "$backupPath"
fi
}
EnsureParentDirectory () {
local target=$1
local parentDirectory
parentDirectory=$(dirname "$target")
if IsSystemPath "$target"; then
run sudo mkdir -p "$parentDirectory"
else
run mkdir -p "$parentDirectory"
fi
}
EnsureBackupParentDirectory () {
local target=$1
local parentDirectory
parentDirectory=$(dirname "$target")
if IsSystemPath "$target"; then
run sudo mkdir -p "$parentDirectory"
else
run mkdir -p "$parentDirectory"
fi
}
EnsureSymlinkMatches () {
local source=$1
local target=$2
if SymlinkAlreadyMatches "$source" "$target"; then
return
fi
logError "Symlink validation failed for $target"
exit 1
}
SymlinkAlreadyMatches () {
local source=$1
local target=$2
local sourcePath targetPath
if ! PathIsSymlink "$target"; then
return 1
fi
sourcePath=$(readlink -f "$source") || return 1
if IsSystemPath "$target"; then
targetPath=$(sudo readlink -f "$target") || return 1
else
targetPath=$(readlink -f "$target") || return 1
fi
[[ $sourcePath == "$targetPath" ]]
}
PathExists () {
local target=$1