hyprland-dotfiles/copy.sh

227 lines
9.8 KiB
Bash
Raw Normal View History

2025-02-20 19:36:43 +00:00
#!/bin/bash
clear
wallpaper=$HOME/.config/hypr/wallpaper_effects/.wallpaper_current
waybar_style="$HOME/.config/waybar/style/[Extra] Modern-Combined - Transparent.css"
waybar_config="$HOME/.config/waybar/configs/[TOP] Default"
waybar_config_laptop="$HOME/.config/waybar/configs/[TOP] Default Laptop"
# 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)"
INFO="$(tput setaf 4)[INFO]$(tput sgr0)"
WARN="$(tput setaf 1)[WARN]$(tput sgr0)"
CAT="$(tput setaf 6)[ACTION]$(tput sgr0)"
MAGENTA="$(tput setaf 5)"
ORANGE="$(tput setaf 214)"
WARNING="$(tput setaf 1)"
YELLOW="$(tput setaf 3)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
SKY_BLUE="$(tput setaf 6)"
RESET="$(tput sgr0)"
# check if running as root. if root, the script will exit
if [[ $EUID -eq 0 ]]; then
echo "${ERROR} this script should ${WARNING}NOT${RESET} be executed as root! exiting..."
printf "\n%.0s" {1..2}
exit 1
fi
# function to print colorful text
print_color() {
printf "%b%s%b\n" "$1" "$2" "$CLEAR"
}
# check /etc/os-release to see if this is an ubuntu or debian based distro
if grep -iq '^\(ID_LIKE\|ID\)=.*\(debian\|ubuntu\)' /etc/os-release >/dev/null 2>&1; then
printf "\n%.0s" {1..1}
print_color $WARNING "
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
HYPRLAND-DOTFILES INCOMPATIBLE
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
debian / ubuntu detected. refer to hyprland-dotfiles
README for instruction on how to update your hyprland-
dotfiles
exiting...
"
printf "\n%.0s" {1..3}
exit 1
2025-02-20 19:44:07 +00:00
fi
printf "\n%.0s" {1..1}
echo -e "\e[35m
██░ ██▓██ ██▓ ██▓███ ██▀███ ▓█████▄ ▒█████ ▄▄▄█████▓ ██████
▓██░ ██▒▒██ ██▒▓██░ ██▒▓██ ▒ ██▒▒██▀ ██▌▒██▒ ██▒▓ ██▒ ▓▒▒██ ▒
▒██▀▀██░ ▒██ ██░▓██░ ██▓▒▓██ ░▄█ ▒░██ █▌▒██░ ██▒▒ ▓██░ ▒░░ ▓██▄
░▓█ ░██ ░ ▐██▓░▒██▄█▓▒ ▒▒██▀▀█▄ ░▓█▄ ▌▒██ ██░░ ▓██▓ ░ ▒ ██▒
░▓█▒░██▓ ░ ██▒▓░▒██▒ ░ ░░██▓ ▒██▒░▒████▓ ░ ████▓▒░ ▒██▒ ░ ▒██████▒▒
▒ ░░▒░▒ ██▒▒▒ ▒▓▒░ ░ ░░ ▒▓ ░▒▓░ ▒▒▓ ▒ ░ ▒░▒░▒░ ▒ ░░ ▒ ▒▓▒ ▒ ░
▒ ░▒░ ░▓██ ░▒░ ░▒ ░ ░▒ ░ ▒░ ░ ▒ ▒ ░ ▒ ▒░ ░ ░ ░▒ ░ ░
░ ░░ ░▒ ▒ ░░ ░░ ░░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░
░ ░ ░░ ░ ░ ░ ░ ░ ░
░ ░ ░
\e[0m"
2025-02-20 19:49:08 +00:00
printf "\n%.0s" {1..1}
# create directory for copy logs
if [ ! -d copy-logs ]; then
mkdir copy-logs
fi
# set the name of the log file to include the current date and time
LOG="copy-logs/install-$(date +%d-%H%M%S)_dotfiles.log"
# update home folders
xdg-user-dirs-update 2>&1 | tee -a "$LOG" || true
# setting up for nvidia
if lspci -k | grep -A 2 -E "(VGA|3D)" | grep -iq nvidia; then
echo "${INFO} nvidia gpu detected, setting up proper env's and configs" 2>&1 | tee "$LOG" || true
sed -i '/env = LIBVA_DRIVER_NAME,nvidia/s/^#//' config/hypr/UserConfigs/ENVariables.conf
sed -i '/env = __GLX_VENDOR_LIBRARY_NAME,nvidia/s/^#//' config/hypr/UserConfigs/ENVariables.conf
sed -i '/env = NVD_BACKEND,direct/s/^#//' config/hypr/UserConfigs/ENVariables.conf
# enabling no hardware cursors if nvidia detected
sed -i 's/^\([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*\)false/\1true/' config/hypr/UserConfigs/UserSettings.conf
# disabling explicit sync for nvidia for now (Hyprland 0.42.0)
#sed -i 's/ explicit_sync = 2/ explicit_sync = 0/' config/hypr/UserConfigs/UserSettings.conf
2025-02-20 19:50:36 +00:00
fi
# uncommenting WLR_RENDERER_ALLOW_SOFTWARE,1 if running in a VM is detected
if hostnamectl | grep -q 'Chassis: vm'; then
echo "${INFO} system is running in a virtual machine. setting up proper env's and configs" 2>&1 | tee -a "$LOG" || true
# enabling proper ENV's for Virtual Environment which should help
sed -i 's/^\([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*\)false/\1true/' config/hypr/UserConfigs/UserSettings.conf
sed -i '/env = WLR_RENDERER_ALLOW_SOFTWARE,1/s/^#//' config/hypr/UserConfigs/ENVariables.conf
#sed -i '/env = LIBGL_ALWAYS_SOFTWARE,1/s/^#//' config/hypr/UserConfigs/ENVariables.conf
sed -i '/monitor = Virtual-1, 1920x1080@60,auto,1/s/^#//' config/hypr/UserConfigs/Monitors.conf
2025-02-20 19:54:58 +00:00
fi
# proper polkit for nixos
if hostnamectl | grep -q 'Operating System: NixOS'; then
echo "${INFO} nixos distro detected. Setting up proper env's and configs." 2>&1 | tee -a "$LOG" || true
sed -i -E '/^#?exec-once = \$scriptsDir\/Polkit-NixOS\.sh/s/^#//' config/hypr/UserConfigs/Startup_Apps.conf
sed -i '/^exec-once = \$scriptsDir\/Polkit\.sh$/ s/^#*/#/' config/hypr/UserConfigs/Startup_Apps.conf
fi
# Check if dpkg is installed (used to check if Debian or Ubuntu or based distros)
if grep -iq '^\(ID_LIKE\|ID\)=.*\(debian\|ubuntu\)' /etc/os-release >/dev/null 2>&1; then
echo "${INFO} debian/ubuntu based distro. disabling pyprland since it does not work properly" 2>&1 | tee -a "$LOG" || true
# disabling pyprland as causing issues
sed -i '/^exec-once = pypr &/ s/^/#/' config/hypr/UserConfigs/Startup_Apps.conf
fi
# activating hyprcursor on env by checking if the directory ~/.icons/Bibata-Modern-Ice/hyprcursors exists
if [ -d "$HOME/.icons/Bibata-Modern-Ice/hyprcursors" ]; then
HYPRCURSOR_ENV_FILE="config/hypr/UserConfigs/ENVariables.conf"
echo "${INFO} bibata-hyprcursor directory detected. activating hyprcursor...." 2>&1 | tee -a "$LOG" || true
sed -i 's/^#env = HYPRCURSOR_THEME,Bibata-Modern-Ice/env = HYPRCURSOR_THEME,Bibata-Modern-Ice/' "$HYPRCURSOR_ENV_FILE"
sed -i 's/^#env = HYPRCURSOR_SIZE,24/env = HYPRCURSOR_SIZE,24/' "$HYPRCURSOR_ENV_FILE"
fi
2025-02-20 20:01:22 +00:00
printf "\n%.0s" {1..1}
2025-02-20 20:03:20 +00:00
# Function to detect keyboard layout using localectl or setxkbmap
detect_layout() {
if command -v localectl >/dev/null 2>&1; then
layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}')
if [ -n "$layout" ]; then
echo "$layout"
fi
elif command -v setxkbmap >/dev/null 2>&1; then
layout=$(setxkbmap -query | grep layout | awk '{print $2}')
if [ -n "$layout" ]; then
echo "$layout"
fi
fi
}
2025-02-20 20:01:22 +00:00
# detect the current keyboard layout
layout=$(detect_layout)
if [ "$layout" = "(unset)" ]; then
while true; do
printf "\n%.0s" {1..1}
print_color $WARNING "
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
STOP AND READ
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
!!! IMPORTANT WARNING !!!
the default keyboard layout could not be detected
you need to set it manually
!!! WARNING !!!
setting a wrong keyboard layout will cause Hyprland to crash
If you are not sure, just type ${YELLOW}us${RESET}
${SKYBLUE}you can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET}
${MAGENTA} NOTE:${RESET}
• you can also set more than 2 keyboard layouts
for example: ${YELLOW}us, kr, gb, no${RESET}
"
printf "\n%.0s" {1..1}
read -p "${CAT} - please enter the correct keyboard layout: " new_layout
if [ -n "$new_layout" ]; then
layout="$new_layout"
break
else
echo "${CAT} please enter a keyboard layout."
fi
done
fi
printf "${NOTE} detecting keyboard layout to prepare proper hyprland settings\n"
# prompt the user to confirm whether the detected layout is correct
while true; do
printf "${INFO} current keyboard layout is ${MAGENTA}$layout${RESET}\n"
read -p "${CAT} is this correct? [y/n] " keyboard_layout
case $keyboard_layout in
[yY])
awk -v layout="$layout" '/kb_layout/ {$0 = " kb_layout = " layout} 1' config/hypr/UserConfigs/UserSettings.conf > temp.conf
mv temp.conf config/hypr/UserConfigs/UserSettings.conf
echo "${NOTE} kb_layout ${MAGENTA}$layout${RESET} configured in settings" 2>&1 | tee -a "$LOG"
break ;;
[nN])
printf: "\n%.0s" {1..2}
print_color $WARNING "
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
STOP AND READ
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
!!! IMPORTANT WARNING !!!
the default keyboard layout could not be detected
you need to set it Manually
!!! WARNING !!!
setting a wrong keyboard layout will cause hyprland to crash
if you are not sure, just type ${YELLOW}us${RESET}
${SKYBLUE}you can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET}
${MAGENTA} NOTE:${RESET}
• you can also set more than 2 keyboard layouts
for example: ${YELLOW}us, kr, gb, no${RESET}
"
printf "\n%.0s" {1..1}
read -p "${CAT} - Please enter the correct keyboard layout: " new_layout
awk -v new_layout="$new_layout" '/kb_layout/ {$0 = " kb_layout = " new_layout} 1' config/hypr/UserConfigs/UserSettings.conf > temp.conf
mv temp.conf config/hypr/UserConfigs/UserSettings.conf
echo "${OK} kb_layout $new_layout configured in settings." 2>&1 | tee -a "$LOG"
break ;;
*)
echo "${ERROR} Please enter either 'y' or 'n'." ;;
esac
done