hyprland-dotfiles/copy.sh

443 lines
19 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
2025-02-20 20:06:17 +00:00
done
# Check if asusctl is installed and add rog-control-center on Startup
if command -v asusctl >/dev/null 2>&1; then
sed -i '/exec-once = rog-control-center &/s/^#//' config/hypr/UserConfigs/Startup_Apps.conf
fi
# Check if blueman-applet is installed and add blueman-applet on Startup
if command -v blueman-applet >/dev/null 2>&1; then
sed -i '/exec-once = blueman-applet &/s/^#//' config/hypr/UserConfigs/Startup_Apps.conf
fi
# Check if ags is installed edit ags behaviour on configs
if command -v ags >/dev/null 2>&1; then
sed -i '/#exec-once = ags &/s/^#//' config/hypr/UserConfigs/Startup_Apps.conf
sed -i '/#ags -q && ags &/s/^#//' config/hypr/scripts/RefreshNoWaybar.sh
sed -i '/#ags -q && ags &/s/^#//' config/hypr/scripts/Refresh.sh
fi
printf "\n%.0s" {1..1}
# Checking if neovim or vim is installed and offer user if they want to make as default editor
# Function to modify the ENVariables.conf file
update_editor() {
local editor=$1
sed -i "s/#env = EDITOR,.*/env = EDITOR,$editor #default editor/" config/hypr/UserConfigs/ENVariables.conf
echo "${OK} default editor set to ${MAGENTA}$editor${RESET}." 2>&1 | tee -a "$LOG"
}
EDITOR_SET=0
# Check for neovim if installed
if command -v nvim &> /dev/null; then
printf "${INFO} ${MAGENTA}neovim${RESET} is detected as installed\n"
read -p "${CAT} do you want to make ${MAGENTA}neovim${RESET} the default editor? (y/N): " EDITOR_CHOICE
if [[ "$EDITOR_CHOICE" == "y" ]]; then
update_editor "nvim"
EDITOR_SET=1
fi
fi
printf "\n"
# Check for vim if installed, but only if neovim wasn't chosen
if [[ "$EDITOR_SET" -eq 0 ]] && command -v vim &> /dev/null; then
printf "${INFO} ${MAGENTA}vim${RESET} is detected as installed\n"
read -p "${CAT} do you want to make ${MAGENTA}vim${RESET} the default editor? (y/N): " EDITOR_CHOICE
if [[ "$EDITOR_CHOICE" == "y" ]]; then
update_editor "vim"
EDITOR_SET=1
fi
fi
if [[ "$EDITOR_SET" -eq 0 ]]; then
echo "${YELLOW} Neither neovim nor vim is installed or selected as default." 2>&1 | tee -a "$LOG"
fi
2025-02-20 20:08:26 +00:00
printf "\n"
# Action to do for better appearance
while true; do
echo "${NOTE} ${SKY_BLUE} by default, hyprland-dotfiles is configured for 1440p or 2k."
echo "${WARN} if you dont select proper resolution, Hyprlock will look weird"
echo "${INFO} if you are not sure what is your resolution, choose 1 here!"
echo "${MAGENTA}select monitor resolution to properly configure appearance and fonts:"
echo "$YELLOW -- enter 1. for monitor resolution less than 1440p (< 1440p)"
echo "$YELLOW -- enter 2. for monitor resolution equal to or higher than 1440p (≥ 1440p)"
read -p "$CAT enter the number of your choice (1 or 2): " res_choice
case $res_choice in
1)
resolution="< 1440p"
break
;;
2)
resolution="≥ 1440p"
break
;;
*)
echo "${ERROR} invalid choice. please enter 1 for < 1440p or 2 for ≥ 1440p."
;;
esac
2025-02-20 20:11:55 +00:00
done
# Use the selected resolution in your existing script
echo "${OK} you have chosen $resolution resolution." 2>&1 | tee -a "$LOG"
# Add your commands based on the resolution choice
if [ "$resolution" == "< 1440p" ]; then
#cp -r config/rofi/resolution/1080p/* config/rofi/ 10-Feb-2025
sed -i 's/font_size 16.0/font_size 12.0/' config/kitty/kitty.conf
# hyprlock matters
mv config/hypr/hyprlock.conf config/hypr/hyprlock-2k.conf &&
mv config/hypr/hyprlock-1080p.conf config/hypr/hyprlock.conf
# rofi fonts reduction
themes_dir="config/rofi/themes"
config_file="config/rofi/config.rasi"
# Change rofi font size
find "$themes_dir" -type f | while read -r file; do
if grep -Pzoq 'element-text {\n font: "JetBrainsMono Nerd Font SemiBold 12";\n}' "$file"; then
sed -i 's/font: "JetBrainsMono Nerd Font SemiBold 12"/font: "JetBrainsMono Nerd Font SemiBold 10"/' "$file"
fi
done
# Change rofi font size in ~/.config/rofi/config.rasi
if [ -f "$config_file" ]; then
if grep -Pzoq 'configuration {\n font: "JetBrainsMono Nerd Font SemiBold 13";\n}' "$config_file"; then
sed -i 's/font: "JetBrainsMono Nerd Font SemiBold 13"/font: "JetBrainsMono Nerd Font SemiBold 12"/' "$config_file"
fi
fi
fi
printf "\n%.0s" {1..1}
# Ask whether to change to 12hr format
while true; do
echo -e "${NOTE} ${SKY_BLUE} by default, hyprland-dotfiles is configured in 24H clock format."
read -p "$CAT do you want to change to 12H format or AM/PM format? (y/n): " answer
# Convert the answer to lowercase for comparison
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
# Check if the answer is valid
if [[ "$answer" == "y" ]]; then
# Modify waybar clock modules if 12hr is selected
# Clock 1
sed -i 's#^\(\s*\)//\("format": " {:%I:%M %p}",\) #\1\2 #g' config/waybar/Modules 2>&1 | tee -a "$LOG"
sed -i 's#^\(\s*\)\("format": " {:%H:%M:%S}",\) #\1//\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
# Clock 2
sed -i 's#^\(\s*\)\("format": " {:%H:%M}",\) #\1//\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
# Clock 3
sed -i 's#^\(\s*\)//\("format": "{:%I:%M %p - %d/%b}",\) #\1\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
sed -i 's#^\(\s*\)\("format": "{:%H:%M - %d/%b}",\) #\1//\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
# Clock 4
sed -i 's#^\(\s*\)//\("format": "{:%B | %a %d, %Y | %I:%M %p}",\) #\1\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
sed -i 's#^\(\s*\)\("format": "{:%B | %a %d, %Y | %H:%M}",\) #\1//\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
# Clock 5
sed -i 's#^\(\s*\)//\("format": "{:%A, %I:%M %P}",\) #\1\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
sed -i 's#^\(\s*\)\("format": "{:%a %d | %H:%M}",\) #\1//\2#g' config/waybar/Modules 2>&1 | tee -a "$LOG"
# for hyprlock
sed -i 's/^\s*text = cmd\[update:1000\] echo "\$(date +"%H")"/# &/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG"
sed -i 's/^\(\s*\)# *text = cmd\[update:1000\] echo "\$(date +"%I")" #AM\/PM/\1 text = cmd\[update:1000\] echo "\$(date +"%I")" #AM\/PM/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG"
sed -i 's/^\s*text = cmd\[update:1000\] echo "\$(date +"%S")"/# &/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG"
sed -i 's/^\(\s*\)# *text = cmd\[update:1000\] echo "\$(date +"%S %p")" #AM\/PM/\1 text = cmd\[update:1000\] echo "\$(date +"%S %p")" #AM\/PM/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG"
echo "${OK} 12H format set on waybar clocks successfully." 2>&1 | tee -a "$LOG"
# Function to apply 12H format to SDDM themes
apply_sddm_12h_format() {
local sddm_directory=$1
# Check if the directory exists
if [ -d "$sddm_directory" ]; then
echo "editing ${SKY_BLUE}$sddm_directory${RESET} to 12H format" 2>&1 | tee -a "$LOG"
sudo sed -i 's|^## HourFormat="hh:mm AP"|HourFormat="hh:mm AP"|' "$sddm_directory/theme.conf" 2>&1 | tee -a "$LOG" || true
sudo sed -i 's|^HourFormat="HH:mm"|## HourFormat="HH:mm"|' "$sddm_directory/theme.conf" 2>&1 | tee -a "$LOG" || true
fi
}
# Applying to different SDDM themes
apply_sddm_12h_format "/usr/share/sddm/themes/simple-sddm"
apply_sddm_12h_format "/usr/share/sddm/themes/simple-sddm-2"
# For SDDM (sequoia_2)
sddm_directory_3="/usr/share/sddm/themes/sequoia_2"
if [ -d "$sddm_directory_3" ]; then
echo "${YELLOW}sddm sequoia_2${RESET} theme exists. editing to 12H format" 2>&1 | tee -a "$LOG"
# Comment out the existing clockFormat="HH:mm" line
sudo sed -i 's|^clockFormat="HH:mm"|## clockFormat="HH:mm"|' "$sddm_directory_3/theme.conf" 2>&1 | tee -a "$LOG" || true
# Insert the new clockFormat="hh:mm AP" line if it's not already present
if ! grep -q 'clockFormat="hh:mm AP"' "$sddm_directory_3/theme.conf"; then
sudo sed -i '/^clockFormat=/a clockFormat="hh:mm AP"' "$sddm_directory_3/theme.conf" 2>&1 | tee -a "$LOG" || true
fi
echo "${OK} 12H format set to SDDM successfully." 2>&1 | tee -a "$LOG"
fi
break
elif [[ "$answer" == "n" ]]; then
echo "${NOTE} you chose not to change to 12H format." 2>&1 | tee -a "$LOG"
break # Exit the loop if the user chooses "n"
else
echo "${ERROR} invalid choice. please enter y for yes or n for no."
fi
done
2025-02-20 20:13:27 +00:00
printf "\n%.0s" {1..1}
# Check if the user wants to disable Rainbow borders
echo "${NOTE} ${SKY_BLUE}by default, rainbow borders animation is enabled"
echo "${WARN} however, this uses a bit more CPU and Memory resources."
read -p "${CAT} do you want to disable Rainbow Borders animation? (y/N): " border_choice
if [[ "$border_choice" =~ ^[Yy]$ ]]; then
mv config/hypr/UserScripts/RainbowBorders.sh config/hypr/UserScripts/RainbowBorders.bak.sh
sed -i '/exec-once = \$UserScripts\/RainbowBorders.sh \&/s/^/#/' config/hypr/UserConfigs/Startup_Apps.conf
sed -i '/^[[:space:]]*animation = borderangle, 1, 180, liner, loop/s/^/#/' config/hypr/UserConfigs/UserAnimations.conf
echo "${OK} rainbow borders are now disabled." 2>&1 | tee -a "$LOG"
else
echo "${NOTE} no changes made. rainbow borders remain enabled." 2>&1 | tee -a "$LOG"
fi
printf "\n%.0s" {1..1}
set -e