fixed installation script. like.. hopefully..

This commit is contained in:
pika 2025-03-21 19:31:38 +01:00
parent b35287e645
commit 563ce9f013

View file

@ -1,9 +1,4 @@
#!/bin/sh #!/usr/bin/env bash
# defaults
menu="tofi"
ls="eza"
files="nautilus"
# ANSI color codes # ANSI color codes
RED='\033[0;31m' RED='\033[0;31m'
@ -29,10 +24,6 @@ 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"
} }
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# ─< Check if the given command exists silently >───────────────────────────────────────── # ─< Check if the given command exists silently >─────────────────────────────────────────
command_exists() { command_exists() {
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
@ -96,12 +87,11 @@ silentexec() {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
} }
pre_stow() { __pre_stow__() {
echo_note "pre_stow" echo_note "__pre_stow__"
conf="$HOME/.config" conf="$HOME/.config"
bak_dir="$HOME/.bak" bak_dir="$HOME/.bak"
dirs=" dirs="
alacritty
btop btop
zsh zsh
gBar gBar
@ -133,14 +123,12 @@ pre_stow() {
done done
h_files=" h_files="
.bashrc
.zshrc .zshrc
.tmux.conf .tmux.conf
.wezterm.lua .wezterm.lua
" "
h_dirs=" h_dirs="
.qfc
.tmux .tmux
.zsh .zsh
.icons .icons
@ -165,52 +153,80 @@ pre_stow() {
} }
askThings() { askThings() {
menu=""
ls=""
files=""
echo_info "Choose a menu - [r]ofi || [t]ofi" echo_info "Choose a menu - [r]ofi || [t]ofi"
read -r askMenu </dev/tty read -r askMenu </dev/tty
echo_info "Choose an ls helper - e[z]a || e[x]a || [l]sd" echo_info "Choose a cli filemanager - [y]azi || [r]anger || [l]f"
read -r askLs </dev/tty read -r askFilemgr </dev/tty
echo_info "Choose a filemanager - [n]autilus || [t]hunar || [d]olphin || [c]aja" echo_info "Choose a bar provider - [w]aybar || [g]Bar || [h]yprpanel"
read -r askFiles </dev/tty read -r askBar </dev/tty
case "$askMenu" in echo_info "Choose a Terminal config (.)(.)"
[rR] | rofi) menu="rofi" ;; echo_note "[G]hostty, [K]itty, [A]lacritty"
[tT] | tofi) menu="tofi" ;; read -r askTerminal </dev/tty
esac
case "$askLs" in echo_info "Do you also want to install optional packages? (y/n)"
[zZ] | eza) ls="eza" ;; read -r askOptional </dev/tty
[xX] | exa) ls="exa" ;;
[lL] | lsd) ls="lsd" ;;
esac
case "$askFiles" in case "$askOptional" in
[Nn] | nautilus) files="nautilus" ;; [yY]) __optional__="true" ;;
[Tt] | thunar) files="thunar" ;; [nN]) __optional__="false" ;;
[Dd] | dolphin) files="dolphin" ;;
esac esac
} }
_dep() { cloneDots() {
choise="$1"
if command_exists git; then
[ -d ./dotfiles ] &&
[ ! -d "./dotfiles/${choise}" ] &&
git clone --depth=1 "https://git.k4li.de/dotfiles/${choise}.git" "./dotfiles/.config/${choise}"
else
echo_error "Git was not found"
fi
}
__validate__() {
if askThings; then
case "$askMenu" in
[rR] | rofi) cloneDots "rofi" ;;
[tT] | tofi) cloneDots "tofi" ;;
esac
case "$askFilemgr" in
[yY] | yazi) cloneDots "yazi" ;;
[rR] | ranger) cloneDots "ranger" ;;
[lL] | lf) cloneDots "lf" ;;
esac
case "$askBar" in
[wW] | waybar) cloneDots "waybar" ;;
[gG] | gBar | gbar) cloneDots "gBar" ;;
[hH] | hyprpanel) cloneDots "hyprpanel" ;;
esac
case "$askTerminal" in
[gG] | ghostty) cloneDots "ghostty" ;;
[kK] | kitty) cloneDots "kitty" ;;
[aA] | alacritty) cloneDots "alacritty" ;;
esac
else
exit 1
fi
}
__dep__() {
_depss=" _depss="
wezterm wezterm
btop btop
$menu
$files
$ls
entr entr
yazi
unzip unzip
zip zip
fzf fzf
zoxide zoxide
tmux tmux
thunar
grimshot grimshot
copyq copyq
wlogout wlogout
@ -227,21 +243,19 @@ _dep() {
_monitors() { _monitors() {
if [ ! -e "$HOME/.monitors.conf" ]; then if [ ! -e "$HOME/.monitors.conf" ]; then
local res="$(hyprctl monitors | grep -oP '\d+x\d+@\d+\.\d+' | head -n 1)"
touch "$HOME/.monitors.conf" touch "$HOME/.monitors.conf"
echo "monitor = eDP-1, primary, 0x0, 1" >"$HOME/.monitors.conf" echo "monitor = eDP-1, ${res}, 0x0, 1" >"$HOME/.monitors.conf"
fi fi
} }
_optional() { pkg_optional() {
echo_info "Do you also want to install optional packages? (y/n)"
read -r optional_ </dev/tty
_ops=" _ops="
cowsay cowsay
cmatrix cmatrix
trash-cli trash-cli
" "
case "$optional_" in case "$_ops" in
Y | y) Y | y)
for _o_ in $_ops; do for _o_ in $_ops; do
if command_exists "$_o_"; then if command_exists "$_o_"; then
@ -271,29 +285,15 @@ _optional() {
fi fi
} }
_stow() { __stow__() {
stow --verbose --target="$HOME" --defer=.gitmodules --restow */ stow --verbose --target="$HOME" --defer=.gitmodules --restow */
} }
main() { main() {
check_root check_root
get_packager get_packager
# askThings
terminal="wezterm" __validate__
if ! command_exists "$terminal"; then
echo_warning "$terminal was not found on the system. It's crucial, as the default terminal for this config is $terminal. Would you like to install $terminal and some other dependencies? (y/n): "
read -r _deps
case "$_deps" in
Y | y)
_dep
;;
*)
echo default
;;
esac
fi
if ! command_exists stow; then if ! command_exists stow; then
echo_error "we couldn't find stow on the machine, do you want us to install it? (y/n): " echo_error "we couldn't find stow on the machine, do you want us to install it? (y/n): "
@ -303,17 +303,23 @@ main() {
_install stow _install stow
;; ;;
*) *)
echo default echo_error "You cannot proceed without installing stow! Please install manually"
exit 1
;; ;;
esac esac
else else
echo_info "stow was found, going on to prepare to stow your config" echo_info "stow was found, going on to prepare to stow your config"
sleep 0.3 sleep 0.3
pre_stow
_stow
fi fi
_optional __pre_stow__
__stow__
sleep 2
[ "$__optional__" -eq "true" ] &&
pkg_optional
_monitors _monitors
} }