addet arch-hyprland setup script
This commit is contained in:
parent
459fc1c4c9
commit
485058024e
1 changed files with 69 additions and 82 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash -e
|
||||||
|
|
||||||
# ╭───────────────╮
|
# ╭───────────────╮
|
||||||
# │ env functions │
|
# │ env functions │
|
||||||
|
@ -11,25 +11,34 @@ LIGHT_GREEN='\033[0;92m'
|
||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# ERROR: -- Message
|
||||||
echo_error() {
|
echo_error() {
|
||||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# INFO: -- Message
|
||||||
echo_info() {
|
echo_info() {
|
||||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# WARNING: -- Message
|
||||||
echo_warning() {
|
echo_warning() {
|
||||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# NOTE: -- Message
|
||||||
echo_note() {
|
echo_note() {
|
||||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
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 if the user is root and set sudo variable if necessary >─────────────
|
||||||
check_root() {
|
check_root() {
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [[ "$(id -u)" -ne 0 ]]; then
|
||||||
if command_exists sudo; then
|
if command_exists sudo; then
|
||||||
echo_info "User is not root. Using sudo for privileged operations."
|
echo_info "User is not root. Using sudo for privileged operations."
|
||||||
_sudo="sudo"
|
_sudo="sudo"
|
||||||
|
@ -45,84 +54,35 @@ check_root() {
|
||||||
|
|
||||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
get_packager() {
|
get_packager() {
|
||||||
if [ -e /etc/os-release ]; then
|
$_sudo pacman -Sy
|
||||||
echo_info "Detecting distribution..."
|
if command_exists paru; then
|
||||||
. /etc/os-release
|
_install() { paru -S --noconfirm "$@"; }
|
||||||
|
elif command_exists yay; then
|
||||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
_install() { yay -S --noconfirm "$@"; }
|
||||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
elif command_exists pacman; then
|
||||||
|
_install() { "$_sudo" pacman -S --noconfirm "$@"; }
|
||||||
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"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_deps() {
|
check_deps() {
|
||||||
deps="
|
deps=(
|
||||||
hyprland
|
"hyprland"
|
||||||
hyprpicker
|
"hyprpicker"
|
||||||
hyprlang
|
"hyprlang"
|
||||||
hyprutils
|
"hyprutils"
|
||||||
hyprwayland-scanner
|
"hyprwayland-scanner"
|
||||||
xdg-desktop-portal-hyprland
|
"xdg-desktop-portal-hyprland"
|
||||||
|
"$BarOfChoise"
|
||||||
|
"${MenuOfChoise[@]}"
|
||||||
|
"swww"
|
||||||
|
"wlogout"
|
||||||
|
"libnotify"
|
||||||
|
)
|
||||||
|
|
||||||
$BarOfChoise
|
for dependency in "${deps[@]}"; do
|
||||||
swww
|
|
||||||
rofi
|
|
||||||
wlogout
|
|
||||||
libnotify
|
|
||||||
"
|
|
||||||
for dependency in $deps; do
|
|
||||||
if ! command_exists "$dependency"; then
|
if ! command_exists "$dependency"; then
|
||||||
echo_note "Installing $dependency.."
|
echo_note "Installing $dependency.."
|
||||||
_install "$dependency"
|
_install "$dependency" || echo_error "Error installing $dependency!"
|
||||||
else
|
else
|
||||||
echo_info "$dependency is already installed"
|
echo_info "$dependency is already installed"
|
||||||
fi
|
fi
|
||||||
|
@ -150,6 +110,27 @@ ask_bar() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ask_menu() {
|
||||||
|
echo_note "Which menu do you want to install?"
|
||||||
|
echo_note "[r]ofi, [t]tofi, [b]oth"
|
||||||
|
read -r askMenu </dev/tty
|
||||||
|
case "$askMenu" in
|
||||||
|
[rR] | rofi)
|
||||||
|
MenuOfChoise="rofi"
|
||||||
|
;;
|
||||||
|
[tT] | tofi)
|
||||||
|
MenuOfChoise="tofi"
|
||||||
|
;;
|
||||||
|
[bB] | both)
|
||||||
|
MenuOfChoise=("tofi" "rofi")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo_error "You did not select something useful! Try again!"
|
||||||
|
ask_bar
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
ask_dotfiles() {
|
ask_dotfiles() {
|
||||||
if [ ! -d "$HOME/.config/hypr" ]; then
|
if [ ! -d "$HOME/.config/hypr" ]; then
|
||||||
echo_note "Do you want to install the custom pika hyprdots?"
|
echo_note "Do you want to install the custom pika hyprdots?"
|
||||||
|
@ -164,22 +145,27 @@ ask_dotfiles() {
|
||||||
_install git
|
_install git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$HOME/git" ]; then
|
local gitDir=""
|
||||||
mkdir -p "$HOME/git"
|
echo_note "What is your preferred git directory?"
|
||||||
|
read -r gitDir </dev/tty
|
||||||
|
if [ ! -d "$gitDir" ]; then
|
||||||
|
mkdir -p "$gitDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$HOME/git/hyprdots"
|
if [[ ! -d "$gitDir/dotfiles" ]]; then
|
||||||
cd "$HOME/git/hyprdots" || echo_error "Directory of choise doesnt work.."
|
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$gitDir/dotfiles"
|
||||||
make
|
cd "$gitDir/dotfiles" || echo_error "Directory of choise doesnt work.."
|
||||||
|
make
|
||||||
|
else
|
||||||
|
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$gitDir/dotfiles/hyprdots" || echo_error "this directory is not empty.."
|
||||||
|
cd "$gitDir/dotfiles/hyprdots" || echo_error "Directory of choise doesnt work.."
|
||||||
|
make
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭────────────────────────────────────╮
|
|
||||||
# │ insert your scripts/functions here │
|
|
||||||
# ╰────────────────────────────────────╯
|
|
||||||
|
|
||||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||||
main() {
|
main() {
|
||||||
if check_root; then
|
if check_root; then
|
||||||
|
@ -192,6 +178,7 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ask_bar
|
ask_bar
|
||||||
|
ask_menu
|
||||||
check_deps
|
check_deps
|
||||||
ask_dotfiles
|
ask_dotfiles
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue