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 │
|
||||
|
@ -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 </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() {
|
||||
if [ ! -d "$HOME/.config/hypr" ]; then
|
||||
echo_note "Do you want to install the custom pika hyprdots?"
|
||||
|
@ -164,22 +145,27 @@ ask_dotfiles() {
|
|||
_install git
|
||||
fi
|
||||
|
||||
if [ ! -d "$HOME/git" ]; then
|
||||
mkdir -p "$HOME/git"
|
||||
local gitDir=""
|
||||
echo_note "What is your preferred git directory?"
|
||||
read -r gitDir </dev/tty
|
||||
if [ ! -d "$gitDir" ]; then
|
||||
mkdir -p "$gitDir"
|
||||
fi
|
||||
|
||||
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$HOME/git/hyprdots"
|
||||
cd "$HOME/git/hyprdots" || echo_error "Directory of choise doesnt work.."
|
||||
make
|
||||
if [[ ! -d "$gitDir/dotfiles" ]]; then
|
||||
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$gitDir/dotfiles"
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
# ╭────────────────────────────────────╮
|
||||
# │ insert your scripts/functions here │
|
||||
# ╰────────────────────────────────────╯
|
||||
|
||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
|
@ -192,6 +178,7 @@ main() {
|
|||
fi
|
||||
|
||||
ask_bar
|
||||
ask_menu
|
||||
check_deps
|
||||
ask_dotfiles
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue