diff --git a/.gitignore b/.gitignore index c51f00c..e36bb3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ Install-Logs/* -!Install-Logs/.gitkeep \ No newline at end of file +!Install-Logs/.gitkeep + +faux-install-dir \ No newline at end of file diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..0f53831 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,4 @@ +# Notify shellcheck that we are sourcing external scripts +external-sources=true + +extended-analysis=true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87b351a..2d53fe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,7 @@ Thank you for your interest in contributing to KooL Hyprland Projects! We welcom - Update the **documentation** if necessary. - Add tests if applicable. - Make sure all tests pass or fully tested before submitting your changes. +- Use the `shellcheck` static analyzer or something similar for all scripts and minimize all warnings and eradicate errors. You cannot ignore warnings unless you have a good reason too. - Keep your pull request focused and avoid including unrelated changes. - Remember to follow the following files before submitting your changes. - [bug.yml](https://github.com/JaKooLit/Debian-Hyprland/blob/main/.github/ISSUE_TEMPLATE/bug.yml) - Use this template to create a report to help us improve. diff --git a/assets/yad_0.40.0-1+b2_amd64.deb b/assets/yad_0.40.0-1+b2_amd64.deb deleted file mode 100644 index 630b0d3..0000000 Binary files a/assets/yad_0.40.0-1+b2_amd64.deb and /dev/null differ diff --git a/assets/yad_7.2-1_amd64.deb b/assets/yad_7.2-1_amd64.deb new file mode 100644 index 0000000..7e30eaf Binary files /dev/null and b/assets/yad_7.2-1_amd64.deb differ diff --git a/auto-install.sh b/auto-install.sh index efb7610..16e0238 100644 --- a/auto-install.sh +++ b/auto-install.sh @@ -2,20 +2,23 @@ # 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)" -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)" +export MAGENTA="$(tput setaf 5)" +export YELLOW="$(tput setaf 226)" +export RED="$(tput setaf 1)" +export ORANGE="$(tput setaf 3)" +export GREEN="$(tput setaf 2)" +export BLUE="$(tput setaf 4)" +export SKY_BLUE="$(tput setaf 12)" +export GRAY="$(tput setaf 251)" +export GREY=$GRAY +export WARNING=$ORANGE +export RESET="$(tput sgr0)" +export OK="${GREEN}[OK]${RESET}" +export ERROR="${RED}[ERROR]${RESET}" +export NOTE="${GRAY}[NOTE]${RESET}" +export INFO="${BLUE}[INFO]${RESET}" +export WARN="${WARNING}[WARN]${RESET}" +export CAT="${SKY_BLUE}[ACTION]${RESET}" # Variables Distro="Debian-Hyprland" @@ -24,10 +27,9 @@ Distro_DIR="$HOME/$Distro" printf "\n%.0s" {1..1} -if ! command -v git &> /dev/null -then +if ! command -v git &>/dev/null; then echo "${INFO} Git not found! ${SKY_BLUE}Installing Git...${RESET}" - if ! sudo apt install -y git; then + if ! sudo apt install --assume-yes git; then echo "${ERROR} Failed to install Git. Exiting." exit 1 fi @@ -47,4 +49,4 @@ else cd "$Distro_DIR" || exit 1 chmod +x install.sh ./install.sh -fi \ No newline at end of file +fi diff --git a/install-scripts/00-dependencies.sh b/install-scripts/00-dependencies.sh index 3fd9bf1..275fb3d 100755 --- a/install-scripts/00-dependencies.sh +++ b/install-scripts/00-dependencies.sh @@ -3,7 +3,6 @@ # main dependencies # # 22 Aug 2024 - NOTE will trim this more down - # packages neeeded dependencies=( build-essential @@ -68,36 +67,44 @@ hyprland_dep=( ) build_dep=( - wlroots + wlroots ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source $SCRIPT_DIR/Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_dependencies.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_dependencies.log" # Installation of main dependencies -printf "\n%s - Installing ${SKY_BLUE}main dependencies....${RESET} \n" "${NOTE}" +echo -e "\n${NOTE} - Installing ${SKY_BLUE}main dependencies....${RESET}" for PKG1 in "${dependencies[@]}" "${hyprland_dep[@]}"; do - install_package "$PKG1" "$LOG" + install_package "$PKG1" "$LOG" done -printf "\n%.0s" {1..1} +newlines 1 for PKG1 in "${build_dep[@]}"; do - build_dep "$PKG1" "$LOG" + build_dep "$PKG1" "$LOG" done -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install-scripts/01-hypr-pkgs.sh b/install-scripts/01-hypr-pkgs.sh index fb0e738..4730a1c 100755 --- a/install-scripts/01-hypr-pkgs.sh +++ b/install-scripts/01-hypr-pkgs.sh @@ -1,7 +1,7 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # Hyprland-Dots Packages # -# edit your packages desired here. +# edit your packages desired here. # WARNING! If you remove packages here, dotfiles may not work properly. # and also, ensure that packages are present in Debian Official Repo @@ -60,10 +60,10 @@ hypr_package_2=( qalculate-gtk ) -# packages to force reinstall +# packages to force reinstall force=( - imagemagick - wayland-protocols + imagemagick + wayland-protocols ) # List of packages to uninstall as it conflicts with swaync or causing swaync to not function properly @@ -88,69 +88,88 @@ uninstall=( ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR=$SCRIPT_DIR/.. # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypr-pkgs.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_hypr-pkgs.log" # conflicting packages removal overall_failed=0 printf "\n%s - ${SKY_BLUE}Removing some packages${RESET} as it conflicts with KooL's Hyprland Dots \n" "${NOTE}" for PKG in "${uninstall[@]}"; do - uninstall_package "$PKG" 2>&1 | tee -a "$LOG" - if [ $? -ne 0 ]; then - overall_failed=1 - fi + ! uninstall_package "$PKG" 2>&1 | tee -a "$LOG" && overall_failed=1 done if [ $overall_failed -ne 0 ]; then - echo -e "${ERROR} Some packages failed to uninstall. Please check the log." + echo "${ERROR} Some packages failed to uninstall. Please check the log." fi -printf "\n%.0s" {1..1} +newlines 1 # Installation of main components printf "\n%s - Installing ${SKY_BLUE}KooL's hyprland necessary packages${RESET} .... \n" "${NOTE}" for PKG1 in "${hypr_package[@]}" "${hypr_package_2[@]}" "${Extra[@]}"; do - install_package "$PKG1" "$LOG" + install_package "$PKG1" "$LOG" done -printf "\n%.0s" {1..1} +newlines 1 for PKG2 in "${force[@]}"; do - re_install_package "$PKG2" "$LOG" + re_install_package "$PKG2" "$LOG" done -printf "\n%.0s" {1..1} -# install YAD from assets. NOTE This is downloaded from SID repo and sometimes +newlines 1 +# install YAD from assets. NOTE This is downloaded from EXPERIMENTAL repo and sometimes # Trixie is removing YAD for some strange reasons # Check if yad is installed -if ! command -v yad &> /dev/null; then - echo "${INFO} Installing ${YELLOW}YAD from assets${RESET} ..." - sudo dpkg -i assets/yad_0.40.0-1+b2_amd64.deb - sudo apt install -f -y - echo "${INFO} ${YELLOW}YAD from assets${RESET} succesfully installed ..." +if ! command -v yad &>/dev/null; then + echo "${INFO} Installing ${YELLOW}YAD from assets${RESET} ..." + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not installing yad=7.2-1_amd64 from $PARENT_DIR/assets/yad_7.2-1_amd64.deb" + else + verbose_log "Installing $PARENT_DIR/assets/yad_.2-1_amd64.deb with dpkg -i" + sudo dpkg -i assets/yad_7.2-1_amd64.deb + verbose_log "Attempting to fix broken packages just in case." + sudo apt install --fix-broken --assume-yes + echo "${INFO} ${YELLOW}YAD from assets${RESET} succesfully installed ..." + fi fi -printf "\n%.0s" {1..2} +newlines 2 -# Install up-to-date Rust -echo "${INFO} Installing most ${YELLOW}up to date Rust compiler${RESET} ..." -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 2>&1 | tee -a "$LOG" +if [[ $DRY -eq 1 ]]; then + echo "${NOTE} I am not installing the Rust compiler." +else + # Install up-to-date Rust + echo "${INFO} Installing most ${YELLOW}up to date Rust compiler${RESET} ..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 2>&1 | tee -a "$LOG" +fi +# shellcheck disable=SC1091 source "$HOME/.cargo/env" -## making brightnessctl work -sudo chmod +s "$(which brightnessctl)" 2>&1 | tee -a "$LOG" || true +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not setting setuid bit of $(which brightnessctl) executable." +else + ## making brightnessctl work + sudo chmod +s "$(which brightnessctl)" 2>&1 | tee -a "$LOG" || true +fi -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install-scripts/02-pre-cleanup.sh b/install-scripts/02-pre-cleanup.sh index 9864ac3..6deef5f 100755 --- a/install-scripts/02-pre-cleanup.sh +++ b/install-scripts/02-pre-cleanup.sh @@ -9,46 +9,66 @@ TARGET_DIR="/usr/local/bin" # Define packages to manually remove (was manually installed previously) PACKAGES=( - hyprctl - hyprpm - hyprland - Hyprland - cliphist - pypr - swappy - waybar - magick + hyprctl + hyprpm + hyprland + Hyprland + hyprwayland-scanner + hyprcursor-util + hyprland-update-screen + hyprland-dialog + hyprland-share-picker + hyprlock + hypridle + cliphist + pypr + swappy + waybar + magick ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR="$SCRIPT_DIR/.." +source "$SCRIPT_DIR/colors.sh" || { + echo "Failed to source $SCRIPT_DIR/colors.sh" + exit 1 +} + +source "$SCRIPT_DIR/parse_args.sh" || { + echo "${ERROR} Failed to source $SCRIPT_DIR/parse_args.sh" + exit 1 +} # Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } - -# Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_pre-clean-up.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_pre-clean-up.log" # Loop through the list of packages for PKG_NAME in "${PACKAGES[@]}"; do - # Construct the full path to the file - FILE_PATH="$TARGET_DIR/$PKG_NAME" + # Construct the full path to the file + FILE_PATH="$TARGET_DIR/$PKG_NAME" - # Check if the file exists - if [[ -f "$FILE_PATH" ]]; then - # Delete the file - sudo rm "$FILE_PATH" - echo "Deleted: $FILE_PATH" 2>&1 | tee -a "$LOG" - else - echo "File not found: $FILE_PATH" 2>&1 | tee -a "$LOG" - fi + # Check if the file exists + if [[ -f "$FILE_PATH" ]]; then + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not removing $FILE_PATH." + else + # Delete the file + sudo rm "$FILE_PATH" + echo "Deleted: $FILE_PATH" 2>&1 | tee -a "$LOG" + fi + else + echo "File not found: $FILE_PATH" 2>&1 | tee -a "$LOG" + fi done - -clear \ No newline at end of file diff --git a/install-scripts/03-Final-Check.sh b/install-scripts/03-Final-Check.sh index 259a9ee..0aca75c 100755 --- a/install-scripts/03-Final-Check.sh +++ b/install-scripts/03-Final-Check.sh @@ -4,59 +4,57 @@ # NOTE: These package checks are only the essentials packages=( - imagemagick - sway-notification-center - waybar - wl-clipboard - cliphist - wlogout - kitty - hyprland + imagemagick + sway-notification-center + waybar + wl-clipboard + cliphist + wlogout + kitty ) # Local packages that should be in /usr/local/bin/ local_pkgs_installed=( - rofi - hypridle - hyprlock - wallust + rofi + hypridle + hyprlock + hyprland + wallust ) local_pkgs_installed_2=( - swww + swww ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/00_CHECK-$(date +%d-%H%M%S)_installed.log" +LOG="$PARENT_DIR/Install-Logs/00_CHECK-$(date +%d-%H%M%S)_installed.log" -printf "\n%s - Final Check if Essential packages were installed \n" "${NOTE}" +echo -e "\n${NOTE} - Final Check if Essential packages were installed" # Initialize an empty array to hold missing packages missing=() local_missing=() local_missing_2=() -# Function to check if a package is installed using dpkg -is_installed_dpkg() { - dpkg -l | grep -q "^ii $1 " -} - # Loop through each package for pkg in "${packages[@]}"; do # Check if the package is installed via dpkg - if ! is_installed_dpkg "$pkg"; then + if ! check_if_installed_with_apt "$pkg"; then + verbose_log "Missing package $pkg that should be installed with apt or apt-like tools" missing+=("$pkg") fi done @@ -64,6 +62,7 @@ done # Check for local packages for pkg1 in "${local_pkgs_installed[@]}"; do if ! [ -f "/usr/local/bin/$pkg1" ]; then + verbose_log "Missing local package $pkg1 in /usr/local/bin" local_missing+=("$pkg1") fi done @@ -71,6 +70,7 @@ done # Check for local packages in /usr/bin for pkg2 in "${local_pkgs_installed_2[@]}"; do if ! [ -f "/usr/bin/$pkg2" ]; then + verbose_log "Missing local package $pkg2 in /usr/bin" local_missing_2+=("$pkg2") fi done @@ -83,7 +83,7 @@ else echo "${WARN} The following packages are not installed and will be logged:" for pkg in "${missing[@]}"; do echo "$pkg" - echo "$pkg" >> "$LOG" # Log the missing package to the file + echo "$pkg" >>"$LOG" # Log the missing package to the file done fi @@ -91,7 +91,7 @@ else echo "${WARN} The following local packages are missing from /usr/local/bin/ and will be logged:" for pkg1 in "${local_missing[@]}"; do echo "$pkg1 is not installed. can't find it in /usr/local/bin/" - echo "$pkg1" >> "$LOG" # Log the missing local package to the file + echo "$pkg1" >>"$LOG" # Log the missing local package to the file done fi @@ -99,10 +99,10 @@ else echo "${WARN} The following local packages are missing from /usr/bin/ and will be logged:" for pkg2 in "${local_missing_2[@]}"; do echo "$pkg2 is not installed. can't find it in /usr/bin/" - echo "$pkg2" >> "$LOG" # Log the missing local package to the file + echo "$pkg2" >>"$LOG" # Log the missing local package to the file done fi # Add a timestamp when the missing packages were logged - echo "${NOTE} Missing packages logged at $(date)" >> "$LOG" + echo "${NOTE} Missing packages logged at $(date)" >>"$LOG" fi diff --git a/install-scripts/Global_functions.sh b/install-scripts/Global_functions.sh index f522ad5..82dc9da 100755 --- a/install-scripts/Global_functions.sh +++ b/install-scripts/Global_functions.sh @@ -2,126 +2,442 @@ # 💫 https://github.com/JaKooLit 💫 # # Global Functions for Scripts # -set -e +set -euo pipefail +IFS=$'\n\t' -# 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)" +# See first comment of answer in https://stackoverflow.com/a/53183593 +# Get directory of this script +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR=$SCRIPT_DIR/.. + +source "$SCRIPT_DIR/colors.sh" || { + echo "Failed to source $SCRIPT_DIR/colors.sh" + exit 1 +} + +source "$SCRIPT_DIR/parse_args.sh" || { + echo "${RED} Failed to source $SCRIPT_DIR/parse_args.sh" + exit 1 +} # Create Directory for Install Logs -if [ ! -d Install-Logs ]; then - mkdir Install-Logs +if [[ $DRY -eq 0 && ! -d "$PARENT_DIR"/Install-Logs ]]; then + mkdir "$PARENT_DIR"/Install-Logs +elif [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not creating directory $PARENT_DIR/Install-Logs" fi +# Print $1 amount of newlines +newlines() { + for ((i = 1; i <= "$1"; i++)); do + printf "\n" + done +} + +# Verbose logging for when using the --verbose or -v option +verbose_log() { + if [[ "$VERBOSE" == 1 ]]; then + echo "${GRAY}[VERBOSE NOTE]${RESET} $1" + fi +} + +# Function to check if the system is Ubuntu +is_ubuntu() { + # Check for 'Ubuntu' in /etc/os-release + if grep -q 'Ubuntu' /etc/os-release; then + return 0 + fi + return 1 +} + +execute_script() { + local script="$1" + local script_path="$SCRIPT_DIR/$script" + if [ -f "$script_path" ]; then + verbose_log "Attempting to change permissions of file to be executable: $script_path" + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't make $script_path executable." + else + chmod +x "$script_path" + fi + if [ -x "$script_path" ]; then + verbose_log "Executing file: $script_path" + env "$script_path" + else + echo "${WARN} Failed to make script '$script' executable.${RESET}" | tee -a "$LOG" + fi + else + echo "${WARN} Script '$script' not found in '$SCRIPT_DIR'.${RESET}" | tee -a "$LOG" + fi +} + +# Function to load preset file +load_preset() { + echo "✅ Loading preset: $1" + # shellcheck source=../preset.sh + source "$1" || { + echo "${ERROR} Failed to execute $(realpath "$1")" + exit 1 + } +} + +# List of services to check for active login managers +services=("gdm.service" "gdm3.service" "lightdm.service" "lxdm.service") + +# Function to check if any login services are active +check_services_running() { + active_services=() # Array to store active services + for svc in "${services[@]}"; do + if systemctl is-active --quiet "$svc"; then + verbose_log "Adding $svc as an active service that should be inactive" + active_services+=("$svc") + fi + done + + verbose_log "Active services count: ${#active_services[@]}" + if [ ${#active_services[@]} -gt 0 ]; then + verbose_log "These interfering active services were found: $(printf "%s\n" "${active_services[@]}")" + return 1 + else + verbose_log "No notorious active services were found." + return 0 + fi +} + +# Check if package is installed with apt and friends (returns 0 if so and 1 if not) +check_if_installed_with_apt() { + # Reliable way to check if package is installed, with Perl regex to support lookaheads + apt list "$1" --installed | grep -qP '^[^\/]*(?=.*\[installed)' + return $? +} + # Show progress function show_progress() { local pid=$1 local package_name=$2 - local spin_chars=("●○○○○○○○○○" "○●○○○○○○○○" "○○●○○○○○○○" "○○○●○○○○○○" "○○○○●○○○○" \ - "○○○○○●○○○○" "○○○○○○●○○○" "○○○○○○○●○○" "○○○○○○○○●○" "○○○○○○○○○●") + local spin_chars=("●○○○○○○○○○" "○●○○○○○○○○" "○○●○○○○○○○" "○○○●○○○○○○" "○○○○●○○○○" "○○○○○●○○○○" "○○○○○○●○○○" "○○○○○○○●○○" "○○○○○○○○●○" "○○○○○○○○○●") local i=0 - tput civis + tput civis printf "\r${INFO} Installing ${YELLOW}%s${RESET} ..." "$package_name" - while ps -p "$pid" &> /dev/null; do + while ps -p "$pid" &>/dev/null; do printf "\r${INFO} Installing ${YELLOW}%s${RESET} %s" "$package_name" "${spin_chars[i]}" - i=$(( (i + 1) % 10 )) - sleep 0.3 + i=$(((i + 1) % 10)) + sleep 0.3 done printf "\r${INFO} Installing ${YELLOW}%s${RESET} ... Done!%-20s \n\n" "$package_name" "" - tput cnorm + tput cnorm } - # Function for installing packages with a progress bar -install_package() { - if dpkg -l | grep -q -w "$1" ; then - echo -e "${INFO} ${MAGENTA}$1${RESET} is already installed. Skipping..." - else - ( - stdbuf -oL sudo apt install -y "$1" 2>&1 - ) >> "$LOG" 2>&1 & - PID=$! - show_progress $PID "$1" - - # Double check if the package successfully installed - if dpkg -l | grep -q -w "$1"; then - echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully installed!" +install_package() { + if check_if_installed_with_apt "$1"; then + echo "${INFO} ${MAGENTA}$1${RESET} is already installed. Skipping..." else - echo -e "\e[1A\e[K${ERROR} ${YELLOW}$1${RESET} failed to install. Please check the install.log. You may need to install it manually. Sorry, I have tried :(" + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install $1 even though it is required." + else + # Install with apt but preserve apt markings. However, --mark-auto does not work, so this regexp workaround has to be used until the bug becomes fixed: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/2100937 + local markauto=0 + apt-mark showauto | grep -qP "^$1(:.+)?$" && { + verbose_log "Preserving apt marking for package $1" + markauto=1 + } + verbose_log "Installing $1 with sudo apt install --assume-yes $1" + ( + # Use stdbuf -oL for line buffering (append as lines go by instead of when it is all done) to the log file + stdbuf -oL sudo apt install --assume-yes "$1" 2>&1 + ) >>"$LOG" 2>&1 & + PID=$! + show_progress $PID "$1" + + # Double check if the package successfully installed + if check_if_installed_with_apt "$1"; then + echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully installed!" + else + echo -e "\e[1A\e[K${ERROR} ${YELLOW}$1${RESET} failed to install. Please check the install.log. You may need to install it manually. Sorry, I have tried :(" + fi + + [[ $markauto -eq 1 ]] && { + echo "${ACTION}Setting package $1 to auto to preserve its apt-mark status" + ( + sudo apt-mark auto "$1" 2>&1 + ) >>"$LOG" 2>&1 + } + fi fi - fi + verbose_log "Done with install_package $1" } -# Function for build depencies with a progress bar -build_dep() { - echo -e "${INFO} building dependencies for ${MAGENTA}$1${RESET} " - ( - stdbuf -oL sudo apt build-dep -y "$1" 2>&1 - ) >> "$LOG" 2>&1 & - PID=$! - show_progress $PID "$1" +# Short synonym for install_package function +apt_install() { + install_package "$@" +} + +# apt install --no-recommends +apt_install_no_recommends() { + if check_if_installed_with_apt "$1"; then + echo "${INFO} ${MAGENTA}$1${RESET} is already installed. Skipping..." + else + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install $1 even though it is required." + else + # Install with apt but preserve apt markings. However, --mark-auto does not work, so this regexp workaround has to be used until the bug becomes fixed: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/2100937 + local markauto=0 + apt-mark showauto | grep -qP "^$1(:.+)?$" && { + verbose_log "Preserving apt marking for package $1" + markauto=1 + } + verbose_log "Installing $1 with sudo apt install --no-install-recommends --assume-yes $1" + ( + # Use stdbuf -oL for line buffering (append as lines go by instead of when it is all done) to the log file + stdbuf -oL sudo apt install --no-install-recommends --assume-yes "$1" 2>&1 + ) >>"$LOG" 2>&1 & + PID=$! + show_progress $PID "$1" + + # Double check if the package successfully installed + if check_if_installed_with_apt "$1"; then + echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully installed!" + else + echo -e "\e[1A\e[K${ERROR} ${YELLOW}$1${RESET} failed to install. Please check the install.log. You may need to install it manually. Sorry, I have tried :(" + fi + + [[ $markauto -eq 1 ]] && { + echo "${ACTION}Setting package $1 to auto to preserve its apt-mark status" + ( + sudo apt-mark auto "$1" 2>&1 + ) >>"$LOG" 2>&1 + } + fi + fi +} + +# Function for build dependencies with a progress bar +build_dep() { + echo "${INFO} building dependencies for ${MAGENTA}$1${RESET} " + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install $1 even though it is required." + else + ( + stdbuf -oL sudo apt build-dep --assume-yes "$1" 2>&1 + ) >>"$LOG" 2>&1 & + PID=$! + show_progress $PID "$1" + fi } # Function for cargo install with a progress bar -cargo_install() { - echo -e "${INFO} installing ${MAGENTA}$1${RESET} using cargo..." - ( - stdbuf -oL cargo install "$1" 2>&1 - ) >> "$LOG" 2>&1 & - PID=$! - show_progress $PID "$1" +cargo_install() { + echo "${INFO} installing ${MAGENTA}$1${RESET} using cargo..." + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install $1 using cargo even though it is required." + else + ( + stdbuf -oL cargo install "$1" 2>&1 + ) >>"$LOG" 2>&1 & + PID=$! + show_progress $PID "$1" + fi } # Function for re-installing packages with a progress bar re_install_package() { - ( - stdbuf -oL sudo apt install --reinstall -y "$1" 2>&1 - ) >> "$LOG" 2>&1 & - - PID=$! - show_progress $PID "$1" - - if dpkg -l | grep -q -w "$1"; then - echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully re-installed!" + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't reinstall $1." else - # Package not found, reinstallation failed - echo -e "${ERROR} ${YELLOW}$1${RESET} failed to re-install. Please check the install.log. You may need to install it manually. Sorry, I have tried :(" + ( + stdbuf -oL sudo apt install --reinstall --assume-yes "$1" 2>&1 + ) >>"$LOG" 2>&1 & + + PID=$! + show_progress $PID "$1" + + if dpkg -l | grep -q -w "$1"; then + echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully re-installed!" + else + # Package not found, reinstallation failed + echo "${ERROR} ${YELLOW}$1${RESET} failed to re-install. Please check the install.log. You may need to install it manually. Sorry, I have tried :(" + fi fi } +# Short synonym for re_install_package function +apt_reinstall() { + re_install_package "$@" +} + # Function for removing packages uninstall_package() { - local pkg="$1" + local pkg="$1" - # Checking if package is installed - if sudo dpkg -l | grep -q -w "^ii $1" ; then - echo -e "${NOTE} removing $pkg ..." - # shellcheck disable=SC2024 - sudo apt autoremove -y "$1" >> "$LOG" 2>&1 | grep -v "error: target not found" - - if ! dpkg -l | grep -q -w "^ii $1" ; then - echo -e "\e[1A\e[K${OK} ${MAGENTA}$1${RESET} removed." + # Checking if package is installed + if sudo dpkg -l | grep -q -w "^ii $1"; then + echo "${NOTE} removing $pkg ..." + if [[ $PURGE -eq 1 ]]; then + if [[ $VERBOSE -eq 1 ]]; then + sudo apt autopurge --assume-yes "$1" | tee -a "$LOG" 2>&1 + else + sudo apt autopurge --assume-yes "$1" | tee -a "$LOG" 2>&1 | grep -v "error: target not found" + fi + else + if [[ $VERBOSE -eq 1 ]]; then + sudo apt autoremove --assume-yes "$1" | tee -a "$LOG" 2>&1 + else + sudo apt autoremove --assume-yes "$1" | tee -a "$LOG" 2>&1 | grep -v "error: target not found" + fi + fi + + if ! dpkg -l | grep -q -w "^ii $1"; then + echo -e "\e[1A\e[K${OK} ${MAGENTA}$1${RESET} removed." + else + echo -e "\e[1A\e[K${ERROR} $pkg Removal failed. No actions required." + return 1 + fi else - echo -e "\e[1A\e[K${ERROR} $pkg Removal failed. No actions required." - return 1 + echo "${INFO} Package $pkg not installed, skipping." fi - else - echo -e "${INFO} Package $pkg not installed, skipping." - fi - return 0 -} \ No newline at end of file + return 0 +} + +# Short synonym for uninstall_package function +apt_remove() { + uninstall_package "$@" +} + +remove_file() { + if [[ -f "$1" ]]; then + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} I am not removing $1" + else + verbose_log "Removing file $1" + if [[ $# -gt 1 && -n $2 ]]; then + rm "$1" 2>&1 | tee -a "$2" + else + rm "$1" 2>&1 + fi + fi + else + verbose_log "File $1 does not exist, so not removing it" + fi +} + +remove_dir() { + # Sanity checker + case $(realpath "$1") in + /) + echo "${ERROR} Attempting to remove root directory $1. Must be a bug in the code. Exiting..." + exit 1 + ;; + /usr | /usr/bin | /usr/local | /usr/local/bin | /etc | /home | /usr/lib | /usr/local/lib) + echo "${ERROR} Attempting to remove system directory $1. Must be a bug in the code. Exiting..." + exit 1 + ;; + *) + verbose_log "Directory $1 is probably safe to remove." + ;; + esac + + if [[ -d "$1" ]]; then + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} I am not removing the directory $1" + else + verbose_log "Forcibly and recursively removing the directory $1" + if [[ $# -gt 1 && -n $2 ]]; then + sudo rm -rf "$1" 2>&1 | tee -a "$2" + else + sudo rm -rf "$1" 2>&1 + fi + fi + else + verbose_log "Directory $1 does not exist, so not removing it" + fi +} + +# Essential function for automating building of repositories from hyprwm +# First arg: release version, second arg: name of repository, third arg: "cmake_build", "hyprland-qt-support", "hyprwayland-scanner", or "meson" build type, fourth arg: "cmake" or "meson" installation type, fifth arg: repository name (defaults to hyprwm) +build_from_git() { + local install_prefix="/usr/local" + # Change install_prefix to --dry-run-dir's value + [[ $DRY -eq 1 ]] && install_prefix=$PARENT_DIR/faux-install-dir + [[ $DRY_RUN_DIR_SET -eq 1 ]] && install_prefix=$DRY_RUN_DIR + + SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + + # Change the working directory to the parent directory of the script + PARENT_DIR="$SCRIPT_DIR/.." + + #specific branch or release + release="$1" + + cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 + } + + # Set the name of the log file to include the current date and time + LOG="Install-Logs/install-$(date +%d-%H%M%S)_$2.log" + MLOG="install-$(date +%d-%H%M%S)_$2.log" + + # Check if directory exists and remove it + remove_dir "$2" + + # Clone and build + echo "${INFO} Installing ${YELLOW}$2 $release${RESET} ..." + if [[ $NO_BUILD -eq 1 ]]; then + echo "${NOTE} I am not cloning $2 and building it." + else + local name="hyprwm" + [[ $# -gt 4 && -n $5 ]] && name=$5 + if git clone --recursive -b "$release" "https://github.com/$name/$2.git"; then + cd "$2" || exit 1 + + case "$3" in + cmake_build) + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH="$install_prefix" -S . -B ./build + cmake --build ./build --config Release --target "$2" -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" + ;; + hyprland-qt-support) + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH="$install_prefix" -DINSTALL_QML_PREFIX=/lib/x86_64-linux-gnu/qt6/qml -S . -B ./build + cmake --build ./build --config Release --target all -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" + ;; + hyprwayland-scanner) + cmake -DCMAKE_INSTALL_PREFIX="$install_prefix" -B build + cmake --build build -j "$(nproc)" + ;; + meson) + meson setup --prefix="$install_prefix" build + ;; + esac + + case "$4" in + cmake) + sudo cmake --install ./build 2>&1 | tee -a "$MLOG" + ;; + meson) + sudo meson install -C ./build 2>&1 | tee -a "$MLOG" + ;; + esac + + if $?; then + echo "${OK} ${MAGENTA}$2 $release${RESET} installed successfully." 2>&1 | tee -a "$MLOG" + else + echo "${ERROR} Installation failed for ${YELLOW}$2 $release${RESET}" 2>&1 | tee -a "$MLOG" + fi + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not moving $MLOG to $PARENT_DIR/Install-Logs/ with mv" + else + #moving the addional logs to Install-Logs directory + mv "$MLOG" "$PARENT_DIR"/Install-Logs/ || true + fi + cd .. + else + echo "${ERROR} Download failed for ${YELLOW}$2 $release${RESET}" 2>&1 | tee -a "$LOG" + fi + fi + + newlines 2 +} diff --git a/install-scripts/InputGroup.sh b/install-scripts/InputGroup.sh index afe0fc8..cb8e285 100755 --- a/install-scripts/InputGroup.sh +++ b/install-scripts/InputGroup.sh @@ -3,17 +3,17 @@ # Adding users into input group # ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} # Set the name of the log file to include the current date and time LOG="Install-Logs/install-$(date +%d-%H%M%S)_input.log" @@ -23,12 +23,20 @@ if grep -q '^input:' /etc/group; then echo "${OK} ${MAGENTA}input${RESET} group exists." else echo "${NOTE} ${MAGENTA}input${RESET} group doesn't exist. Creating ${MAGENTA}input${RESET} group..." - sudo groupadd input - echo "${MAGENTA}input${RESET} group created" >> "$LOG" + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not adding the nonexistent group, input, with sudo groupadd" + else + sudo groupadd input + fi + echo "${MAGENTA}input${RESET} group created" >>"$LOG" fi -# Add the user to the 'input' group -sudo usermod -aG input "$(whoami)" -echo "${OK} ${YELLOW}user${RESET} added to the ${MAGENTA}input${RESET} group. Changes will take effect after you log out and log back in." >> "$LOG" +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE}Not adding $(whoami) to the input group with sudo usermod -aG" +else + # Add the user to the 'input' group + sudo usermod -aG input "$(whoami)" + echo "${OK} ${YELLOW}user${RESET} added to the ${MAGENTA}input${RESET} group. Changes will take effect after you log out and log back in." >>"$LOG" +fi -printf "\n%.0s" {1..2} \ No newline at end of file +newlines 2 diff --git a/install-scripts/ags.sh b/install-scripts/ags.sh index 9d7b6d5..9d71118 100755 --- a/install-scripts/ags.sh +++ b/install-scripts/ags.sh @@ -3,16 +3,16 @@ # Aylur's GTK Shell # ags=( - node-typescript - npm - meson - libgjs-dev - gjs - libgtk-layer-shell-dev + node-typescript + npm + meson + libgjs-dev + gjs + libgtk-layer-shell-dev libgtk-3-dev - libpam0g-dev - libpulse-dev - libdbusmenu-gtk3-dev + libpam0g-dev + libpulse-dev + libdbusmenu-gtk3-dev libsoup-3.0-dev ) @@ -28,17 +28,24 @@ build_dep=( ags_tag="v1.9.0" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR=$SCRIPT_DIR/.. # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time LOG="Install-Logs/install-$(date +%d-%H%M%S)_ags.log" @@ -46,64 +53,76 @@ MLOG="install-$(date +%d-%H%M%S)_ags2.log" # Check if AGS is installed if command -v ags &>/dev/null; then - AGS_VERSION=$(ags -v | awk '{print $NF}') + AGS_VERSION=$(ags -v | awk '{print $NF}') if [[ "$AGS_VERSION" == "1.9.0" ]]; then - printf "${INFO} ${MAGENTA}Aylur's GTK Shell v1.9.0${RESET} is already installed. Skipping installation." - printf "\n%.0s" {1..2} + echo "${INFO} ${MAGENTA}Aylur's GTK Shell v1.9.0${RESET} is already installed. Skipping installation." + newlines 1 exit 0 fi fi # Installation of main components -printf "\n%s - Installing ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET} Dependencies \n" "${INFO}" +newlines 1 +echo "${INFO} - Installing ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET} Dependencies" # Installing ags Dependencies for PKG1 in "${ags[@]}"; do - install_package "$PKG1" "$LOG" + install_package "$PKG1" "$LOG" done for force_ags in "${f_ags[@]}"; do - re_install_package "$force_ags" 2>&1 | tee -a "$LOG" - done - -printf "\n%.0s" {1..1} - -for PKG1 in "${build_dep[@]}"; do - build_dep "$PKG1" "$LOG" + re_install_package "$force_ags" 2>&1 | tee -a "$LOG" done -#install typescript by npm -sudo npm install --global typescript 2>&1 | tee -a "$LOG" +newlines 1 + +for PKG1 in "${build_dep[@]}"; do + build_dep "$PKG1" "$LOG" +done + +if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not installing typescript with npm install --global" | tee -a "$LOG" +else + #install typescript by npm + sudo npm install --global typescript 2>&1 | tee -a "$LOG" +fi # ags v1 -printf "${NOTE} Install and Compiling ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET}..\n" +echo "${NOTE} Install and Compiling ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET}.." # Check if directory exists and remove it if [ -d "ags" ]; then - printf "${NOTE} Removing existing ags directory...\n" - rm -rf "ags" + echo "${NOTE} Removing existing ags directory..." + remove_dir "ags" "$LOG" fi -printf "\n%.0s" {1..1} -printf "${INFO} Kindly Standby...cloning and compiling ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET}...\n" -printf "\n%.0s" {1..1} -# Clone repository with the specified tag and capture git output into MLOG -if git clone --depth=1 https://github.com/JaKooLit/ags_v1.9.0.git; then - cd ags_v1.9.0 || exit 1 - npm install - meson setup build - if sudo meson install -C build 2>&1 | tee -a "$MLOG"; then - printf "\n${OK} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "\n${ERROR} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} Installation failed\n " 2>&1 | tee -a "$MLOG" - fi - # Move logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. +newlines 1 +echo "${INFO} Kindly Standby...cloning and compiling ${SKY_BLUE}Aylur's GTK shell $ags_tag${RESET}..." +newlines 1 + +if [[ $NO_BUILD -eq 1 ]]; then + echo "${NOTE} Not cloning or building ags" else - echo -e "\n${ERROR} Failed to download ${YELLOW}Aylur's GTK shell $ags_tag${RESET} Please check your connection\n" 2>&1 | tee -a "$LOG" - mv "$MLOG" ../Install-Logs/ || true - exit 1 + # Clone repository with the specified tag and capture git output into MLOG + if git clone --depth=1 https://github.com/JaKooLit/ags_v1.9.0.git; then + cd "$PARENT_DIR"/ags_v1.9.0 || exit 1 + npm install + meson setup build + if sudo meson install -C build 2>&1 | tee -a "$MLOG"; then + newlines 1 + echo "${OK} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} installed successfully." 2>&1 | tee -a "$MLOG" + else + newlines 1 + echo "${ERROR} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} Installation failed" 2>&1 | tee -a "$MLOG" + fi + # Move logs to Install-Logs directory + mv "$MLOG" "$PARENT_DIR"/Install-Logs/ || true + cd .. + else + echo -e "\n${ERROR} Failed to download ${YELLOW}Aylur's GTK shell $ags_tag${RESET} Please check your connection\n" 2>&1 | tee -a "$LOG" + mv "$MLOG" "$PARENT_DIR"/Install-Logs/ || true + exit 1 + fi fi -printf "\n%.0s" {1..2} \ No newline at end of file +newlines 2 diff --git a/install-scripts/aquamarine.sh b/install-scripts/aquamarine.sh index 201471d..42d8df3 100755 --- a/install-scripts/aquamarine.sh +++ b/install-scripts/aquamarine.sh @@ -2,51 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # aquamarine # - #specific branch or release -lang_tag="v0.8.0" +aquamarine_tag="v0.8.0" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_aquamarine.log" -MLOG="install-$(date +%d-%H%M%S)_aquamarine2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}aquamarine dependencies${RESET} .... \n" "${INFO}" - -# Check if aquamarine directory exists and remove it -if [ -d "aquamarine" ]; then - rm -rf "aquamarine" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}aquamarine $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/aquamarine.git; then - cd aquamarine || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target aquamarine -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}aquamarine $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}aquamarine $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}aquamarine $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi - -printf "\n%.0s" {1..2} +build_from_git $aquamarine_tag "aquamarine" "cmake_build" "cmake" diff --git a/install-scripts/bluetooth.sh b/install-scripts/bluetooth.sh index f342210..2d5b968 100755 --- a/install-scripts/bluetooth.sh +++ b/install-scripts/bluetooth.sh @@ -3,33 +3,44 @@ # Bluetooth # blue=( - bluez - blueman + bluez + blueman ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR=$SCRIPT_DIR/.. # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_bluetooth.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_bluetooth.log" # Bluetooth -printf "${NOTE} Installing ${SKY_BLUE}Bluetooth${RESET} Packages...\n" - for BLUE in "${blue[@]}"; do - install_package "$BLUE" "$LOG" - done +echo "${NOTE} Installing ${SKY_BLUE}Bluetooth${RESET} Packages..." +for BLUE in "${blue[@]}"; do + install_package "$BLUE" "$LOG" +done -printf " Activating ${YELLOW}Bluetooth${RESET} Services...\n" -sudo systemctl enable --now bluetooth.service 2>&1 | tee -a "$LOG" +echo " Activating ${YELLOW}Bluetooth${RESET} Services..." +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not enabling service bluetooth.service with systemctl enable --now" +else + sudo systemctl enable --now bluetooth.service 2>&1 | tee -a "$LOG" +fi -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install-scripts/colors.sh b/install-scripts/colors.sh new file mode 100755 index 0000000..138e78d --- /dev/null +++ b/install-scripts/colors.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# shellcheck disable=SC2155 + +set -a + +# Header guard because it is useless to execute the rest of this so many times +[[ -v SOURCED_COLORS ]] && return +SOURCED_COLORS= + +# Set some colors for output messages +MAGENTA="$(tput setaf 5)" +YELLOW="$(tput setaf 226)" +RED="$(tput setaf 1)" +ORANGE="$(tput setaf 3)" +GREEN="$(tput setaf 2)" +BLUE="$(tput setaf 4)" +SKY_BLUE="$(tput setaf 12)" +GRAY="$(tput setaf 251)" +GREY=$GRAY +WARNING=$ORANGE +RESET="$(tput sgr0)" +OK="${GREEN}[OK]${RESET}" +ERROR="${RED}[ERROR]${RESET}" +NOTE="${GRAY}[NOTE]${RESET}" +INFO="${BLUE}[INFO]${RESET}" +WARN="${WARNING}[WARN]${RESET}" +CAT="${SKY_BLUE}[ACTION]${RESET}" + +set +a diff --git a/install-scripts/dotfiles-branch.sh b/install-scripts/dotfiles-branch.sh index b1baac3..fb3e432 100755 --- a/install-scripts/dotfiles-branch.sh +++ b/install-scripts/dotfiles-branch.sh @@ -6,35 +6,48 @@ dots_tag="Deb-Untu-Dots" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source $SCRIPT_DIR/Global_functions.sh" + exit 1 +} # Check if Hyprland-Dots exists -printf "${NOTE} Cloning and Installing ${SKY_BLUE}KooL's Hyprland Dots for Debian${RESET}....\n" +echo "${NOTE} Cloning and Installing ${SKY_BLUE}KooL's Hyprland Dots for Debian${RESET}...." # Check if Hyprland-Dots exists if [ -d Hyprland-Dots-Debian ]; then - cd Hyprland-Dots-Debian || exit - git stash && git pull - chmod +x copy.sh - ./copy.sh + cd Hyprland-Dots-Debian || exit + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I am not stashing and pulling the already existing $PARENT_DIR/Hyprland-Dots-Debian directory or copying KooL's Hyprland Dots." + else + git stash && git pull + chmod +x copy.sh + ./copy.sh + fi else - if git clone --depth=1 -b $dots_tag https://github.com/JaKooLit/Hyprland-Dots Hyprland-Dots-Debian; then - cd Hyprland-Dots-Debian || exit 1 - chmod +x copy.sh - ./copy.sh - else - echo -e "$ERROR Can't download ${YELLOW}KooL's Hyprland-Dots-Debian${RESET}" - fi + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I am not fetching KooL's Hyprland-Dots-Debian repository or copying those files." + else + if git clone --depth=1 -b $dots_tag https://github.com/JaKooLit/Hyprland-Dots Hyprland-Dots-Debian; then + cd Hyprland-Dots-Debian || exit 1 + chmod +x copy.sh + ./copy.sh + else + echo -e "$ERROR Can't download ${YELLOW}KooL's Hyprland-Dots-Debian${RESET}" + fi + fi fi -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install-scripts/fonts.sh b/install-scripts/fonts.sh index af29604..e02b84a 100755 --- a/install-scripts/fonts.sh +++ b/install-scripts/fonts.sh @@ -3,38 +3,45 @@ # Fonts Required # fonts=( - fonts-firacode - fonts-font-awesome - fonts-noto - fonts-noto-cjk - fonts-noto-color-emoji + fonts-firacode + fonts-font-awesome + fonts-noto + fonts-noto-cjk + fonts-noto-color-emoji ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +PARENT_DIR=$SCRIPT_DIR/.. # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_fonts.log" - +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_fonts.log" # Installation of main components -printf "\n%s - Installing necessary ${SKY_BLUE}fonts${RESET}.... \n" "${NOTE}" +newlines 1 +echo "${NOTE} - Installing necessary ${SKY_BLUE}fonts${RESET}...." for PKG1 in "${fonts[@]}"; do - install_package "$PKG1" "$LOG" + install_package "$PKG1" "$LOG" done -printf "\n%.0s" {1..2} +newlines 2 # jetbrains nerd font. Necessary for waybar DOWNLOAD_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.tar.xz" @@ -47,34 +54,46 @@ for ((ATTEMPT = 1; ATTEMPT <= MAX_ATTEMPTS; ATTEMPT++)); do done # Check if the JetBrainsMono directory exists and delete it if it does -if [ -d ~/.local/share/fonts/JetBrainsMonoNerd ]; then - rm -rf ~/.local/share/fonts/JetBrainsMonoNerd 2>&1 | tee -a "$LOG" -fi +remove_dir ~/.local/share/fonts/JetBrainsMonoNerd "$LOG" -mkdir -p ~/.local/share/fonts/JetBrainsMonoNerd 2>&1 | tee -a "$LOG" -# Extract the new files into the JetBrainsMono directory and log the output -tar -xJkf JetBrainsMono.tar.xz -C ~/.local/share/fonts/JetBrainsMonoNerd 2>&1 | tee -a "$LOG" - -# Fantasque Mono Nerd Font -if wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/FantasqueSansMono.zip; then - mkdir -p "$HOME/.local/share/fonts/FantasqueSansMonoNerd" && unzip -o -q "FantasqueSansMono.zip" -d "$HOME/.local/share/fonts/FantasqueSansMono" && echo "FantasqueSansMono installed successfully" | tee -a "$LOG" +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE}Not creating ~/.local/share/fonts/JetBrainsMonoNerd or extracting $PARENT_DIR/JetBrainsMonoNerd.tar.xz to that directory." else - echo -e "\n${ERROR} Failed to download ${YELLOW}Fantasque Sans Mono Nerd Font${RESET} Please check your connection\n" | tee -a "$LOG" + mkdir -p ~/.local/share/fonts/JetBrainsMonoNerd 2>&1 | tee -a "$LOG" + # Extract the new files into the JetBrainsMono directory and log the output + tar -xJkf "$PARENT_DIR"/JetBrainsMono.tar.xz -C ~/.local/share/fonts/JetBrainsMonoNerd 2>&1 | tee -a "$LOG" fi -# Victor Mono-Font -if wget -q https://rubjo.github.io/victor-mono/VictorMonoAll.zip; then - mkdir -p "$HOME/.local/share/fonts/VictorMono" && unzip -o -q "VictorMonoAll.zip" -d "$HOME/.local/share/fonts/VictorMono" && echo "Victor Font installed successfully" | tee -a "$LOG" +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not installing Fantasque Mono Nerd Font." else - echo -e "\n${ERROR} Failed to download ${YELLOW}Victor Mono Font${RESET} Please check your connection\n" | tee -a "$LOG" + # Fantasque Mono Nerd Font + if wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/FantasqueSansMono.zip; then + mkdir -p "$HOME/.local/share/fonts/FantasqueSansMonoNerd" && unzip -o -q "FantasqueSansMono.zip" -d "$HOME/.local/share/fonts/FantasqueSansMono" && echo "FantasqueSansMono installed successfully" | tee -a "$LOG" + else + echo -e "\n${ERROR} Failed to download ${YELLOW}Fantasque Sans Mono Nerd Font${RESET} Please check your connection\n" | tee -a "$LOG" + fi fi -# Update font cache and log the output -fc-cache -v 2>&1 | tee -a "$LOG" - -# clean up -if [ -d "JetBrainsMono.tar.xz" ]; then - rm -r JetBrainsMono.tar.xz 2>&1 | tee -a "$LOG" +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not installing Victor Mono-Font" +else + # Victor Mono-Font + if wget -q https://rubjo.github.io/victor-mono/VictorMonoAll.zip; then + mkdir -p "$HOME/.local/share/fonts/VictorMono" && unzip -o -q "VictorMonoAll.zip" -d "$HOME/.local/share/fonts/VictorMono" && echo "Victor Font installed successfully" | tee -a "$LOG" + else + echo -e "\n${ERROR} Failed to download ${YELLOW}Victor Mono Font${RESET} Please check your connection\n" | tee -a "$LOG" + fi fi -printf "\n%.0s" {1..2} +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE}Not updating the font cache with fc-cache" +else + # Update font cache and log the output + fc-cache -v 2>&1 | tee -a "$LOG" +fi + +# clean up +remove_file "$PARENT_DIR"/JetBrainsMono.tar.xz "$LOG" + +newlines 2 diff --git a/install-scripts/gtk_themes.sh b/install-scripts/gtk_themes.sh index d740485..e7ff396 100755 --- a/install-scripts/gtk_themes.sh +++ b/install-scripts/gtk_themes.sh @@ -8,43 +8,56 @@ engine=( ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time LOG="Install-Logs/install-$(date +%d-%H%M%S)_themes.log" - # installing engine needed for gtk themes +verbose_log "Installing dependencies for gtk themes" for PKG1 in "${engine[@]}"; do install_package "$PKG1" "$LOG" done # Check if the directory exists and delete it if present -if [ -d "GTK-themes-icons" ]; then - echo "$NOTE GTK themes and Icons directory exist..deleting..." 2>&1 | tee -a "$LOG" - rm -rf "GTK-themes-icons" 2>&1 | tee -a "$LOG" -fi +remove_dir "GTK-themes-icons" echo "$NOTE Cloning ${SKY_BLUE}GTK themes and Icons${RESET} repository..." 2>&1 | tee -a "$LOG" -if git clone --depth=1 https://github.com/JaKooLit/GTK-themes-icons.git ; then - ( - cd GTK-themes-icons || exit 1 - chmod +x auto-extract.sh - ./auto-extract.sh - ) - echo "$OK Extracted GTK Themes & Icons to ~/.icons & ~/.themes directories" 2>&1 | tee -a "$LOG" +if [[ $NO_BUILD -eq 1 ]]; then + echo "${NOTE} Not cloning or building https://github.com/JaKooLit/GTK-themes-icons.git" else - echo "$ERROR Download failed for GTK themes and Icons.." 2>&1 | tee -a "$LOG" + if git clone --depth=1 https://github.com/JaKooLit/GTK-themes-icons.git; then + ( + cd GTK-themes-icons || exit 1 + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not running auto-extract.sh or setting it to be executable as we do not want to modify files" + else + chmod +x auto-extract.sh + ./auto-extract.sh + fi + ) + echo "$OK Extracted GTK Themes & Icons to ~/.icons & ~/.themes directories" 2>&1 | tee -a "$LOG" + else + echo "$ERROR Download failed for GTK themes and Icons.." 2>&1 | tee -a "$LOG" + fi fi -printf "\n%.0s" {1..2} \ No newline at end of file +newlines 2 diff --git a/install-scripts/hyprcursor.sh b/install-scripts/hyprcursor.sh index a693d22..a8e9fd1 100755 --- a/install-scripts/hyprcursor.sh +++ b/install-scripts/hyprcursor.sh @@ -2,51 +2,23 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprcursor # - #specific branch or release -lang_tag="v0.1.12" +hyprcursor_tag="v0.1.12" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprcursor.log" -MLOG="install-$(date +%d-%H%M%S)_hyprcursor2.log" +execute_script "hyprlang.sh" # Depends on hyprutils +sleep 1 -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprcursor dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprcursor directory exists and remove it -if [ -d "hyprcursor" ]; then - rm -rf "hyprcursor" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprcursor $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprcursor.git; then - cd hyprcursor || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target all -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprcursor $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprcursor $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprcursor $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprcursor" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprcursor_tag "hyprcursor" "cmake_build" "cmake" diff --git a/install-scripts/hyprgraphics.sh b/install-scripts/hyprgraphics.sh index 7212fd3..7ae4b7e 100755 --- a/install-scripts/hyprgraphics.sh +++ b/install-scripts/hyprgraphics.sh @@ -2,51 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprgraphics # - #specific branch or release -lang_tag="v0.1.3" +hyprgraphics_tag="v0.1.3" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprgraphics.log" -MLOG="install-$(date +%d-%H%M%S)_hyprgraphics2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprgraphics dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprgraphics directory exists and remove it -if [ -d "hyprgraphics" ]; then - rm -rf "hyprgraphics" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprgraphics $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprgraphics.git; then - cd hyprgraphics || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target hyprgraphics -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprgraphics $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprgraphics $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprgraphics $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprgraphics" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprgraphics_tag "hyprgraphics" "cmake_build" "cmake" diff --git a/install-scripts/hypridle.sh b/install-scripts/hypridle.sh index bc2570c..f5b3814 100755 --- a/install-scripts/hypridle.sh +++ b/install-scripts/hypridle.sh @@ -7,57 +7,33 @@ idle=( ) #specific branch or release -idle_tag="v0.1.6" +hypridle_tag="v0.1.6" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypridle.log" -MLOG="install-$(date +%d-%H%M%S)_hypridle2.log" +LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypridle_install_dependencies.log" # Installation of dependencies printf "\n%s - Installing ${YELLOW}hypridle dependencies${RESET} .... \n" "${INFO}" for PKG1 in "${idle[@]}"; do - re_install_package "$PKG1" 2>&1 | tee -a "$LOG" - if [ $? -ne 0 ]; then - echo -e "\e[1A\e[K${ERROR} - ${YELLOW}$PKG1${RESET} Package installation failed, Please check the installation logs" - exit 1 - fi + re_install_package "$PKG1" 2>&1 | tee -a "$LOG" + if ! re_install_package "$PKG1" 2>&1 | tee -a "$LOG"; then + echo -e "\e[1A\e[K${ERROR} - ${YELLOW}$PKG1${RESET} Package installation failed, Please check the installation logs" + exit 1 + fi done -# Check if hypridle directory exists and remove it -if [ -d "hypridle" ]; then - rm -rf "hypridle" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hypridle $idle_tag${RESET} ...\n" -if git clone --recursive -b $idle_tag https://github.com/hyprwm/hypridle.git; then - cd hypridle || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build - cmake --build ./build --config Release --target hypridle -j"$(nproc 2>/dev/null || getconf NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hypridle $idle_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hypridle $idle_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hypridle $idle_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hypridle" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hypridle_tag "hypridle" "cmake_build" "cmake" diff --git a/install-scripts/hyprland-protocols.sh b/install-scripts/hyprland-protocols.sh index 69af7cd..4b4b6d5 100755 --- a/install-scripts/hyprland-protocols.sh +++ b/install-scripts/hyprland-protocols.sh @@ -2,50 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprland-protocols # - #specific branch or release -lang_tag="v0.6.4" +hyprland_protocols_tag="v0.6.4" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprland-protocols.log" -MLOG="install-$(date +%d-%H%M%S)_hyprland-protocols2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprland-protocols dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprland-protocols directory exists and remove it -if [ -d "hyprland-protocols" ]; then - rm -rf "hyprland-protocols" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprland-protocols $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprland-protocols.git; then - cd hyprland-protocols || exit 1 - meson setup build - if sudo meson install -C ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprland-protocols $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprland-protocols $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprland-protocols $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprland-protocols" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprland_protocols_tag "hyprland-protocols" "meson" "meson" diff --git a/install-scripts/hyprland-qt-support.sh b/install-scripts/hyprland-qt-support.sh index 276a505..4aaadb4 100755 --- a/install-scripts/hyprland-qt-support.sh +++ b/install-scripts/hyprland-qt-support.sh @@ -2,51 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprland-qt-support # - #specific branch or release -lang_tag="v0.1.0" +hyprland_qt_support="v0.1.0" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprland-qt-support.log" -MLOG="install-$(date +%d-%H%M%S)_hyprland-qt-support2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprland-qt-support dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprland-qt-support directory exists and remove it -if [ -d "hyprland-qt-support" ]; then - rm -rf "hyprland-qt-support" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprland-qt-support $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprland-qt-support.git; then - cd hyprland-qt-support || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINSTALL_QML_PREFIX=/usr/lib/x86_64-linux-gnu/qt6/qml -S . -B ./build - cmake --build ./build --config Release --target all -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprland-qt-support $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprland-qt-support $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprland-qt-support $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprland-qt-support" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprland_qt_support "hyprland-qt-support" "hyprland-qt-support" "cmake" diff --git a/install-scripts/hyprland-qtutils.sh b/install-scripts/hyprland-qtutils.sh index 636a976..a58331a 100755 --- a/install-scripts/hyprland-qtutils.sh +++ b/install-scripts/hyprland-qtutils.sh @@ -2,51 +2,23 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprland-qtutils # - #specific branch or release -lang_tag="v0.1.4" +hyprland_qtutils_tag="v0.1.4" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprland-qtutils.log" -MLOG="install-$(date +%d-%H%M%S)_hyprland-qtutils2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprland-qtutils dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprland-qtutils directory exists and remove it -if [ -d "hyprland-qtutils" ]; then - rm -rf "hyprland-qtutils" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprland-qtutils $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprland-qtutils.git; then - cd hyprland-qtutils || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target all -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprland-qtutils $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprland-qtutils $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprland-qtutils $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprland-qtutils" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprland_qtutils_tag "hyprland-qtutils" "cmake_build" "cmake" diff --git a/install-scripts/hyprland.sh b/install-scripts/hyprland.sh index f75db6b..9177662 100755 --- a/install-scripts/hyprland.sh +++ b/install-scripts/hyprland.sh @@ -2,51 +2,40 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprland # - #specific branch or release -lang_tag="v0.49.0" +hyprland_tag="v0.49.0" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprland.log" -MLOG="install-$(date +%d-%H%M%S)_hyprland2.log" +verbose_log "Need to build hyprland dependencies from source first." +# Dependencies +execute_script "hyprcursor.sh" # Depends on hyprlang +sleep 1 +execute_script "hyprgraphics.sh" +sleep 1 +execute_script "hyprland-qt-support.sh" +sleep 1 +execute_script "hyprland-qtutils.sh" +sleep 1 +execute_script "hyprwayland-scanner.sh" +sleep 1 +execute_script "aquamarine.sh" +sleep 1 +execute_script "hyprland-protocols.sh" +sleep 1 +execute_script "hypridle.sh" +sleep 1 +execute_script "hyprlock.sh" -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprland dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprland directory exists and remove it -if [ -d "hyprland" ]; then - rm -rf "hyprland" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprland $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprland.git; then - cd hyprland || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target all -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprland $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprland $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprland $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprland" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprland_tag "hyprland" "cmake_build" "cmake" diff --git a/install-scripts/hyprlang.sh b/install-scripts/hyprlang.sh index 9913f24..42c7913 100755 --- a/install-scripts/hyprlang.sh +++ b/install-scripts/hyprlang.sh @@ -2,51 +2,23 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprlang # - #specific branch or release -lang_tag="v0.6.3" +hyprlang_tag="v0.6.3" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprlang.log" -MLOG="install-$(date +%d-%H%M%S)_hyprlang2.log" +execute_script "hyprutils.sh" # Order is very specific for dependencies are scattered +sleep 1 -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprlang dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprlang directory exists and remove it -if [ -d "hyprlang" ]; then - rm -rf "hyprlang" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprlang $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprlang.git; then - cd hyprlang || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target hyprlang -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprlang $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprlang $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprlang $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprlang" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprlang_tag "hyprlang" "cmake_build" "cmake" diff --git a/install-scripts/hyprlock.sh b/install-scripts/hyprlock.sh index c1d7bdc..ba73f56 100755 --- a/install-scripts/hyprlock.sh +++ b/install-scripts/hyprlock.sh @@ -3,61 +3,45 @@ # hyprlock # lock=( - libpam0g-dev - libgbm-dev - libdrm-dev + libpam0g-dev + libgbm-dev + libdrm-dev libmagic-dev libsdbus-c++-dev ) #specific branch or release -lock_tag="v0.8.2" +hyprlock_tag="v0.8.2" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprlock.log" -MLOG="install-$(date +%d-%H%M%S)_hyprlock2.log" +LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprlock_install_dependencies.log" # Installation of dependencies printf "\n%s - Installing ${YELLOW}hyprlock dependencies${RESET} .... \n" "${INFO}" for PKG1 in "${lock[@]}"; do - re_install_package "$PKG1" "$LOG" + re_install_package "$PKG1" "$LOG" done -# Check if hyprlock directory exists and remove it -if [ -d "hyprlock" ]; then - rm -rf "hyprlock" -fi - -# Clone and build hyprlock -printf "${INFO} Installing ${YELLOW}hyprlock $lock_tag${RESET} ...\n" -if git clone --recursive -b $lock_tag https://github.com/hyprwm/hyprlock.git; then - cd hyprlock || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build - cmake --build ./build --config Release --target hyprlock -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${YELLOW}hyprlock $lock_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprlock $lock_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprlock $lock_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprlock" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprlock_tag "hyprlock" "cmake_build" "cmake" diff --git a/install-scripts/hyprutils.sh b/install-scripts/hyprutils.sh index 3929392..7f7269e 100755 --- a/install-scripts/hyprutils.sh +++ b/install-scripts/hyprutils.sh @@ -2,51 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprutils # - #specific branch or release -lang_tag="v0.7.1" +hyprutils_tag="v0.7.1" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprutils.log" -MLOG="install-$(date +%d-%H%M%S)_hyprutils2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprutils dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprutils directory exists and remove it -if [ -d "hyprutils" ]; then - rm -rf "hyprutils" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprutils $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprutils.git; then - cd hyprutils || exit 1 - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target hyprutils -j"$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprutils $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprutils $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprutils $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprutils" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprutils_tag "hyprutils" "cmake_build" "cmake" diff --git a/install-scripts/hyprwayland-scanner.sh b/install-scripts/hyprwayland-scanner.sh index 02f4363..2613307 100755 --- a/install-scripts/hyprwayland-scanner.sh +++ b/install-scripts/hyprwayland-scanner.sh @@ -2,51 +2,20 @@ # 💫 https://github.com/JaKooLit 💫 # # hyprwayland-scanner # - #specific branch or release -lang_tag="v0.4.4" +hyprwayland_scanner_tag="v0.4.4" ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} -# Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_hyprwayland-scanner.log" -MLOG="install-$(date +%d-%H%M%S)_hyprwayland-scanner2.log" - -# Installation of dependencies -printf "\n%s - Installing ${YELLOW}hyprwayland-scanner dependencies${RESET} .... \n" "${INFO}" - -# Check if hyprwayland-scanner directory exists and remove it -if [ -d "hyprwayland-scanner" ]; then - rm -rf "hyprwayland-scanner" -fi - -# Clone and build -printf "${INFO} Installing ${YELLOW}hyprwayland-scanner $lang_tag${RESET} ...\n" -if git clone --recursive -b $lang_tag https://github.com/hyprwm/hyprwayland-scanner.git; then - cd hyprwayland-scanner || exit 1 - cmake -DCMAKE_INSTALL_PREFIX=/usr -B build - cmake --build build -j "$(nproc)" - if sudo cmake --install ./build 2>&1 | tee -a "$MLOG" ; then - printf "${OK} ${MAGENTA}hyprwayland-scanner $lang_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" - else - echo -e "${ERROR} Installation failed for ${YELLOW}hyprwayland-scanner $lang_tag${RESET}" 2>&1 | tee -a "$MLOG" - fi - #moving the addional logs to Install-Logs directory - mv "$MLOG" ../Install-Logs/ || true - cd .. -else - echo -e "${ERROR} Download failed for ${YELLOW}hyprwayland-scanner $lang_tag${RESET}" 2>&1 | tee -a "$LOG" -fi -rm -rf "hyprwayland-scanner" # Cleanup -printf "\n%.0s" {1..2} +build_from_git $hyprwayland_scanner_tag "hyprwayland-scanner" "hyprwayland-scanner" "cmake" diff --git a/install-scripts/nvidia.sh b/install-scripts/nvidia.sh index 401adf2..cbf4443 100755 --- a/install-scripts/nvidia.sh +++ b/install-scripts/nvidia.sh @@ -4,53 +4,81 @@ # UBUNTU USERS, FOLLOW README! nvidia_pkg=( - nvidia-driver - firmware-misc-nonfree - nvidia-kernel-dkms - linux-headers-"$(uname -r)" - libnvidia-egl-wayland1 - libva-wayland2 - libnvidia-egl-wayland1 - nvidia-vaapi-driver + nvidia-driver + firmware-misc-nonfree + nvidia-kernel-dkms + linux-headers-"$(uname -r)" + libnvidia-egl-wayland1 + libva-wayland2 + libnvidia-egl-wayland1 + nvidia-vaapi-driver ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time LOG="Install-Logs/install-$(date +%d-%H%M%S)_nvidia.log" MLOG="install-$(date +%d-%H%M%S)_nvidia2.log" -## adding the deb source for nvidia driver -# Create a backup of the sources.list file -sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup 2>&1 | tee -a "$LOG" +if [[ $DRY -eq 1 ]]; then + echo "Not creating /etc/apt/sources.list.d/sid.sources to fetch packages from Debian Sid (unstable)" +else + ## adding the deb source for nvidia driver + # Create a backup of the sources.list file + if [[ -f /etc/apt/sources.list.d/sid.sources ]]; then + verbose_log "Copying /etc/apt/sources.list.d/sid.sources to /etc/apt/sources.list.d/sid.sources.backup with sudo cp -a since /etc/apt/sources.list.d/sid.sources exists" + sudo cp -a /etc/apt/sources.list.d/sid.sources /etc/apt/sources.list.d/sid.sources.backup 2>&1 | tee -a "$LOG" + else + verbose_log "/etc/apt/sources.list.d/sid.sources nonexistent, so not backing up with cp" + fi -## UBUNTU - NVIDIA (comment this two by adding # you dont need this!) -# Add the comment and repository entry to sources.list -echo "## for nvidia" | sudo tee -a /etc/apt/sources.list 2>&1 | tee -a "$LOG" -echo "deb http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware" | sudo tee -a /etc/apt/sources.list 2>&1 | tee -a "$LOG" + ## UBUNTU - NVIDIA (comment this nine by adding # you don't need this!) + # Add the comment and repository entry to sources.list + echo "## for nvidia" | sudo tee -a /etc/apt/sources.list.d/sid.sources 2>&1 | tee -a "$LOG" + cat "/etc/apt/sources.list.d/sid.sources" <> '$config_file'" + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not adding $value to $config_file" + else + sudo sh -c "echo '$value' >> '$config_file'" + fi else echo "$value is already present in $config_file." fi @@ -58,52 +86,68 @@ add_to_file() { # Install additional Nvidia packages printf "${YELLOW} Installing ${SKY_BLUE}Nvidia packages${RESET} ...\n" - for NVIDIA in "${nvidia_pkg[@]}"; do +for NVIDIA in "${nvidia_pkg[@]}"; do install_package "$NVIDIA" "$LOG" - done +done # adding additional nvidia-stuff printf "${YELLOW} adding ${SKY_BLUE}nvidia-stuff${RESET} to /etc/default/grub..." - # Additional options to add to GRUB_CMDLINE_LINUX - additional_options="rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rcutree.rcu_idle_gp_delay=1" +# Additional options to add to GRUB_CMDLINE_LINUX +additional_options="rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rcutree.rcu_idle_gp_delay=1" - # Check if additional options are already present in GRUB_CMDLINE_LINUX - if grep -q "GRUB_CMDLINE_LINUX.*$additional_options" /etc/default/grub; then +# Check if additional options are already present in GRUB_CMDLINE_LINUX +if grep -q "GRUB_CMDLINE_LINUX.*$additional_options" /etc/default/grub; then echo "GRUB_CMDLINE_LINUX already contains the additional options" - else - # Append the additional options to GRUB_CMDLINE_LINUX - sudo sed -i "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"$additional_options /" /etc/default/grub - echo "Added the additional options to GRUB_CMDLINE_LINUX" - fi +else + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not adding 'rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rcutree.rcu_idle_gp_delay=1' to GRUB_CMDLINE_LINUX in /etc/default/grub" + else + # Append the additional options to GRUB_CMDLINE_LINUX + sudo sed -i "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"$additional_options /" /etc/default/grub + echo "Added the additional options to GRUB_CMDLINE_LINUX" + fi +fi - # Update GRUB configuration - sudo update-grub 2>&1 | tee -a "$LOG" - - # Define the configuration file and the line to add - config_file="/etc/modprobe.d/nvidia.conf" - line_to_add=""" +if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not updating GRUB configuration with sudo update-grub" +else + # Update GRUB configuration + sudo update-grub 2>&1 | tee -a "$LOG" +fi + +# Define the configuration file and the line to add +config_file="/etc/modprobe.d/nvidia.conf" +line_to_add=""" options nvidia-drm modeset=1 fbdev=1 options nvidia NVreg_PreserveVideoMemoryAllocations=1 """ - # Check if the config file exists - if [ ! -e "$config_file" ]; then - echo "Creating $config_file" +# Check if the config file exists +if [ ! -e "$config_file" ]; then + echo "Creating $config_file" + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not creating $config_file with touch" + else sudo touch "$config_file" 2>&1 | tee -a "$LOG" fi +fi - add_to_file "$config_file" "$line_to_add" +add_to_file "$config_file" "$line_to_add" - # Add NVIDIA modules to initramfs configuration - modules_to_add="nvidia nvidia_modeset nvidia_uvm nvidia_drm" - modules_file="/etc/initramfs-tools/modules" +# Add NVIDIA modules to initramfs configuration +modules_to_add="nvidia nvidia_modeset nvidia_uvm nvidia_drm" +modules_file="/etc/initramfs-tools/modules" - if [ -e "$modules_file" ]; then +if [ -e "$modules_file" ]; then add_to_file "$modules_file" "$modules_to_add" 2>&1 | tee -a "$LOG" - sudo update-initramfs -u 2>&1 | tee -a "$LOG" - else + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not updating initramfs with sudo update-initramfs -uk all" + else + sudo update-initramfs -uk all 2>&1 | tee -a "$LOG" + fi +else echo "Modules file ($modules_file) not found." 2>&1 | tee -a "$LOG" - fi +fi -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install-scripts/parse_args.sh b/install-scripts/parse_args.sh new file mode 100755 index 0000000..536721f --- /dev/null +++ b/install-scripts/parse_args.sh @@ -0,0 +1,254 @@ +#!/bin/bash +# Helper file for parsing arguments, exposing only the parse_args function and important argument variables +# Argument parsing is for install.sh though + +set -aeuo pipefail +IFS=$'\n\t' + +# Header guard since this should be executed only once +[[ -v SOURCED_PARSE_ARGS ]] && return +SOURCED_PARSE_ARGS= + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +source "$SCRIPT_DIR/colors.sh" || { + echo "Failed to source colors.sh" + exit 1 +} + +# Define main argument variables + +if [[ ! -v VERBOSE ]]; then + VERBOSE=0 + DRY=0 + DRY_RUN_DIR_SET=0 + DRY_RUN_DIR="" + PEDANTIC_DRY=0 + NO_BUILD=0 + PRESET="" + PRESET_ENABLED=0 + PURGE=0 +fi + +# Parse arguments by passing "$@" to this for ./install.sh +parse_args() { + # Are there no arguments? If so, this is a useless function + if [[ $# -eq 0 ]]; then return; fi + + # Define argument parsing options + LONGOPTS=help,verbose,dry-run,dry-run-dir:,pedantic-dry-run,no-build,preset: + SHORTOPTS=hvd:p: + + # Print help message + print_help() { + echo "Usage: $0 [-hv] [-d DRY_RUN_DIR] [-p PRESET] [--dry-run] [--dry-run-dir DRY_RUN_DIR] [--pedantic-dry-run] [--help] [--verbose]" + echo "[--preset PRESET]" + echo "Run the install script for KooL's automated install of Hyprland for Debian Trixie/Sid." + echo + echo "${WARNING}Please be sure to backup your system before running this script as it will" + echo "FORCIBLY INSTALL AND REMOVE packages WITHOUT user intervention.${RESET}" + echo "PLEASE NOTE: Run this script from the directory this script is in." + echo + echo " -h, --help display this help message and exit successfully" + echo " -v, --verbose be loud and verbose; output many debugging messages" + echo + echo "The following section is intended for developers:" + echo "Additionally, they are designed to try not to modify files outside this script's directory." + echo " --dry-run do a dry run by installing to a test dir, specified with" + echo "the --dry-run-dir option; aka don't possibly break your system. Do note, apt packages will be" + echo "installed for this script, but the Install-Logs directory will not be created if nonexistent." + echo " -d, --dry-run-dir=DRY_RUN_DIR specify directory to do the dry run installation into;" + echo "defaults to this script's directory's faux-install-dir directory, which will be" + echo "automatically created. Specify DRY_RUN_DIR to install there instead, but you have to create the" + echo "directory yourself. Can only be used when using the --dry-run option" + echo " --pedantic-dry-run absolutely do not install apt packages, so assuming you have" + echo "them all. Also do not synchronize package index files with sudo apt update. Attempts to not modify" + echo "any file except for building. Overrides --dry-run" + echo "option, and the same rules for --dry-run-dir or -d applies." + echo " --no-build don't build anything from source. Can only be used with either" + echo "the --dry-run/-d or --pedantic-dry-run options. This will probably cause the script to fail." + echo + echo + echo " -p, --preset=PRESET specify preset file, which can be, for example, preset.sh in" + echo "the Debian-Hyprland directory. See that preset.sh file for details." + echo " --purge When removing packages, purge (delete all configuration files)" + echo "them. Dangerous if you want to keep them. This also purges autoremoved packages." + echo + echo "Hint: You do not have to specify the whole argument name as getopt tries to fill the rest in, unless" + echo "what was entered is ambiguous. Example: --pedantic-dr is synonymous with --pedantic-dry-run." + echo + echo "View repository and complain about bugs to: " + } + + # Function to test if GNU's enhanced getopt works + parse_args_setup() { + ENHANCED_GETOPT=1 + + # Temporarily disable Bash from exiting if command has error + set +e + # Test if GNU's enhanced getopt exists + getopt --test 2>/dev/null + if [[ $? -ne 4 ]]; then + echo "${GRAY}I require GNU's enhanced getopt to parse arguments." + echo "You can continue without parsing arguments or install util-linux," + echo "which should have been installed on Debian.${RESET}" + ENHANCED_GETOPT=0 + fi + # Back to being strict + set -e + + if [[ "$ENHANCED_GETOPT" == 0 ]]; then + read -rp "Would you like to continue without parsing arguments? [y/N]: " confirm + case "$confirm" in + [yY][eE][sS] | [yY]) + echo "${OK} Ignoring arguments and continuing installation..." + ;; + *) + echo "${NOTE} You chose not to continue. Exiting..." + exit 1 + ;; + esac + fi + } + + # Specfically check for help and verbose argument first to allow verbosity for everything even if option is not in order + parse_first_args() { + if [[ "$ENHANCED_GETOPT" == 1 ]]; then + if ! PARSED=$(getopt --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "$0" -- "$@"); then + echo "${ERROR} Failed to use getopt to parse arguments! Exiting with atypical error code 2..." + exit 2 + fi + + eval set -- "${PARSED}" + + while [[ $# -gt 0 ]]; do + case $1 in + -h | --help) + print_help + exit 0 + ;; + -v | --verbose) + VERBOSE=1 + echo "${CAT} Enabled verbose mode." + ;; + esac + shift + done + fi + } + + # Check validity and saneness of arguments + check_sane_arguments() { + if [[ $DRY -eq 1 && $PEDANTIC_DRY -eq 1 ]]; then + echo "${INFO} --pedantic-dry-run overrides the --dry-run option, so also enabling dry run mode." + DRY=1 + fi + + # When dry and pedantic dry are both disabled + if [[ $DRY -eq 0 && $PEDANTIC_DRY -eq 0 ]]; then + if [[ $DRY_RUN_DIR_SET -eq 1 ]]; then + echo "${WARN} Ignoring --dry-run-dir option as the --dry-run or --pedantic-dry-run option is not enabled." + DRY_RUN_DIR_SET=0 + elif [[ $NO_BUILD -eq 1 ]]; then + echo "${WARN} Ignoring --no-build option as the --dry-run or --pedantic-dry-run option is not enabled." + NO_BUILD=0 + fi + fi + + if [[ $DRY -eq 1 && $DRY_RUN_DIR_SET -eq 0 ]]; then + echo "${WARN} Using ${WORKING_DIR}/faux-install-dir since --dry-run-dir was not set." + DRY_RUN_DIR="$WORKING_DIR"/faux-install-dir + verbose_log "DRY_RUN_DIR is now ${DRY_RUN_DIR}" + fi + + # If DRY_RUN_DIR_SET is 1, which means --dry-run-dir or -d was passed as an argument, and DRY_RUN_DIR is not a directory + if [[ $DRY_RUN_DIR_SET -eq 1 && (! -d "$DRY_RUN_DIR") ]]; then + echo "${ERROR} --dry-run-dir option set to $DRY_RUN_DIR is not a valid directory. Exiting..." + exit 1 + fi + + # If PRESET_ENABLED is 1, which means --preset or -p was passed as an argument, and PRESET is a file that does not exist + if [[ $PRESET_ENABLED -eq 1 ]]; then + if [[ ! -f "$PRESET" ]]; then + PRESET_ENABLED=0 + echo "${WARN} ⚠️ Preset file not found or invalid: $PRESET. Using default values." + else + PRESET_ENABLED=1 + verbose_log "PRESET_ENABLED set to 1 as PRESET, $PRESET, is a file that exists." + fi + else + verbose_log "Not using preset since --preset was not specified" + fi + + if [[ $DRY -eq 1 && $PURGE -eq 1 ]]; then + echo "${WARN} Purge mode will not have any real effect with dry or pedantic dry mode." + fi + } + + parse_args_setup + + # Time to handle arguments (or not if system does not support GNU's enhanced getopt or no arguments were passed) + if [[ $ENHANCED_GETOPT -eq 1 ]]; then + parse_first_args "$@" + + if ! PARSED=$(getopt --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "$0" -- "$@"); then + echo "${ERROR} Failed to use getopt to parse arguments! Exiting with atypical error code 2..." + exit 2 + fi + verbose_log "Parsed with getopt: $PARSED" + + eval set -- "${PARSED}" + + while [[ $# -gt 0 ]]; do + verbose_log "Met argument $1" + case $1 in + -h | --help) + # Already handled in parse_first_args local function, so this is a noop for reference + ;; + -v | --verbose) + # Already handled in parse_first_args local function, so this is a noop for reference + ;; + --dry-run) + DRY=1 + verbose_log "Using dry run mode (does not install to system but to custom directory)" + ;; + -d | --dry-run-dir) + shift 1 + DRY_RUN_DIR_SET=1 + DRY_RUN_DIR="$(realpath "$1")" + verbose_log "Setting DRY_RUN_DIR to $(realpath "$1")" + ;; + --pedantic-dry-run) + PEDANTIC_DRY=1 + echo "${NOTE} Using pedantic dry run mode, which will ${RED}NOT${RESET} install any packages but only build from source, even if you are missing apt packages. Use the --help or -h option for more info." + ;; + --no-build) + NO_BUILD=1 + echo "${NOTE} Using no build mode, which ${RED}DISABLES${RESET} building anything from source." + ;; + -p | --preset) + shift 1 + PRESET_ENABLED=1 + PRESET="$(realpath "$1")" + verbose_log "Setting PRESET to $(realpath "$1")" + ;; + --purge) + shift 1 + PURGE=1 + verbose_log + ;; + --) + # For some reason, this option is always present when using getopt, so this is a noop + ;; + *) + echo "${WARN} Ignoring positional argument: $1" + ;; + esac + shift # Move to next argument + done + + check_sane_arguments + fi + # End of arguments complaining and shenanigans with https://gist.github.com/mcnesium/bbfe60e4f43554cbc2880f2e7085956d used for help +} +set +a diff --git a/install-scripts/sddm.sh b/install-scripts/sddm.sh index fd79030..c804c39 100755 --- a/install-scripts/sddm.sh +++ b/install-scripts/sddm.sh @@ -4,81 +4,110 @@ # installing with NO-recommends sddm1=( - sddm + sddm ) sddm2=( - qt6-5compat-dev - qml6-module-qt5compat-graphicaleffects - qt6-declarative-dev - qt6-svg-dev + qt6-5compat-dev + qml6-module-qt5compat-graphicaleffects + qt6-declarative-dev + qt6-svg-dev ) # login managers to attempt to disable login=( - lightdm - gdm3 - gdm - lxdm - lxdm-gtk3 + lightdm + gdm3 + gdm + lxdm + lxdm-gtk3 ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Change the working directory to the parent directory of the script PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time LOG="Install-Logs/install-$(date +%d-%H%M%S)_sddm.log" - # Install SDDM (no-recommends) printf "\n%s - Installing ${SKY_BLUE}SDDM and dependencies${RESET} .... \n" "${NOTE}" -for PKG1 in "${sddm1[@]}" ; do - sudo apt install --no-install-recommends -y "$PKG1" | tee -a "$LOG" +for PKG1 in "${sddm1[@]}"; do + apt_install_no_recommends "$PKG1" done # Installation of additional sddm stuff for PKG2 in "${sddm2[@]}"; do - install_package "$PKG2" "$LOG" + install_package "$PKG2" "$LOG" done # Check if other login managers are installed and disable their service before enabling SDDM for login_manager in "${login[@]}"; do - if dpkg -l | grep -q "^ii $login_manager"; then - echo "Disabling $login_manager..." - # shellcheck disable=SC2024 - sudo systemctl disable "$login_manager.service" >> "$LOG" 2>&1 || echo "Failed to disable $login_manager" >> "$LOG" - echo "$login_manager disabled." - fi + if dpkg -l | grep -q "^ii $login_manager"; then + echo "Disabling $login_manager..." + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not disabling $login_manager.service with systemctl disable" + else + sudo systemctl disable "$login_manager.service" | tee -a "$LOG" 2>&1 || echo "Failed to disable $login_manager" >>"$LOG" + fi + echo "$login_manager disabled." + fi done # Double check with systemctl for manager in "${login[@]}"; do - if systemctl is-active --quiet "$manager.service" > /dev/null 2>&1; then - echo "$manager.service is active, disabling it..." >> "$LOG" 2>&1 - # shellcheck disable=SC2024 - sudo systemctl disable "$manager.service" --now >> "$LOG" 2>&1 || echo "Failed to disable $manager.service" >> "$LOG" - else - echo "$manager.service is not active" >> "$LOG" 2>&1 - fi + if systemctl is-active --quiet "$manager.service" >/dev/null 2>&1; then + echo "$manager.service is active, disabling it..." >>"$LOG" 2>&1 + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not disabling \"$manager.service\" with systemctl disable --now" >>"$LOG" 2>&1 + else + sudo systemctl disable "$manager.service" --now | tee -a "$LOG" 2>&1 || echo "Failed to disable $manager.service" >>"$LOG" + fi + else + echo "$manager.service is not active" >>"$LOG" 2>&1 + fi done -printf "\n%.0s" {1..1} -printf "${INFO} Activating sddm service........\n" -sudo systemctl set-default graphical.target 2>&1 | tee -a "$LOG" -sudo systemctl enable sddm.service 2>&1 | tee -a "$LOG" +newlines 1 +echo "${INFO} Activating sddm service........" +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not setting graphical.target to be default or enabling sddm.service" +else + sudo systemctl set-default graphical.target 2>&1 | tee -a "$LOG" + sudo systemctl enable sddm.service 2>&1 | tee -a "$LOG" +fi wayland_sessions_dir=/usr/share/wayland-sessions -[ ! -d "$wayland_sessions_dir" ] && { printf "$CAT - $wayland_sessions_dir not found, creating...\n"; sudo mkdir -p "$wayland_sessions_dir" 2>&1 | tee -a "$LOG"; } -sudo cp assets/hyprland.desktop "$wayland_sessions_dir/" 2>&1 | tee -a "$LOG" +[ ! -d "$wayland_sessions_dir" ] && { + echo "$CAT - $wayland_sessions_dir not found, creating..." + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not making directory $wayland_sessions_dir with mkdir -p" + else + sudo mkdir -p "$wayland_sessions_dir" 2>&1 | tee -a "$LOG" + fi +} -printf "\n%.0s" {1..2} \ No newline at end of file +if [[ $DRY -eq 1 ]]; then + echo "${NOTE} Not copying assets/hyprland.desktop to $wayland_sessions_dir/ with cp" +else + sudo cp assets/hyprland.desktop "$wayland_sessions_dir/" 2>&1 | tee -a "$LOG" +fi + +newlines 2 diff --git a/install-scripts/wallust.sh b/install-scripts/wallust.sh index c8affdf..e8e205d 100755 --- a/install-scripts/wallust.sh +++ b/install-scripts/wallust.sh @@ -3,23 +3,28 @@ # wallust - pywal colors replacement # wallust=( - wallust + wallust ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} + +cd "$PARENT_DIR" || { + echo "${ERROR} Failed to change directory to $PARENT_DIR" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_wallust.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_wallust.log" # Create log directory if it doesn't exist mkdir -p "$(dirname "$LOG")" @@ -27,29 +32,29 @@ mkdir -p "$(dirname "$LOG")" # Install up-to-date Rust echo "${INFO} Installing most ${YELLOW}up to date Rust compiler${RESET} ..." curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 2>&1 | tee -a "$LOG" +# shellcheck disable=SC1091 source "$HOME/.cargo/env" -printf "\n%.0s" {1..2} +newlines 2 # Remove any existing Wallust binary if [[ -f "/usr/local/bin/wallust" ]]; then echo "Removing existing Wallust binary..." 2>&1 | tee -a "$LOG" - sudo rm "/usr/local/bin/wallust" + remove_file "/usr/local/bin/wallust" fi -printf "\n%.0s" {1..2} +newlines 2 # Install Wallust using Cargo for WALL in "${wallust[@]}"; do - cargo_install "$WALL" "$LOG" - if [ $? -eq 0 ]; then + if cargo_install "$WALL" "$LOG"; then echo "${OK} ${MAGENTA}Wallust${RESET} installed successfully." | tee -a "$LOG" else echo "${ERROR} Installation of ${MAGENTA}$WALL${RESET} failed. Check the log file $LOG for details." | tee -a "$LOG" exit 1 fi done -printf "\n%.0s" {1..1} +newlines 1 # Move the newly compiled binary to /usr/local/bin echo "Moving Wallust binary to /usr/local/bin..." | tee -a "$LOG" if sudo mv "$HOME/.cargo/bin/wallust" /usr/local/bin 2>&1 | tee -a "$LOG"; then @@ -59,5 +64,4 @@ else exit 1 fi - -printf "\n%.0s" {1..2} \ No newline at end of file +printf "\n%.0s" {1..2} diff --git a/install-scripts/zsh.sh b/install-scripts/zsh.sh index 3660912..9efd6a8 100755 --- a/install-scripts/zsh.sh +++ b/install-scripts/zsh.sh @@ -3,100 +3,100 @@ # Zsh and Oh my Zsh + Optional Pokemon ColorScripts# zsh=( - lsd - zsh - mercurial - zplug + lsd + zsh + mercurial + zplug ) ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# Change the working directory to the parent directory of the script -PARENT_DIR="$SCRIPT_DIR/.." -cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; } +set -euo pipefail +IFS=$'\n\t' + +SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") # Source the global functions script -if ! source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"; then - echo "Failed to source Global_functions.sh" - exit 1 -fi +source "$SCRIPT_DIR/Global_functions.sh" || { + echo "Failed to source Global_functions.sh" + exit 1 +} # Set the name of the log file to include the current date and time -LOG="Install-Logs/install-$(date +%d-%H%M%S)_zsh.log" +LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_zsh.log" # Check if the log file already exists, if yes, append a counter to make it unique COUNTER=1 while [ -f "$LOG" ]; do - LOG="Install-Logs/install-$(date +%d-%H%M%S)_${COUNTER}_zsh.log" - ((COUNTER++)) + LOG="$PARENT_DIR/Install-Logs/install-$(date +%d-%H%M%S)_${COUNTER}_zsh.log" + ((COUNTER++)) done # Installing zsh packages -printf "${NOTE} Installing core zsh packages...${RESET}\n" +echo "${NOTE} Installing core zsh packages..." for ZSHP in "${zsh[@]}"; do - install_package "$ZSHP" + install_package "$ZSHP" done -printf "\n%.0s" {1..1} +newlines 1 # Install Oh My Zsh, plugins, and set zsh as default shell if command -v zsh >/dev/null; then - printf "${NOTE} Installing ${SKY_BLUE}Oh My Zsh and plugins${RESET} ...\n" - if [ ! -d "$HOME/.oh-my-zsh" ]; then - sh -c "$(curl -fsSL https://install.ohmyz.sh)" "" --unattended - else - echo "${INFO} Directory .oh-my-zsh already exists. Skipping re-installation." 2>&1 | tee -a "$LOG" - fi - - # Check if the directories exist before cloning the repositories - if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]; then - git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions - else - echo "${INFO} Directory zsh-autosuggestions already exists. Cloning Skipped." 2>&1 | tee -a "$LOG" - fi + echo "${NOTE} Installing ${SKY_BLUE}Oh My Zsh and plugins${RESET} ..." + if [ ! -d "$HOME/.oh-my-zsh" ]; then + sh -c "$(curl -fsSL https://install.ohmyz.sh)" "" --unattended + else + echo "${INFO} Directory .oh-my-zsh already exists. Skipping re-installation." 2>&1 | tee -a "$LOG" + fi - if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]; then - git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting - else - echo "${INFO} Directory zsh-syntax-highlighting already exists. Cloning Skipped." 2>&1 | tee -a "$LOG" - fi - - # Check if ~/.zshrc and .zprofile exists, create a backup, and copy the new configuration - if [ -f "$HOME/.zshrc" ]; then - cp -b "$HOME/.zshrc" "$HOME/.zshrc-backup" || true - fi + # Check if the directories exist before cloning the repositories + if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]; then + git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"/plugins/zsh-autosuggestions + else + echo "${INFO} Directory zsh-autosuggestions already exists. Cloning Skipped." 2>&1 | tee -a "$LOG" + fi - if [ -f "$HOME/.zprofile" ]; then - cp -b "$HOME/.zprofile" "$HOME/.zprofile-backup" || true - fi - - # Copying the preconfigured zsh themes and profile - cp -r 'assets/.zshrc' ~/ - cp -r 'assets/.zprofile' ~/ + if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]; then + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"/plugins/zsh-syntax-highlighting + else + echo "${INFO} Directory zsh-syntax-highlighting already exists. Cloning Skipped." 2>&1 | tee -a "$LOG" + fi - # Check if the current shell is zsh - current_shell=$(basename "$SHELL") - if [ "$current_shell" != "zsh" ]; then - printf "${NOTE} Changing default shell to ${MAGENTA}zsh${RESET}..." - printf "\n%.0s" {1..2} + # Check if ~/.zshrc and .zprofile exists, create a backup, and copy the new configuration + if [ -f "$HOME/.zshrc" ]; then + cp -b "$HOME/.zshrc" "$HOME/.zshrc-backup" || true + fi - # Loop to ensure the chsh command succeeds - while ! chsh -s "$(command -v zsh)"; do - echo "${ERROR} Authentication failed. Please enter the correct password." 2>&1 | tee -a "$LOG" - sleep 1 - done + if [ -f "$HOME/.zprofile" ]; then + cp -b "$HOME/.zprofile" "$HOME/.zprofile-backup" || true + fi - printf "${INFO} Shell changed successfully to ${MAGENTA}zsh${RESET}" 2>&1 | tee -a "$LOG" - else - echo "${NOTE} Your shell is already set to ${MAGENTA}zsh${RESET}." - fi + # Copying the preconfigured zsh themes and profile + cp -r 'assets/.zshrc' ~/ + cp -r 'assets/.zprofile' ~/ + + # Check if the current shell is zsh + current_shell=$(basename "$SHELL") + if [ "$current_shell" != "zsh" ]; then + echo "${NOTE} Changing default shell to ${MAGENTA}zsh${RESET}..." + newlines 1 + + # Loop to ensure the chsh command succeeds + while ! chsh -s "$(command -v zsh)"; do + echo "${ERROR} Authentication failed. Please enter the correct password." 2>&1 | tee -a "$LOG" + sleep 1 + done + + echo "${INFO} Shell changed successfully to ${MAGENTA}zsh${RESET}" 2>&1 | tee -a "$LOG" + else + echo "${NOTE} Your shell is already set to ${MAGENTA}zsh${RESET}." + fi fi # copy additional oh-my-zsh themes from assets if [ -d "$HOME/.oh-my-zsh/themes" ]; then - cp -r assets/add_zsh_theme/* ~/.oh-my-zsh/themes >> "$LOG" 2>&1 + cp -r "$PARENT_DIR"/assets/add_zsh_theme/* ~/.oh-my-zsh/themes >>"$LOG" 2>&1 fi -printf "\n%.0s" {1..2} +newlines 2 diff --git a/install.sh b/install.sh index 8562fc5..4cbb261 100755 --- a/install.sh +++ b/install.sh @@ -1,87 +1,104 @@ #!/bin/bash # https://github.com/JaKooLit -clear +# Do not complain about the following message in this file: +# Don't use variables in the printf format string. Use printf "..%s.." "$foo". +# Rationale: I want nice color formatting in printf. +# shellcheck disable=2059 -# 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)" +# Let's be safer when programming in Bash +set -euo pipefail +IFS=$'\n\t' + +PARENT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") + +cd "$PARENT_DIR" || (echo "Failed to change directory to $PARENT_DIR, so exitting with error code 1." && exit 1) + +# Set the name of the log file to include the current date and time +LOG="$PARENT_DIR/Install-Logs/01-Hyprland-Install-Scripts-$(date +%d-%H%M%S).log" + +restore_cursor() { + tput cnorm + [[ $(type -t verbose_log) == "function" && -v VERBOSE ]] && verbose_log "Exiting, so restoring cursor in case 'tput civis' was executed." +} + +cleanup() { + restore_cursor + echo -e "\n\n$1" | tee -a "$LOG" + exit 1 +} + +# In case user interrupts, switch back to old directory. Manually set colors for compatibility. +trap 'restore_cursor' EXIT +trap 'cleanup "$(tput setaf 4)[INFO]$(tput sgr0) Exiting by error encountered. (ERR)...\n$(tput setaf 251)[NOTE]$(tput sgr0) If you did not press Ctrl+D, check the most recent files in $PARENT_DIR/Install-Logs for possible reasons for such an early exit."' ERR +trap 'cleanup "$(tput setaf 12)[ACTION]$(tput sgr0) Exiting due to user-interrupt. (SIGINT)..."' SIGINT +trap 'cleanup "$(tput setaf 1)[ERROR]$(tput sgr0) Exiting due to abort signal. A critical error may have occurred internally. (SIGABRT)..."' SIGABRT + +source "$PARENT_DIR/install-scripts/colors.sh" || { + echo "$(tput setaf 1)[ERROR]$(tput sgr0) Failed to source $PARENT_DIR/install-scripts/colors.sh" | tee -a "$LOG" + exit 1 +} + +# Check if running as root. If root, script will exit +if [[ $EUID -eq 0 ]]; then + echo "${ERROR} This script should ${RED}NOT${RESET} be executed as root!! Exiting......." | tee -a "$LOG" + printf "\n%.0s" {1..2} + exit 1 +fi + +source "$PARENT_DIR/install-scripts/Global_functions.sh" || { + echo "${ERROR} Failed to source $PARENT_DIR/install-scripts/Global_functions.sh" | tee -a "$LOG" + exit 1 +} + +parse_args "$@" # Display warning message -echo -e "${WARNING}NOTE:${RESET} Hyprland on Repo is extremely outdated and will not be supported anymore." -echo -e "Use this at your own risk." -echo -e "${WARNING}Any issues will not be dealt with${RESET}" -echo +echo "${WARNING}WARNING:${RESET} Hyprland on Repo is extremely outdated and will not be supported anymore." +echo "Use this at your own risk." +echo "${RED}Any issues will not be dealt with${RESET}" +newlines 1 # Prompt user to continue or exit read -rp "Do you want to continue with the installation? [y/N]: " confirm case "$confirm" in - [yY][eE][sS]|[yY]) - echo -e "${OK} Continuing with installation..." - ;; - *) - echo -e "${NOTE} You chose not to continue. Exiting..." - exit 1 - ;; -esac - -# Create Directory for Install Logs -if [ ! -d Install-Logs ]; then - mkdir Install-Logs -fi - -# Set the name of the log file to include the current date and time -LOG="Install-Logs/01-Hyprland-Install-Scripts-$(date +%d-%H%M%S).log" - -# Check if running as root. If root, script will exit -if [[ $EUID -eq 0 ]]; then - echo "${ERROR} This script should ${WARNING}NOT${RESET} be executed as root!! Exiting......." | tee -a "$LOG" - printf "\n%.0s" {1..2} +[yY][eE][sS] | [yY]) + echo "${OK} Continuing with installation..." + ;; +*) + echo "${INFO} You chose not to continue. Exiting..." exit 1 -fi - -# Function to check if the system is Ubuntu -is_ubuntu() { - # Check for 'Ubuntu' in /etc/os-release - if grep -q 'Ubuntu' /etc/os-release; then - return 0 - fi - return 1 -} + ;; +esac # Check if the system is Ubuntu if is_ubuntu; then - echo "${WARN}This script is ${WARNING}NOT intended for Ubuntu / Ubuntu Based${RESET}. Refer to ${YELLOW}README for the correct link for Ubuntu-Hyprland project${RESET}" | tee -a "$LOG" + echo "${WARN}This script is ${RED}NOT intended for an Ubuntu / Ubuntu-based distribution${RESET}. Refer to ${YELLOW}README for the correct link for the Ubuntu-Hyprland project${RESET}" | tee -a "$LOG" exit 1 +else + verbose_log "You are not using an Ubuntu / Ubuntu-based distribution." fi # install whiptails if detected not installed. Necessary for this version if ! command -v whiptail >/dev/null; then - echo "${NOTE} - whiptail is not installed. Installing..." | tee -a "$LOG" - sudo apt install -y whiptail - printf "\n%.0s" {1..1} + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install whiptail even though it is required." | tee -a "$LOG" + else + echo "${NOTE} - whiptail is not installed. Installing..." | tee -a "$LOG" + apt_install whiptail + fi + newlines 1 +else + verbose_log "whiptail already installed, not installing." fi - -printf "\n%.0s" {1..2} +newlines 2 echo -e "\e[35m ╦╔═┌─┐┌─┐╦ ╦ ╦┬ ┬┌─┐┬─┐┬ ┌─┐┌┐┌┌┬┐ ╠╩╗│ ││ │║ ╠═╣└┬┘├─┘├┬┘│ ├─┤│││ ││ 2025 ╩ ╩└─┘└─┘╩═╝ ╩ ╩ ┴ ┴ ┴└─┴─┘┴ ┴┘└┘─┴┘ Debian Trixie / SiD \e[0m" -printf "\n%.0s" {1..1} +newlines 1 # Welcome message using whiptail (for displaying information) whiptail --title "KooL Debian-Hyprland Trixie-SID (2025) Install Script" \ @@ -93,95 +110,57 @@ NOTE: If you are installing on a VM, ensure to enable 3D acceleration else Hyprl # Ask if the user wants to proceed if ! whiptail --title "Proceed with Installation?" \ --yesno "VERY IMPORTANT!!!\n\nYou must be able to install from source by uncommenting deb-src on /etc/apt/sources.list else script may fail to install Hyprland.\n\n\nShall we proceed?" 15 60; then - echo -e "\n" + newlines 2 echo "❌ ${INFO} You 🫵 chose ${YELLOW}NOT${RESET} to proceed. ${YELLOW}Exiting...${RESET}" | tee -a "$LOG" - echo -e "\n" + newlines 2 exit 1 fi -echo "👌 ${OK} 🇵🇭 ${MAGENTA}KooL..${RESET} ${SKY_BLUE}lets continue with the installation...${RESET}" | tee -a "$LOG" +echo "👌 ${OK} 🇵🇭 ${MAGENTA}KooL..${RESET} ${SKY_BLUE}let's continue with the installation...${RESET}" | tee -a "$LOG" sleep 1 -printf "\n%.0s" {1..1} +newlines 1 # install pciutils if detected not installed. Necessary for detecting GPU -if ! dpkg -l | grep -w pciutils > /dev/null; then - echo "pciutils is not installed. Installing..." | tee -a "$LOG" - sudo apt install -y pciutils - printf "\n%.0s" {1..1} -fi - - -# Path to the install-scripts directory -script_directory=install-scripts - -# Function to execute a script if it exists and make it executable -execute_script() { - local script="$1" - local script_path="$script_directory/$script" - if [ -f "$script_path" ]; then - chmod +x "$script_path" - if [ -x "$script_path" ]; then - env "$script_path" - else - echo "Failed to make script '$script' executable." | tee -a "$LOG" - fi +if ! dpkg -l | grep -w pciutils >/dev/null; then + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't install whiptail even though it is required." | tee -a "$LOG" else - echo "Script '$script' not found in '$script_directory'." | tee -a "$LOG" + echo "pciutils is not installed. Installing..." | tee -a "$LOG" + apt_install pciutils fi -} + newlines 1 +else + verbose_log "pciutils already installed, not installing." +fi ################# -## Default values for the options (will be overwritten by preset file if available) -gtk_themes="OFF" -bluetooth="OFF" -thunar="OFF" -ags="OFF" -sddm="OFF" -sddm_theme="OFF" -xdph="OFF" -zsh="OFF" -pokemon="OFF" -rog="OFF" -dots="OFF" -input_group="OFF" -nvidia="OFF" +## Default values for the options (will be overwritten by preset file if --preset is used with a valid file) +export gtk_themes="OFF" +export bluetooth="OFF" +export thunar="OFF" +export ags="OFF" +export sddm="OFF" +export sddm_theme="OFF" +export xdph="OFF" +export zsh="OFF" +export pokemon="OFF" +export rog="OFF" +export dots="OFF" +export input_group="OFF" +export nvidia="OFF" -# Function to load preset file -load_preset() { - if [ -f "$1" ]; then - echo "✅ Loading preset: $1" - source "$1" - else - echo "⚠️ Preset file not found: $1. Using default values." - fi -} - -# Check if --preset argument is passed -if [[ "$1" == "--preset" && -n "$2" ]]; then - load_preset "$2" +# Load preset if PRESET_ENABLED is 1, which is only if PRESET is a valid file and set as an argument +if [[ $PRESET_ENABLED -eq 1 ]]; then + # shellcheck disable=SC2153 + load_preset "$PRESET" fi -# List of services to check for active login managers -services=("gdm.service" "gdm3.service" "lightdm.service" "lxdm.service") +check_services_running +# shellcheck disable=SC2034 +NON_SDDM_SERVICES_RUNNING=$? -# Function to check if any login services are active -check_services_running() { - active_services=() # Array to store active services - for svc in "${services[@]}"; do - if systemctl is-active --quiet "$svc"; then - active_services+=("$svc") - fi - done - - if [ ${#active_services[@]} -gt 0 ]; then - return 0 - else - return 1 - fi -} - -if check_services_running; then +if [[ $NON_SDDM_SERVICES_RUNNING -eq 1 ]]; then active_list=$(printf "%s\n" "${active_services[@]}") # Display the active login manager(s) in the whiptail message box @@ -191,9 +170,12 @@ fi # Check if NVIDIA GPU is detected nvidia_detected=false -if lspci | grep -i "nvidia" &> /dev/null; then +if lspci | grep -i "nvidia" &>/dev/null; then + verbose_log "NVIDIA GPU detected." nvidia_detected=true whiptail --title "NVIDIA GPU Detected" --msgbox "NVIDIA GPU detected in your system.\n\nNOTE: The script will install nvidia-dkms, nvidia-utils, and nvidia-settings if you choose to configure." 12 60 +else + verbose_log "NVIDIA GPU not detected." fi # Initialize the options array for whiptail checklist @@ -203,6 +185,7 @@ options_command=( # Add NVIDIA options if detected if [ "$nvidia_detected" == "true" ]; then + verbose_log "Adding nvidia option to selection list" options_command+=( "nvidia" "Do you want script to configure NVIDIA GPU?" "OFF" ) @@ -211,25 +194,30 @@ fi # Check if user is already in the 'input' group input_group_detected=false if ! groups "$(whoami)" | grep -q '\binput\b'; then + verbose_log "You are not in the input group." input_group_detected=true whiptail --title "Input Group" --msgbox "You are not currently in the input group.\n\nAdding you to the input group might be necessary for the Waybar keyboard-state functionality." 12 60 +else + verbose_log "You are already in the input group." fi # Add 'input_group' option if user is not in input group -if [ "$input_group_detected" == "true" ]; then +if [[ "$input_group_detected" == "true" ]]; then + verbose_log "Adding input_group option to selection list" options_command+=( "input_group" "Add your USER to input group for some waybar functionality?" "OFF" ) fi # Conditionally add SDDM and SDDM theme options if no active login manager is found -if ! check_services_running; then +if [[ $NON_SDDM_SERVICES_RUNNING -eq 0 ]]; then options_command+=( "sddm" "Install & configure SDDM login manager?" "OFF" "sddm_theme" "Download & Install Additional SDDM theme?" "OFF" ) fi +verbose_log "Adding remaining gtk_themes, bluetooth, thunar, ags, xdph, zsh, pokemon, rog, and dots options to selection" # Add the remaining static options options_command+=( "gtk_themes" "Install GTK themes (required for Dark/Light function)" "OFF" @@ -245,31 +233,31 @@ options_command+=( # Capture the selected options before the while loop starts while true; do - selected_options=$("${options_command[@]}" 3>&1 1>&2 2>&3) - # Check if the user pressed Cancel (exit status 1) - if [ $? -ne 0 ]; then - echo -e "\n" + if ! selected_options=$("${options_command[@]}" 3>&1 1>&2 2>&3); then + newlines 2 echo "❌ ${INFO} You 🫵 cancelled the selection. ${YELLOW}Goodbye!${RESET}" | tee -a "$LOG" - exit 0 # Exit the script if Cancel is pressed + exit 0 # Exit the script if Cancel is pressed fi # If no option was selected, notify and restart the selection if [ -z "$selected_options" ]; then + verbose_log "No options selected." whiptail --title "Warning" --msgbox "No options were selected. Please select at least one option." 10 60 - continue # Return to selection if no options selected + continue # Return to selection if no options selected fi # Strip the quotes and trim spaces if necessary (sanitize the input) selected_options=$(echo "$selected_options" | tr -d '"' | tr -s ' ') # Convert selected options into an array (preserving spaces in values) - IFS=' ' read -r -a options <<< "$selected_options" + IFS=' ' read -r -a options <<<"$selected_options" # Check if the "dots" option was selected dots_selected="OFF" for option in "${options[@]}"; do if [[ "$option" == "dots" ]]; then + verbose_log "dots option selected" dots_selected="ON" break fi @@ -279,14 +267,14 @@ while true; do if [[ "$dots_selected" == "OFF" ]]; then # Show a note about not selecting the "dots" option if ! whiptail --title "KooL Hyprland Dot Files" --yesno \ - "You have not selected to install the pre-configured KooL Hyprland dotfiles.\n\nKindly NOTE that if you proceed without Dots, Hyprland will start with default vanilla Hyprland configuration and I won't be able to give you support.\n\nWould you like to continue install without KooL Hyprland Dots or return to choices/options?" \ - --yes-button "Continue" --no-button "Return" 15 90; then + "You have not selected to install the pre-configured KooL Hyprland dotfiles.\n\nKindly NOTE that if you proceed without Dots, Hyprland will start with default vanilla Hyprland configuration and I won't be able to give you support.\n\nWould you like to continue install without KooL Hyprland Dots or return to choices/options?" \ + --yes-button "Continue" --no-button "Return" 15 90; then echo "🔙 Returning to options..." | tee -a "$LOG" continue else # User chose to continue echo "${INFO} ⚠️ Continuing WITHOUT the dotfiles installation..." | tee -a "$LOG" - printf "\n%.0s" {1..1} + newlines 1 fi fi @@ -299,19 +287,23 @@ while true; do # Confirmation prompt if ! whiptail --title "Confirm Your Choices" --yesno "$(printf "%s" "$confirm_message")" 25 80; then - echo -e "\n" + newlines 2 echo "❌ ${SKY_BLUE}You're not 🫵 happy${RESET}. ${YELLOW}Returning to options...${RESET}" | tee -a "$LOG" - continue + continue fi echo "👌 ${OK} You confirmed your choices. Proceeding with ${SKY_BLUE}KooL 🇵🇭 Hyprland Installation...${RESET}" | tee -a "$LOG" - break + break done -printf "\n%.0s" {1..1} +newlines 1 -echo "${INFO} Running a ${SKY_BLUE}full system update...${RESET}" | tee -a "$LOG" -sudo apt update +if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} I won't synchronize your package index files." | tee -a "$LOG" +else + echo "${INFO} ${SKY_BLUE}Synchronizing${RESET} package index files with apt update..." | tee -a "$LOG" + sudo apt update +fi sleep 1 # execute pre clean up @@ -329,28 +321,6 @@ echo "${INFO} Installing ${SKY_BLUE}KooL Hyprland packages...${RESET}" | tee -a sleep 1 execute_script "01-hypr-pkgs.sh" sleep 1 -execute_script "hyprutils.sh" # Order is very specific for dependencies are scattered -sleep 1 -execute_script "hyprlang.sh" -sleep 1 -execute_script "hyprcursor.sh" -sleep 1 -execute_script "hyprgraphics.sh" -sleep 1 -execute_script "hyprland-qt-support.sh" -sleep 1 -execute_script "hyprland-qtutils.sh" -sleep 1 -execute_script "hyprwayland-scanner.sh" -sleep 1 -execute_script "aquamarine.sh" -sleep 1 -execute_script "hyprland-protocols.sh" -sleep 1 -execute_script "hypridle.sh" -sleep 1 -execute_script "hyprlock.sh" -sleep 1 execute_script "hyprland.sh" sleep 1 execute_script "wallust.sh" @@ -367,130 +337,148 @@ sleep 1 selected_options=$(echo "$selected_options" | tr -d '"' | tr -s ' ') # Convert selected options into an array (splitting by spaces) -IFS=' ' read -r -a options <<< "$selected_options" +IFS=' ' read -r -a options <<<"$selected_options" # Loop through selected options for option in "${options[@]}"; do case "$option" in - sddm) - if check_services_running; then - active_list=$(printf "%s\n" "${active_services[@]}") - whiptail --title "Error" --msgbox "One of the following login services is running:\n$active_list\n\nPlease stop & disable it or DO not choose SDDM." 12 60 - exec "$0" - else - echo "${INFO} Installing and configuring ${SKY_BLUE}SDDM...${RESET}" | tee -a "$LOG" - execute_script "sddm.sh" - fi - ;; - nvidia) - echo "${INFO} Configuring ${SKY_BLUE}nvidia stuff${RESET}" | tee -a "$LOG" - execute_script "nvidia.sh" - ;; - gtk_themes) - echo "${INFO} Installing ${SKY_BLUE}GTK themes...${RESET}" | tee -a "$LOG" - execute_script "gtk_themes.sh" - ;; - input_group) - echo "${INFO} Adding user into ${SKY_BLUE}input group...${RESET}" | tee -a "$LOG" - execute_script "InputGroup.sh" - ;; - ags) - echo "${INFO} Installing ${SKY_BLUE}AGS v1 for Desktop Overview...${RESET}" | tee -a "$LOG" - execute_script "ags.sh" - ;; - xdph) - echo "${INFO} Installing ${SKY_BLUE}xdg-desktop-portal-hyprland...${RESET}" | tee -a "$LOG" - execute_script "xdph.sh" - ;; - bluetooth) - echo "${INFO} Configuring ${SKY_BLUE}Bluetooth...${RESET}" | tee -a "$LOG" - execute_script "bluetooth.sh" - ;; - thunar) - echo "${INFO} Installing ${SKY_BLUE}Thunar file manager...${RESET}" | tee -a "$LOG" - execute_script "thunar.sh" - execute_script "thunar_default.sh" - ;; - sddm_theme) - echo "${INFO} Downloading & Installing ${SKY_BLUE}Additional SDDM theme...${RESET}" | tee -a "$LOG" - execute_script "sddm_theme.sh" - ;; - zsh) - echo "${INFO} Installing ${SKY_BLUE}zsh with Oh-My-Zsh...${RESET}" | tee -a "$LOG" - execute_script "zsh.sh" - ;; - pokemon) - echo "${INFO} Adding ${SKY_BLUE}Pokemon color scripts to terminal...${RESET}" | tee -a "$LOG" - execute_script "zsh_pokemon.sh" - ;; - rog) - echo "${INFO} Installing ${SKY_BLUE}ROG laptop packages...${RESET}" | tee -a "$LOG" - execute_script "rog.sh" - ;; - dots) - echo "${INFO} Installing pre-configured ${SKY_BLUE}KooL Hyprland dotfiles...${RESET}" | tee -a "$LOG" - execute_script "dotfiles-branch.sh" - ;; - *) - echo "Unknown option: $option" | tee -a "$LOG" - ;; + sddm) + if check_services_running; then + active_list=$(printf "%s\n" "${active_services[@]}") + whiptail --title "Error" --msgbox "One of the following login services is running:\n$active_list\n\nPlease stop & disable it or DO not choose SDDM." 12 60 + exec "$0" + else + echo "${INFO} Installing and configuring ${SKY_BLUE}SDDM...${RESET}" | tee -a "$LOG" + execute_script "sddm.sh" + fi + ;; + nvidia) + echo "${INFO} Configuring ${SKY_BLUE}nvidia stuff${RESET}" | tee -a "$LOG" + execute_script "nvidia.sh" + ;; + gtk_themes) + echo "${INFO} Installing ${SKY_BLUE}GTK themes...${RESET}" | tee -a "$LOG" + execute_script "gtk_themes.sh" + ;; + input_group) + echo "${INFO} Adding user into ${SKY_BLUE}input group...${RESET}" | tee -a "$LOG" + execute_script "InputGroup.sh" + ;; + ags) + echo "${INFO} Installing ${SKY_BLUE}AGS v1 for Desktop Overview...${RESET}" | tee -a "$LOG" + execute_script "ags.sh" + ;; + xdph) + echo "${INFO} Installing ${SKY_BLUE}xdg-desktop-portal-hyprland...${RESET}" | tee -a "$LOG" + execute_script "xdph.sh" + ;; + bluetooth) + echo "${INFO} Configuring ${SKY_BLUE}Bluetooth...${RESET}" | tee -a "$LOG" + execute_script "bluetooth.sh" + ;; + thunar) + echo "${INFO} Installing ${SKY_BLUE}Thunar file manager...${RESET}" | tee -a "$LOG" + execute_script "thunar.sh" + execute_script "thunar_default.sh" + ;; + sddm_theme) + echo "${INFO} Downloading & Installing ${SKY_BLUE}Additional SDDM theme...${RESET}" | tee -a "$LOG" + execute_script "sddm_theme.sh" + ;; + zsh) + echo "${INFO} Installing ${SKY_BLUE}zsh with Oh-My-Zsh...${RESET}" | tee -a "$LOG" + execute_script "zsh.sh" + ;; + pokemon) + echo "${INFO} Adding ${SKY_BLUE}Pokemon color scripts to terminal...${RESET}" | tee -a "$LOG" + execute_script "zsh_pokemon.sh" + ;; + rog) + echo "${INFO} Installing ${SKY_BLUE}ROG laptop packages...${RESET}" | tee -a "$LOG" + execute_script "rog.sh" + ;; + dots) + echo "${INFO} Installing pre-configured ${SKY_BLUE}KooL Hyprland dotfiles...${RESET}" | tee -a "$LOG" + execute_script "dotfiles-branch.sh" + ;; + *) + echo "Unknown option: $option" | tee -a "$LOG" + ;; esac done # Perform cleanup printf "\n${OK} Performing some clean up.\n" +verbose_log "Checking to remove files $WORKING_DIR/JetBrainsMono.tar.xz, $WORKING_DIR/VictorMonoAll.zip, and $WORKING_DIR/FantasqueSansMono.zip" files_to_delete=("JetBrainsMono.tar.xz" "VictorMonoAll.zip" "FantasqueSansMono.zip") for file in "${files_to_delete[@]}"; do if [ -e "$file" ]; then - echo "$file found. Deleting..." | tee -a "$LOG" - rm "$file" - echo "$file deleted successfully." | tee -a "$LOG" + if [[ $DRY -eq 1 ]]; then + echo "I am not deleting $file even though it should be cleaned up. Manually use 'rm $file' instead." | tee -a "$LOG" + else + echo "$file found. Deleting..." | tee -a "$LOG" + rm "$file" + echo "$file deleted successfully." | tee -a "$LOG" + fi fi done - -clear +# clear # copy fastfetch config if debian is not present if [ ! -f "$HOME/.config/fastfetch/debian.png" ]; then - cp -r assets/fastfetch "$HOME/.config/" + if [[ $DRY -eq 1 ]]; then + echo "${NOTE} I am not copying $WORKING_DIR/assets/fastfetch to $HOME/.config" | tee -a "$LOG" + else + verbose_log "Copying $WORKING_DIR/assets/fastfetch to $HOME/.config/ since $HOME/.config/fastfetch/debian.png is not present" + cp -r assets/fastfetch "$HOME/.config/" + fi fi -printf "\n%.0s" {1..2} +newlines 2 # final check essential packages if it is installed execute_script "03-Final-Check.sh" -printf "\n%.0s" {1..1} +newlines 1 -# Check if either hyprland or hyprland-git is installed -if dpkg -l | grep -qw hyprland; then +# Check if hyprland is installed, either by apt, which is installing via apt is not supported and therefore impossible, or by building from source, which is to check if some other possible location exists with command -v +if check_if_installed_with_apt "hyprland" || command -v Hyprland >/dev/null; then + if check_if_installed_with_apt "hyprland"; then + verbose_log "hyprland is installed with apt" + else + verbose_log "hyprland is not installed with apt, but since the command, Hyprland, exists, I assume hyprland was built and installed from source" + fi printf "\n ${OK} 👌 Hyprland is installed. However, some essential packages may not be installed. Please see above!" printf "\n${CAT} Ignore this message if it states ${YELLOW}All essential packages${RESET} are installed as per above\n" sleep 2 - printf "\n%.0s" {1..2} + newlines 2 printf "${SKY_BLUE}Thank you${RESET} 🫰 for using 🇵🇭 ${MAGENTA}KooL's Hyprland Dots${RESET}. ${YELLOW}Enjoy and Have a good day!${RESET}" - printf "\n%.0s" {1..2} + newlines 2 - printf "\n${NOTE} You can start Hyprland by typing ${SKY_BLUE}Hyprland${RESET} (IF SDDM is not installed) (note the capital H!).\n" + printf "\n${NOTE} You can start Hyprland by typing ${SKY_BLUE}Hyprland${RESET} or ${SKY_BLUE}hyprland${RESET} (IF SDDM is not installed).\n" printf "\n${NOTE} However, it is ${YELLOW}highly recommended to reboot${RESET} your system.\n\n" while true; do echo -n "${CAT} Would you like to reboot now? (y/n): " - read HYP + read -r HYP HYP=$(echo "$HYP" | tr '[:upper:]' '[:lower:]') if [[ "$HYP" == "y" || "$HYP" == "yes" ]]; then - echo "${INFO} Rebooting now..." - systemctl reboot + if [[ $PEDANTIC_DRY -eq 1 ]]; then + echo "${NOTE} Not rebooting, even with user confirmation, since pedantic dry run mode is enabled. However, you can still manually reboot with 'systemctl reboot'." | tee -a "$LOG" + break + fi + echo "${INFO} Rebooting now..." | tee -a "$LOG" + systemctl reboot break elif [[ "$HYP" == "n" || "$HYP" == "no" ]]; then - echo "👌 ${OK} You chose NOT to reboot" - printf "\n%.0s" {1..1} + echo "👌 ${OK} You chose NOT to reboot" | tee -a "$LOG" + newlines 1 # Check if NVIDIA GPU is present - if lspci | grep -i "nvidia" &> /dev/null; then - echo "${INFO} HOWEVER ${YELLOW}NVIDIA GPU${RESET} detected. Reminder that you must REBOOT your SYSTEM..." - printf "\n%.0s" {1..1} + if lspci | grep -i "nvidia" &>/dev/null; then + echo "${INFO} HOWEVER ${YELLOW}NVIDIA GPU${RESET} detected. Reminder that you must REBOOT your SYSTEM..." | tee -a "$LOG" + newlines 1 fi break else @@ -499,10 +487,10 @@ if dpkg -l | grep -qw hyprland; then done else # Print error message if neither package is installed - printf "\n${WARN} Hyprland is NOT installed. Please check 00_CHECK-time_installed.log and other files in the Install-Logs/ directory..." - printf "\n%.0s" {1..3} + printf "\n${WARN} Hyprland is NOT installed. Please check 00_CHECK-time_installed.log and other files in the Install-Logs/ directory..." | tee -a "$LOG" + newlines 3 + verbose_log "I shall exit with error code 1 since hyprland is probably not installed based on checking apt and /usr/bin for hyprland" exit 1 fi -printf "\n%.0s" {1..2} - +newlines 2 diff --git a/preset.sh b/preset.sh index 679f836..b90e132 100644 --- a/preset.sh +++ b/preset.sh @@ -1,46 +1,50 @@ +#!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # Define the options you want to preselect (either ON or OFF) # IMPORTANT: answer should be inside "" +# Remember to use the --preset option when calling install.sh so this is executed, such as +# ./install.sh --preset preset.sh + ### Script will install nvidia-dkms nvidia-utils & nvidia-settings ###-Would you like script to Configure NVIDIA for you? -nvidia="OFF" +export nvidia="OFF" ###-Install GTK themes (required for Dark/Light function)? -gtk_themes="ON" +export gtk_themes="ON" ###-Do you want to configure Bluetooth? -bluetooth="ON" +export bluetooth="ON" ###-Do you want to install Thunar file manager? -thunar="ON" +export thunar="ON" ### Adding user to the 'input' group might be necessary for waybar keyboard-state functionality -input_group="ON" +export input_group="ON" ### Desktop overview Demo Link in README ### Desktop overview Demo Link in README -### Install AGS (aylur's GTK shell) v1 for Desktop-Like Overview?" -ags="ON" +### Install AGS (aylur's GTK shell) v1 for Desktop-Like Overview?" +export ags="ON" ###-Install & configure SDDM log-in Manager -sddm="ON" +export sddm="ON" ### install and download SDDM themes -sddm_theme="ON" +export sddm_theme="ON" ###-Install XDG-DESKTOP-PORTAL-HYPRLAND? (For proper Screen Share ie OBS) -xdph="ON" +export xdph="ON" ### Shell extension. Bash alternative ###-Install zsh, oh-my-zsh -zsh="ON" -### add Pokemon color scripts to terminal -pokemon="ON" +export zsh="ON" +### add Pokemon color scripts to terminal +export pokemon="ON" ### This will install ASUSCTL & SUPERGFXCTL ###-Installing on Asus ROG Laptops? -rog="OFF" +export rog="OFF" ###-Download and Add pre-configured Hyprland dotfiles? -dots="ON" +export dots="ON" diff --git a/uninstall.sh b/uninstall.sh index 2a99359..7a06e91 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -2,23 +2,10 @@ # 💫 https://github.com/JaKooLit 💫 # # KooL Debian-Hyprland uninstall script # -clear +# Suddenly clearing is invasive to terminal +# clear -# 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)" +source "colors.sh" printf "\n%.0s" {1..2} echo -e "\e[35m