322 lines
9.2 KiB
Bash
322 lines
9.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# ╭───────────────╮
|
|
# │ env functions │
|
|
# ╰───────────────╯
|
|
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
# WHY:
|
|
# This import will give you the following variables:
|
|
# _sudo="sudo -E" <- only if non root user
|
|
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
|
|
# arch = bool
|
|
# fedora = bool
|
|
# opensuse = bool....
|
|
# You can then use it for, `if $arch; then`
|
|
# Also this gives you the _install command, which installs a package pased on the packagemanager/distro used.
|
|
# CAUTION:
|
|
# This only wokrs for generic package names, like neovim, or vim, or tmux etc..
|
|
# not every package packagemanager has the same packagenames for their packages..
|
|
source-script() {
|
|
i="$1"
|
|
import="$(mktemp)"
|
|
if command_exists curl; then
|
|
curl -fsSL $i -o $import
|
|
else
|
|
echo "curl is required, but missing.."
|
|
exit 1
|
|
fi
|
|
|
|
source "$import"
|
|
sleep 0.3
|
|
rm "$import"
|
|
}
|
|
|
|
askThings() {
|
|
# if ! command_exists waybar && ! command_exists hyprpanel && ! command_exists gBar; then
|
|
case "$distro" in
|
|
arch)
|
|
choose bar "Choose a bar.." waybar hyprpanel gBar </dev/tty
|
|
[ "$bar" == "gBar" ] && bar=gbar
|
|
;;
|
|
*)
|
|
choose bar "Choose a bar.." waybar gBar </dev/tty
|
|
[ "$bar" == "gBar" ] && bar=gbar
|
|
;;
|
|
esac
|
|
|
|
pen grey "$bar was picked"
|
|
|
|
# if ! command_exists rofi && ! command_exists tofi; then
|
|
choose menu "Choose a menu.." rofi tofi </dev/tty
|
|
pen grey "$menu was picked"
|
|
|
|
choose terminal "Choose a menu.." alacritty foot kitty wezterm </dev/tty
|
|
pen grey "$terminal was picked"
|
|
|
|
removeUnwanted=false
|
|
if confirm --default-no "Do you want to also remove conflicting packages?" </dev/tty; then
|
|
removeUnwanted=true
|
|
fi
|
|
|
|
line
|
|
|
|
advDeps=(
|
|
"${menu:-rofi}"
|
|
"${terminal:-foot}"
|
|
"$bar"
|
|
"hyprshot"
|
|
"hyprlock"
|
|
"swww"
|
|
)
|
|
}
|
|
|
|
instCustom() {
|
|
for _d in "${advDeps[@]}"; do
|
|
case "$_d" in
|
|
hyprpanel | hyprlock | hyprshot | gBar | rofi | swww)
|
|
# eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/hyprpanel.sh)"
|
|
source-script https://git.k4li.de/scripts/installs/raw/branch/main/$_d.sh
|
|
;;
|
|
none)
|
|
return
|
|
;;
|
|
*)
|
|
check-and-install "$_d"
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
cloneDotfiles() {
|
|
pen blue bold "Which dotfiles do you want to clone? (if you choose 'own' you will be asked to put in a url for your neovim config repo)"
|
|
choose askDotfiles2 "What dotfiles do you want to choose?" "pika's" own none </dev/tty
|
|
# read -r askDotfiles2 </dev/tty
|
|
case "$askDotfiles2" in
|
|
"pika's")
|
|
spin blue bold "Cloning pika's config..."
|
|
if run git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$HOME/dotfiles"; then
|
|
upclear
|
|
check "Cloned dotfiles"
|
|
else
|
|
upclear
|
|
throw bold red "Failed to clone dotfiles!"
|
|
return 69
|
|
fi
|
|
|
|
cd $HOME/dotfiles || { echo-error "Failed to change dir into dotfiles.." && exit 1; }
|
|
|
|
pen blue bold "Installing dotfiles..."
|
|
line
|
|
|
|
make </dev/tty || { echo-error "Failed to install dotfiles!" && exit 1; }
|
|
|
|
pen blue bold "Dotfiles installed successfully!"
|
|
;;
|
|
own)
|
|
pen bold red "Warning: This does only clone the dotfiles into $HOME/dotfiles, you have to install them yourself!"
|
|
lin
|
|
request customDots "Type in the url of your hyprland dotfiles:" </dev/tty
|
|
sleep 1
|
|
spin blue bold "Getting your dotfiles from $customDots"
|
|
if run git clone --recursive --depth=1 "$customDots" "$HOME/dotfiles"; then
|
|
upclear
|
|
check "Cloned dotfiles"
|
|
else
|
|
upclear
|
|
throw bold red "Failed to clone dotfiles!"
|
|
return 69
|
|
fi
|
|
;;
|
|
none)
|
|
return
|
|
;;
|
|
esac
|
|
}
|
|
|
|
checkConfig() {
|
|
dirs="hypr $menu $bar"
|
|
for i in $dirs; do
|
|
if [ ! -d "$HOME/.config/$i" ]; then
|
|
pen bold yellow "Config directory $i not found!"
|
|
if confirm "Do you want to clone some dotfiles?" </dev/tty; then
|
|
pen blue bold "Cloning dotfiles..."
|
|
cloneDotfiles
|
|
fi
|
|
|
|
# breaking out of the loop, so that it doesn't get called for every missing dir
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
getDependencies() {
|
|
pen blue bold "Checking build dependencies.."
|
|
|
|
# INFO:
|
|
# ╭─────────────────────────────────────────────────────────────────────────╮
|
|
# │ You can define dependencies for various linux distros here. It will │
|
|
# │ automagically be pulled via the $pkgArray[$distro] variable │
|
|
# ╰─────────────────────────────────────────────────────────────────────────╯
|
|
generalDeps=(
|
|
hyprland
|
|
xdg-desktop-portal-hyprland
|
|
hyprland-protocols
|
|
wayland-protocols
|
|
|
|
grim
|
|
slurp
|
|
wlogout
|
|
ffmpeg
|
|
wob
|
|
nwg-look
|
|
kitty
|
|
wl-clipboard
|
|
)
|
|
depsDebian=(
|
|
hyprland-dev
|
|
)
|
|
depsFedora=()
|
|
depsOpensuse=()
|
|
depsArch=(
|
|
hyprpolkitagent
|
|
wayland-utils
|
|
wayland-protocols
|
|
)
|
|
depsAlpine=()
|
|
|
|
declare -A deps=(
|
|
[debian]="depsDebian"
|
|
[ubuntu]="depsUbuntu"
|
|
[fedora]="depsFedora"
|
|
[arch]="depsArch"
|
|
[alpine]="depsAlpine"
|
|
[opensuse]="depsOpensuse"
|
|
)
|
|
|
|
# INFO:
|
|
# ╭────────────────────────────────────────────────────────────────╮
|
|
# │ This variable stores the packages you provided for each distro │
|
|
# ╰────────────────────────────────────────────────────────────────╯
|
|
declare -n pkgArray="${deps[$distro]}"
|
|
|
|
case "$distro" in
|
|
arch)
|
|
check-and-install ${generalDeps[@]}
|
|
check-and-install ${pkgArray[@]}
|
|
;;
|
|
debian)
|
|
if $trixie; then
|
|
check-and-install ${generalDeps[@]}
|
|
check-and-install ${pkgArray[@]}
|
|
else
|
|
echo-error "Your current distro of debian is not sufficient, you have to have trixie (13) installed"
|
|
echo "trixie: $trixie"
|
|
echo "bookworm: $bookworm"
|
|
echo "bullseye: $bullseye"
|
|
echo "buster: $buster"
|
|
|
|
exit 69
|
|
fi
|
|
;;
|
|
*)
|
|
echo "$distro is currently not supported by this script!"
|
|
exit 69
|
|
;;
|
|
esac
|
|
}
|
|
|
|
remove-unwanted() {
|
|
local arr=(
|
|
mako
|
|
nano
|
|
dunst
|
|
hyprpaper
|
|
)
|
|
|
|
check-and-remove ${arr[@]}
|
|
}
|
|
|
|
setup-env() {
|
|
# local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh
|
|
# local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh
|
|
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
|
|
|
|
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists spin; then
|
|
source-script $dream
|
|
fi
|
|
|
|
if $debian; then
|
|
pen blue bold "Using debian.. checking for compatibility.."
|
|
if ! $trixie; then
|
|
echo-error "You are not using trixie, this script can currently only run on trixie (13)!"
|
|
echo-error "trixie: $trixie"
|
|
echo-error "bookworm: $bookworm"
|
|
echo-error "bullseye: $bullseye"
|
|
echo-error "buster: $buster"
|
|
return 69
|
|
else
|
|
pen blue bold "Using trixie.. good choice"
|
|
return 0
|
|
fi
|
|
elif $arch; then
|
|
pen blue bold "Using arch linux.. You really shouldn't get any errors :)"
|
|
return 0
|
|
else
|
|
echo-error "Cannot install $PACKAGE for $distro"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
askThings
|
|
|
|
if $silent; then
|
|
pen bold yellow "Executing script silently!"
|
|
fi
|
|
|
|
getDependencies
|
|
|
|
# remove conflicting packages if the user confirmed it
|
|
if $removeUnwanted; then
|
|
remove-unwanted
|
|
fi
|
|
|
|
instCustom
|
|
|
|
if [[ ! -d "$HOME/dotfiles" ]]; then
|
|
cloneDotfiles
|
|
fi
|
|
}
|
|
|
|
if setup-env; then
|
|
# ─< package variable >───────────────────────────────────────────────────────────────────
|
|
unset PACKAGE
|
|
|
|
# ─< argument list variables >────────────────────────────────────────────────────────────
|
|
silent=false
|
|
|
|
sleep 0.1
|
|
|
|
PACKAGE=hyprland
|
|
if command_exists "$PACKAGE"; then
|
|
pen bold yellow "$PACKAGE is already installed!"
|
|
pen bold yellow "Exiting now!"
|
|
exit 69
|
|
fi
|
|
|
|
# ─< parse arguments and get variable contents >──────────────────────────────────────────
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--silent | -s)
|
|
silent=true
|
|
;;
|
|
esac
|
|
done
|
|
|
|
main
|
|
fi
|