forked from JaKooLit/Hyprland-v2.1
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-hyprland-2.1.sh
executable file
·697 lines (610 loc) · 22.4 KB
/
install-hyprland-2.1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#!/bin/bash
# https://github.com/JaKooLit
# Set some colors for output messages
OK="$(tput setaf 2)[OK]$(tput sgr0)"
ERROR="$(tput setaf 1)[ERROR]$(tput sgr0)"
NOTE="$(tput setaf 3)[NOTE]$(tput sgr0)"
WARN="$(tput setaf 166)[WARN]$(tput sgr0)"
CAT="$(tput setaf 6)[ACTION]$(tput sgr0)"
ORANGE=$(tput setaf 166)
YELLOW=$(tput setaf 3)
RESET=$(tput sgr0)
# Set the name of the log file to include the current date and time
LOG="install-$(date +%d-%H%M%S).log"
#clear screen
clear
# Get the width of the terminal
TERM_WIDTH=$(tput cols)
# Calculate the padding for the message
MESSAGE="Welcome to my Arch-Hyprland Installer"
PAD_LENGTH=$((($TERM_WIDTH - ${#MESSAGE}) / 2))
# Set the color to green
GREN='\033[0;32m'
NC='\033[0m' # No Color
# Display the message with thicker width and green color
printf "${GREN}+$(printf '%*s' "$((TERM_WIDTH - 1))" '' | tr ' ' -)+${NC}\n"
printf "${GREN}|%*s${MESSAGE}%*s|${NC}\n" $PAD_LENGTH "" $PAD_LENGTH ""
printf "${GREN}+$(printf '%*s' "$((TERM_WIDTH - 1))" '' | tr ' ' -)+${NC}\n"
sleep 2
# Print backup warning message
printf "${ORANGE}$(tput smso)PLEASE BACKUP YOUR FILES BEFORE PROCEEDING!$(tput rmso)\n"
printf "${YELLOW} Although I will attempt to backup your files!\n"
printf "\n"
printf "\n"
sleep 2
# Print password warning message
printf "\n${YELLOW} Some commands require you to enter your password in order to execute.\n"
printf " If you are worried about entering your password, you can cancel the script now with CTRL+C and review the contents of this script.${RESET}\n"
sleep 2
printf "\n"
printf "\n"
# Print VM warning message
printf "\n${NOTE} If you are installing on a VM (virtual box, VMWARE, QEMU-KVM), kindly ensure that 3D acceleration is enabled.\n"
printf "Hyprland's performance on a Virtual Environment is abysmal... worst at its best. and it may not start at all!! YOU HAVE BEEN WARNED .${RESET}\n"
sleep 2
printf "\n"
printf "\n"
# Print system-update warning message
printf "\n${NOTE} If you have not perform a full system update for a while, cancel the script by CTRL C and perform a full system update first\n"
printf "${WARN} If there is a kernel update, reboot first your system and re-run script. Script may fail if not updated. .${RESET}\n"
sleep 2
printf "\n"
printf "\n"
# proceed
read -n1 -rep "${CAT} Shall we proceed with installation (y/n) " PROCEED
echo
if [[ $PROCEED =~ ^[Yy]$ ]]; then
printf "\n%s Alright.....LETS BEGIN!.\n" "${OK}"
else
printf "\n%s NO changes made to your system. Goodbye.!!!\n" "${NOTE}"
exit
fi
#clear screen
clear
# Check for AUR helper and install if not found
ISAUR=$(command -v yay || command -v paru)
if [ -n "$ISAUR" ]; then
printf "\n%s - AUR helper was located, moving on.\n" "${OK}"
else
printf "\n%s - AUR helper was NOT located\n" "$WARN"
while true; do
read -rp "${CAT} Which AUR helper do you want to use, yay or paru? Enter 'y' or 'p': " choice
case "$choice" in
y | Y)
printf "\n%s - Installing yay from AUR\n" "${NOTE}"
git clone https://aur.archlinux.org/yay-bin.git || {
printf "%s - Failed to clone yay from AUR\n" "${ERROR}"
exit 1
}
cd yay-bin || {
printf "%s - Failed to enter yay-bin directory\n" "${ERROR}"
exit 1
}
makepkg -si --noconfirm 2>&1 | tee -a "$LOG" || {
printf "%s - Failed to install yay from AUR\n" "${ERROR}"
exit 1
}
cd ..
break
;;
p | P)
printf "\n%s - Installing paru from AUR\n" "${NOTE}"
git clone https://aur.archlinux.org/paru-bin.git || {
printf "%s - Failed to clone paru from AUR\n" "${ERROR}"
exit 1
}
cd paru-bin || {
printf "%s - Failed to enter paru-bin directory\n" "${ERROR}"
exit 1
}
makepkg -si --noconfirm 2>&1 | tee -a "$LOG" || {
printf "%s - Failed to install paru from AUR\n" "${ERROR}"
exit 1
}
cd ..
break
;;
*)
printf "%s - Invalid choice. Please enter 'y' or 'p'\n" "${ERROR}"
continue
;;
esac
done
fi
#clear screen
clear
# Update system before proceeding
printf "\n%s - Performing a full system update to avoid issues.... \n" "${NOTE}"
ISAUR=$(command -v yay || command -v paru)
$ISAUR -Syu --noconfirm 2>&1 | tee -a "$LOG" || {
printf "%s - Failed to update system\n" "${ERROR}"
exit 1
}
#clear screen
clear
# Set the script to exit on error
set -e
# Function for installing packages
install_package() {
# checking if package is already installed
if $ISAUR -Q "$1" &>>/dev/null; then
echo -e "${OK} $1 is already installed. skipping..."
else
# package not installed
echo -e "${NOTE} installing $1 ..."
$ISAUR -S --noconfirm "$1" 2>&1 | tee -a "$LOG"
# making sure package installed
if $ISAUR -Q "$1" &>>/dev/null; then
echo -e "\e[1A\e[K${OK} $1 was installed."
else
# something is missing, exitting to review log
echo -e "\e[1A\e[K${ERROR} $1 failed to install :( , please check the install.log . You may need to install manually! Sorry I have tried :("
exit 1
fi
fi
}
# Function to print error messages
print_error() {
printf " %s%s\n" "${ERROR}" "$1" "$NC" 2>&1 | tee -a "$LOG"
}
# Function to print success messages
print_success() {
printf "%s%s%s\n" "${OK}" "$1" "$NC" 2>&1 | tee -a "$LOG"
}
# Exit immediately if a command exits with a non-zero status.
set -e
# Hyprland Main installation part including automatic detection of Nvidia-GPU is present in your system
if ! lspci -k | grep -A 2 -E "(VGA|3D)" | grep -iq nvidia; then
printf "${YELLOW} No NVIDIA GPU detected in your system. Installing Hyprland without Nvidia support..."
sleep 1
for HYP in hyprland; do
install_package "$HYP" 2>&1 | tee -a $LOG
done
else
# Prompt user for Nvidia installation
printf "${YELLOW} NVIDIA GPU Detected. Kindly note that Nvidia-Wayland is still kinda wonky. Kindly check Hyprland Wiki if Issues encountered!\n"
sleep 1
printf "${YELLOW} Kindly enable some Nvidia-related stuff in the configs after installation\n"
sleep 2
read -n1 -rp "Would you like to install Nvidia Hyprland? (y/n) " NVIDIA
echo
if [[ $NVIDIA =~ ^[Yy]$ ]]; then
# Install Nvidia Hyprland
printf "\n"
printf "${YELLOW}Installing Nvidia Hyprland...${RESET}\n"
if pacman -Qs hyprland >/dev/null; then
read -n1 -rp "Hyprland detected. Would you like to remove and install hyprland-nvidia instead? (y/n) " nvidia_hypr
echo
if [[ $nvidia_hypr =~ ^[Yy]$ ]]; then
sudo pacman -R --noconfirm hyprland 2>/dev/null | tee -a "$LOG" || true
fi
fi
for hyprnvi in hyprland hyprland-nvidia hyprland-nvidia-hidpi-git; do
sudo pacman -R --noconfirm "$hyprnvi" 2>/dev/null | tee -a $LOG || true
done
install_package "hyprland-nvidia-git" 2>&1 | tee -a $LOG
else
printf "\n"
printf "${YELLOW} Installing non-Nvidia Hyprland...\n"
for hyprnvi in hyprland-nvidia-git hyprland-nvidia hyprland-nvidia-hidpi-git; do
sudo pacman -R --noconfirm "$hyprnvi" 2>/dev/null | tee -a $LOG || true
done
for HYP2 in hyprland; do
install_package "$HYP2" 2>&1 | tee -a $LOG
done
fi
# Install additional nvidia packages
printf "${YELLOW} Installing additional Nvidia packages...\n"
for krnl in $(cat /usr/lib/modules/*/pkgbase); do
for NVIDIA in "${krnl}-headers" nvidia-dkms nvidia-settings nvidia-utils libva libva-nvidia-driver-git; do
install_package "$NVIDIA" 2>&1 | tee -a $LOG
done
done
# adding nvidia modules in mkinitcpio
sudo sed -i 's/MODULES=()/MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf 2>&1 | tee -a $LOG
sudo mkinitcpio -P 2>&1 | tee -a $LOG
printf "\n"
printf "\n"
# preparing exec.conf to enable env = WLR_NO_HARDWARE_CURSORS,1 so it will be ready once config files copied
sed -i '44s/#//' config/hypr/configs/exec.conf
# Additional Nvidia steps
NVEA="/etc/modprobe.d/nvidia.conf"
if [ -f "$NVEA" ]; then
printf "${OK} Seems like nvidia-drm modeset=1 is already added in your system..moving on.\n"
printf "\n"
else
printf "\n"
printf "${YELLOW} Adding options to $NVEA..."
sudo echo -e "options nvidia-drm modeset=1" | sudo tee -a /etc/modprobe.d/nvidia.conf 2>&1 | tee -a $LOG
printf "\n"
fi
# Blacklist nouveau
read -n1 -rep "${CAT} Would you like to blacklist nouveau? (y/n)" response
echo
if [[ $response =~ ^[Yy]$ ]]; then
NOUVEAU="/etc/modprobe.d/nouveau.conf"
if [ -f "$NOUVEAU" ]; then
printf "${OK} Seems like nouveau is already blacklisted..moving on.\n"
else
printf "\n"
echo "blacklist nouveau" | sudo tee -a "$NOUVEAU" 2>&1 | tee -a $LOG
printf "${NOTE} has been added to $NOUVEAU.\n"
printf "\n"
# to completely blacklist nouveau (See wiki.archlinux.org/title/Kernel_module#Blacklisting 6.1)
if [ -f "/etc/modprobe.d/blacklist.conf" ]; then
echo "install nouveau /bin/true" | sudo tee -a "/etc/modprobe.d/blacklist.conf" 2>&1 | tee -a $LOG
else
echo "install nouveau /bin/true" | sudo tee "/etc/modprobe.d/blacklist.conf" 2>&1 | tee -a $LOG
fi
fi
else
printf "${NOTE} Skipping nouveau blacklisting.\n"
fi
fi
#clear screen
clear
# installation of other components needed
printf "\n%s - Installing other necessary packages.... \n" "${NOTE}"
for PKG1 in foot swaybg hyprlock wofi wlogout mako grim slurp wl-clipboard hyprpolkitagent nwg-look-bin swww pavucontrol playerctl; do
install_package "$PKG1" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $PKG1 install had failed, please check the install.log"
exit 1
fi
done
for PKG2 in qt5ct btop jq gvfs gvfs-mtp ffmpegthumbs mpv curl pamixer brightnessctl xdg-user-dirs ristretto swappy mpv network-manager-applet gtk4 hypridle checkupdates-with-aur; do
install_package "$PKG2" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $PKG2 install had failed, please check the install.log"
exit 1
fi
done
for FONT in ttf-jetbrains-mono-nerd nerd-fonts-sarasa-term; do
install_package "$FONT" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $FONT install had failed, please check the install.log"
exit 1
fi
done
# Check if waybar or waybar-hyprland is installed
if pacman -Qs waybar-hyprland >/dev/null; then
read -n1 -rep "${CAT} waybar-hyprland is already installed. Would you like to uninstall it and install waybar? (y/n)" bar
echo
if [[ $bar =~ ^[Yy]$ ]]; then
sudo pacman -R --noconfirm waybar 2>>"$LOG" >/dev/null || true
sudo pacman -R --noconfirm waybar-hyprland 2>>"$LOG" >/dev/null || true
install_package waybar 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - waybar install had failed, please check the install.log"
exit 1
fi
else
echo "You chose not to install waybar."
fi
else
install_package waybar 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - waybar install had failed, please check the install.log"
exit 1
fi
fi
echo
print_success "All necessary packages installed successfully."
sleep 2
#clear screen
clear
#themes and cursors
for THEME in mojave-gtk-theme mcmojave-cursors mcmojave-circle-icon-theme; do
install_package "$THEME" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $THEME install had failed, please check the install.log"
exit 1
fi
done
#clear screen
clear
# additional packages (File Manager)
read -n1 -rep "${CAT} OPTIONAL - Would you like to install Thunar as file manager? (y/n)" inst3
echo
if [[ $inst3 =~ ^[Yy]$ ]]; then
for THUNAR in thunar thunar-volman tumbler thunar-archive-plugin xarchiver; do
install_package "$THUNAR" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $THUNAR install had failed, please check the install.log"
exit 1
fi
done
# check for existing config folders and backup
for DIR1 in Thunar xfce4; do
DIRPATH=~/.config/$DIR1
if [ -d "$DIRPATH" ]; then
echo -e "${NOTE} Config for $DIR1 found, backing up."
mv $DIRPATH $DIRPATH-back-up 2>&1 | tee -a "$LOG"
echo -e "${NOTE} Backed up $DIR1 to $DIRPATH-back-up."
fi
done
cp -r config/xfce4 ~/.config/ || {
echo "Error: Failed to copy xfce4 config files."
exit 1
} 2>&1 | tee -a "$LOG"
cp -r config/Thunar ~/.config/ || {
echo "Error: Failed to copy Thunar config files."
exit 1
} 2>&1 | tee -a "$LOG"
else
printf "${NOTE} Thunar will not be installed.\n"
fi
#clear screen
clear
# BLUETOOTH
read -n1 -rep "${CAT} OPTIONAL - Would you like to install Bluetooth packages? (y/n)" inst4
if [[ $inst4 =~ ^[Yy]$ ]]; then
printf "${NOTE} Installing Bluetooth Packages...\n"
for BLUE in bluez bluez-utils blueman; do
install_package "$BLUE" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $BLUE install had failed, please check the install.log"
exit 1
fi
done
printf " Activating Bluetooth Services...\n"
sudo systemctl enable --now bluetooth.service 2>&1 | tee -a "$LOG"
else
printf "${NOTE} No bluetooth packages installed..\n"
fi
#clear screen
clear
# SDDM install
read -n1 -rep "${CAT} OPTIONAL - Would you like to install SDDM as the login manager? (y/n)" install_sddm
echo
if [[ $install_sddm =~ ^[Yy]$ ]]; then
# Check if SDDM is already installed
if pacman -Qs sddm >/dev/null; then
# Prompt user to manually install sddm to remove SDDM
read -n1 -rep "SDDM is already installed. Would you like to manually install sddm to remove it? This requires manual intervention. (y/n)" manual_install_sddm
echo
if [[ $manual_install_sddm =~ ^[Yy]$ ]]; then
$ISAUR -S sddm 2>&1 | tee -a "$LOG"
fi
fi
# Install SDDM and sddm-macos theme
printf "${NOTE} Installing SDDM and sddm-macos theme...\n"
for package in sddm; do
install_package "$package" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $package install has failed, please check the install.log"
exit 1
fi
done
# Check if other login managers installed and disabling its service before enabling sddm
if pacman -Qs lightdm >/dev/null; then
echo "disabling lightdm..."
sudo systemctl disable lightdm.service 2>&1 | tee -a "$LOG"
fi
if pacman -Qs gdm >/dev/null; then
echo "disabling gdm..."
sudo systemctl disable gdm.service 2>&1 | tee -a "$LOG"
fi
if pacman -Qs lxdm >/dev/null; then
echo "disabling lxdm..."
sudo systemctl disable lxdm.service 2>&1 | tee -a "$LOG"
fi
if pacman -Qs lxdm-gtk3 >/dev/null; then
echo "disabling lxdm..."
sudo systemctl disable lxdm.service 2>&1 | tee -a "$LOG"
fi
printf " Activating sddm service........\n"
sudo systemctl enable sddm
# Set up SDDM
echo -e "${NOTE} Setting up the login screen."
sddm_conf_dir=/etc/sddm.conf.d
sddm_theme_dir=/usr/share/sddm/themes
if [ ! -d "$sddm_conf_dir" ]; then
printf "$CAT - $sddm_conf_dir not found, creating...\n"
sudo mkdir "$sddm_conf_dir" 2>&1 | tee -a "$LOG"
fi
if [ ! -d "$sddm_theme_dir" ]; then
printf "$CAT - $sddm_theme_dir not found, creating...\n"
sudo mkdir "$sddm_theme_dir" 2>&1 | tee -a "$LOG"
fi
sudo cp -a config/sddm/ssdm-macos "$sddm_theme_dir/" 2>&1 | tee -a "$LOG"
echo -e "[Theme]\nCurrent=sddm-macos" | sudo tee -a "$sddm_conf_dir/10-theme.conf" 2>&1 | tee -a "$LOG"
wayland_sessions_dir=/usr/share/wayland-sessions
if [ ! -d "$wayland_sessions_dir" ]; then
printf "$CAT - $wayland_sessions_dir not found, creating...\n"
sudo mkdir "$wayland_sessions_dir" 2>&1 | tee -a "$LOG"
fi
sudo cp misc/hyprland.desktop "$wayland_sessions_dir/" 2>&1 | tee -a "$LOG"
else
printf "${NOTE} SDDM will not be installed.\n"
fi
#clear screen
clear
# XDPH
printf "${YELLOW} Kindly note XDPH only needed for screencast/screenshot. Hyprland will still work hence this is optional\n"
printf "\n"
read -n1 -rep "${CAT} Would you like to install XDG-Portal-Hyprland? (y/n)" XDPH
if [[ $XDPH =~ ^[Yy]$ ]]; then
printf "${NOTE} Installing XDPH...\n"
for xdph in xdg-desktop-portal-hyprland; do
install_package "$xdph" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
echo -e "\e[1A\e[K${ERROR} - $xdph install had failed, please check the install.log"
exit 1
fi
done
printf "${NOTE} Checking for other other XDG-Desktop-Portal-Implementations....\n"
sleep 1
printf "\n"
printf "${NOTE} XDG-desktop-portal-KDE (if installed) should be manually disabled or removed! I cant remove it... sorry...\n"
read -n1 -rep "${CAT} Would you like me to try to remove other XDG-Desktop-Portal-Implementations? (y/n)" XDPH1
sleep 1
if [[ $XDPH1 =~ ^[Yy]$ ]]; then
# Clean out other portals
printf "${NOTE} Clearing any other xdg-desktop-portal implementations...\n"
# Check if packages are installed and uninstall if present
if pacman -Qs xdg-desktop-portal-gnome >/dev/null; then
echo "Removing xdg-desktop-portal-gnome..."
sudo pacman -R --noconfirm xdg-desktop-portal-gnome 2>&1 | tee -a "$LOG"
fi
if pacman -Qs xdg-desktop-portal-gtk >/dev/null; then
echo "Removing xdg-desktop-portal-gtk..."
sudo pacman -R --noconfirm xdg-desktop-portal-gtk 2>&1 | tee -a "$LOG"
fi
if pacman -Qs xdg-desktop-portal-wlr >/dev/null; then
echo "Removing xdg-desktop-portal-wlr..."
sudo pacman -R --noconfirm xdg-desktop-portal-wlr 2>&1 | tee -a "$LOG"
fi
if pacman -Qs xdg-desktop-portal-lxqt >/dev/null; then
echo "Removing xdg-desktop-portal-lxqt..."
sudo pacman -R --noconfirm xdg-desktop-portal-lxqt 2>&1 | tee -a "$LOG"
fi
print_success " All other XDG-DESKTOP-PORTAL implementations cleared."
fi
else
printf "${NOTE} XDPH will not be installed..\n"
fi
#clear screen
clear
### Disable wifi powersave mode ###
read -n1 -rp "${CAT} Would you like to disable wifi powersave? (y/n) " WIFI
if [[ $WIFI =~ ^[Yy]$ ]]; then
LOC="/etc/NetworkManager/conf.d/wifi-powersave.conf"
if [ -f "$LOC" ]; then
printf "${OK} seems wifi powersave already disabled.\n"
else
printf "\n"
printf "${NOTE} The following has been added to $LOC.\n"
printf "[connection]\nwifi.powersave = 2" | sudo tee -a $LOC
printf "\n"
printf "${NOTE} Restarting NetworkManager service...\n"
sudo systemctl restart NetworkManager 2>&1 | tee -a "$LOG"
sleep 2
fi
else
printf "${NOTE} WIFI Powersave is not being disabled.\n"
fi
#clear screen
clear
# Function to detect keyboard layout in a tty environment
detect_tty_layout() {
layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}')
if [ -n "$layout" ]; then
echo "$layout"
else
echo "unknown"
fi
}
# preparing hyprland.conf keyboard layout
# Function to detect keyboard layout in an X server environment
detect_x_layout() {
layout=$(setxkbmap -query | grep layout | awk '{print $2}')
if [ -n "$layout" ]; then
echo "$layout"
else
echo "unknown"
fi
}
# Detect the current keyboard layout based on the environment
if [ -n "$DISPLAY" ]; then
# System is in an X server environment
layout=$(detect_x_layout)
else
# System is in a tty environment
layout=$(detect_tty_layout)
fi
echo "Keyboard layout: $layout"
printf "${NOTE} Detecting keyboard layout to prepare necessary changes in hyprland.conf before copying\n"
printf "\n"
printf "\n"
# Prompt the user to confirm whether the detected layout is correct
read -p "Detected keyboard layout or keymap: $layout. Is this correct? [y/n] " confirm
if [ "$confirm" = "y" ]; then
# If the detected layout is correct, update the 'kb_layout=' line in the file
awk -v layout="$layout" '/kb_layout/ {$0 = " kb_layout=" layout} 1' config/hypr/hyprland.conf >temp.conf
mv temp.conf config/hypr/hyprland.conf
else
# If the detected layout is not correct, prompt the user to enter the correct layout
printf "${WARN} Ensure to type in the proper keyboard layout, e.g., uk, de, pl, etc.\n"
read -p "Please enter the correct keyboard layout: " new_layout
# Update the 'kb_layout=' line with the correct layout in the file
awk -v new_layout="$new_layout" '/kb_layout/ {$0 = " kb_layout=us," new_layout} 1' config/hypr/hyprland.conf >temp.conf
mv temp.conf config/hypr/hyprland.conf
fi
printf "\n"
printf "\n"
### Copy Config Files ###
set -e # Exit immediately if a command exits with a non-zero status.
read -n1 -rep "${CAT} Would you like to copy config and wallpaper files? (y,n)" CFG
if [[ $CFG =~ ^[Yy]$ ]]; then
# check for existing config folders and backup
for DIR in btop hypr foot mako swappy waybar wlogout wofi; do
DIRPATH=~/.config/$DIR
if [ -d "$DIRPATH" ]; then
echo -e "${NOTE} - Config for $DIR found, attempting to back up."
mv $DIRPATH $DIRPATH-back-up 2>&1 | tee -a "$LOG"
echo -e "${NOTE} - Backed up $DIR to $DIRPATH-back-up."
fi
done
for DIRw in wallpapers; do
DIRPATH=~/Pictures/$DIRw
if [ -d "$DIRPATH" ]; then
echo -e "${NOTE} - wallpapers in $DIRw found, attempting to back up."
mv $DIRPATH $DIRPATH-back-up 2>&1 | tee -a "$LOG"
echo -e "${NOTE} - Backed up $DIRw to $DIRPATH-back-up."
fi
done
printf " Copying config files...\n"
mkdir -p ~/.config
cp -r config/hypr ~/.config/ || {
echo "Error: Failed to copy hypr config files."
exit 1
} 2>&1 | tee -a "$LOG"
cp -r config/foot ~/.config/ || {
echo "Error: Failed to copy foot config files."
exit 1
} 2>&1 | tee -a "$LOG"
cp -r config/wlogout ~/.config/ || {
echo "Error: Failed to copy wlogout config files."
exit 1
} 2>&1 | tee -a "$LOG"
cp -r config/btop ~/.config/ || {
echo "Error: Failed to copy btop config files."
exit 1
} 2>&1 | tee -a "$LOG"
mkdir -p ~/Pictures/wallpapers
cp -r wallpapers ~/Pictures/ && { echo "Copy completed!"; } || {
echo "Error: Failed to copy wallpapers."
exit 1
} 2>&1 | tee -a "$LOG"
else
print_error " No Config files and wallpaper files copied"
fi
#clear screen
clear
### Script is done ###
printf "\n${OK} Yey! Installation Completed.\n"
printf "\n"
printf "\n"
printf "\n${NOTE} NOTICE TO NVIDIA OWNERS! KINDLY REBOOT YOUR SYSTEM !!!"
printf "\n"
printf "\n"
sleep 2
printf "\n${NOTE} You can start Hyprland by typing Hyprland (IF SDDM is not installed) (note the capital H!).\n"
printf "\n"
printf "\n"
printf "\n"
read -n1 -rep "${CAT} Would you like to start Hyprland now? (y,n)" HYP
if [[ $HYP =~ ^[Yy]$ ]]; then
if command -v sddm >/dev/null; then
sudo systemctl start sddm 2>&1 | tee -a "$LOG"
fi
if command -v Hyprland >/dev/null; then
exec Hyprland
else
print_error "Hyprland not found. Please make sure Hyprland is installed by checking install.log.\n"
exit 1
fi
else
exit
fi