From 485058024e74e4d4c1db124db30d3e7762bdcbcd Mon Sep 17 00:00:00 2001 From: pika Date: Sat, 5 Apr 2025 09:47:23 +0200 Subject: [PATCH] addet arch-hyprland setup script --- setup/arch-hyprland.sh | 151 +++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 82 deletions(-) diff --git a/setup/arch-hyprland.sh b/setup/arch-hyprland.sh index 66b367e..297962b 100644 --- a/setup/arch-hyprland.sh +++ b/setup/arch-hyprland.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash -e # ╭───────────────╮ # │ env functions │ @@ -11,25 +11,34 @@ LIGHT_GREEN='\033[0;92m' BOLD='\033[1m' NC='\033[0m' # No Color +# ERROR: -- Message echo_error() { printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 } +# INFO: -- Message echo_info() { printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" } +# WARNING: -- Message echo_warning() { printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" } +# NOTE: -- Message echo_note() { printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" } +# ──────────────────────< Check if the given command exists silently >────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + # ─────────────< Check if the user is root and set sudo variable if necessary >───────────── check_root() { - if [ "$(id -u)" -ne 0 ]; then + if [[ "$(id -u)" -ne 0 ]]; then if command_exists sudo; then echo_info "User is not root. Using sudo for privileged operations." _sudo="sudo" @@ -45,84 +54,35 @@ check_root() { # ─< Distribution detection and installation >──────────────────────────────────────── get_packager() { - if [ -e /etc/os-release ]; then - echo_info "Detecting distribution..." - . /etc/os-release - - ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]') - ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]') - - case "$ID" in - ubuntu | pop) _install() { $_sudo apt-get install --assume-yes "$@"; } ;; - debian) _install() { $_sudo apt-get install --assume-yes "$@"; } ;; - fedora) _install() { $_sudo dnf install -y "$@"; } ;; - alpine) _install() { $_sudo apk add "$@"; } ;; - arch | manjaro | garuda | endeavour) _install() { $pkger -S --noconfirm "$@"; } ;; - opensuse*) _install() { $_sudo zypper in -y "$@"; } ;; - *) - if echo "$ID_LIKE" | grep -q "debian"; then - _install() { $_sudo apt-get install --assume-yes "$@"; } - elif echo "$ID_LIKE" | grep -q "ubuntu"; then - _install() { $_sudo apt-get install --assume-yes "$@"; } - elif echo "$ID_LIKE" | grep -q "arch"; then - _install() { $pkger -S --noconfirm "$@"; } - elif echo "$ID_LIKE" | grep -q "fedora"; then - _install() { $_sudo dnf install -y "$@"; } - elif echo "$ID_LIKE" | grep -q "suse"; then - _install() { $_sudo zypper in -y "$@"; } - else - echo_error "Unsupported distribution: $ID" - return 1 - fi - ;; - esac - else - echo_error "Unable to detect distribution. /etc/os-release not found." - return 1 - fi -} - -# ──────────────────────< Check if the given command exists silently >────────────────────── -command_exists() { - command -v "$@" >/dev/null 2>&1 -} - -check_aur() { - if ! command_exists yay; then - echo_error "Yay was not found.. looking for paru instead" - if ! command_exists paru; then - echo_error "No AUR helper found, please install before continuing!" - exit 1 - else - echo_info "Found paru, using it.." - pkger="paru" - fi - exit 1 - else - echo_info "Found yay, using it.." - pkger="yay" + $_sudo pacman -Sy + if command_exists paru; then + _install() { paru -S --noconfirm "$@"; } + elif command_exists yay; then + _install() { yay -S --noconfirm "$@"; } + elif command_exists pacman; then + _install() { "$_sudo" pacman -S --noconfirm "$@"; } fi } check_deps() { - deps=" - hyprland - hyprpicker - hyprlang - hyprutils - hyprwayland-scanner - xdg-desktop-portal-hyprland + deps=( + "hyprland" + "hyprpicker" + "hyprlang" + "hyprutils" + "hyprwayland-scanner" + "xdg-desktop-portal-hyprland" + "$BarOfChoise" + "${MenuOfChoise[@]}" + "swww" + "wlogout" + "libnotify" + ) - $BarOfChoise - swww - rofi - wlogout - libnotify - " - for dependency in $deps; do + for dependency in "${deps[@]}"; do if ! command_exists "$dependency"; then echo_note "Installing $dependency.." - _install "$dependency" + _install "$dependency" || echo_error "Error installing $dependency!" else echo_info "$dependency is already installed" fi @@ -150,6 +110,27 @@ ask_bar() { esac } +ask_menu() { + echo_note "Which menu do you want to install?" + echo_note "[r]ofi, [t]tofi, [b]oth" + read -r askMenu ─────────────────────────────── main() { if check_root; then @@ -192,6 +178,7 @@ main() { fi ask_bar + ask_menu check_deps ask_dotfiles }