211 lines
4.6 KiB
Bash
211 lines
4.6 KiB
Bash
{
|
|
#!/usr/bin/env bash
|
|
|
|
# ─< 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..
|
|
getImports() {
|
|
local url="$1"
|
|
local import="$(mktemp)"
|
|
if command_exists curl; then
|
|
curl -fsSL $url -o $import
|
|
elif command_exists wget; then
|
|
wget -o $import $url
|
|
else
|
|
echo "curl/wget is required, but missing.."
|
|
exit 69
|
|
fi
|
|
|
|
. "$import"
|
|
sleep 0.1
|
|
|
|
rm -f "$import"
|
|
}
|
|
|
|
ask-stuff() {
|
|
choose multiplexer "Select a multiplexer" tmux zellij </dev/tty
|
|
choose menu "Select a menu package" rofi wofi tofi </dev/tty
|
|
choose shell "Select a shell" zsh bash fish nushell </dev/tty
|
|
|
|
stuff=(
|
|
$multiplexer
|
|
$menu
|
|
$shell
|
|
$package
|
|
)
|
|
}
|
|
|
|
ask-stuff-old() {
|
|
pen bold blue "What multiplexer do you prefer (tmux/zellij)?"
|
|
read -r multiplexer </dev/tty
|
|
|
|
pen bold blue "What menu do you prefer (rofi/tofi/wofi/fuzzel)?"
|
|
read -r menu </dev/tty
|
|
|
|
pen bold blue "What shell do you prefer (zsh/bash/fish)?"
|
|
read -r shell </dev/tty
|
|
|
|
pen bold blue "What packages should also get installed? (space separated list)"
|
|
read -r package </dev/tty
|
|
|
|
case "$multiplexer" in
|
|
t | tmux)
|
|
multiplexer=tmux
|
|
;;
|
|
z | zellij)
|
|
multiplexer=zellij
|
|
;;
|
|
esac
|
|
case "$menu" in
|
|
r | rofi)
|
|
menu=rofi
|
|
;;
|
|
t | tofi)
|
|
menu=tofi
|
|
;;
|
|
w | wofi)
|
|
menu=wofi
|
|
;;
|
|
f | fuzzel)
|
|
menu=fuzzel
|
|
;;
|
|
esac
|
|
case "$shell" in
|
|
z | zsh)
|
|
shell=zsh
|
|
;;
|
|
b | bash)
|
|
shell=bash
|
|
;;
|
|
f | fish)
|
|
shell=fish
|
|
;;
|
|
esac
|
|
|
|
stuff=(
|
|
$multiplexer
|
|
$menu
|
|
$shell
|
|
$package
|
|
)
|
|
}
|
|
|
|
arr=(
|
|
neofetch
|
|
neovim
|
|
btop
|
|
)
|
|
|
|
install-stuff() {
|
|
local err
|
|
|
|
check-and-install ${arr[@]} ${stuff[@]}
|
|
|
|
if confirm "Do you want to remove the previous installed (doesn't inclued the stuff you put in yourself) packages?"; then
|
|
line
|
|
pen grey bold "Packages to remove: $(pen bold red ${#arr[@]})"
|
|
for pkg in "${arr[@]}"; do
|
|
spin "Removing $pkg"
|
|
if run --err err pkg-remove $pkg; then
|
|
upclear
|
|
check "Removed $pkg"
|
|
else
|
|
upclear
|
|
throw "Error removing $pkg"
|
|
echo-error "${err:-}"
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
new() {
|
|
pen bold blue "This is the new version"
|
|
|
|
ask-stuff
|
|
|
|
install-stuff
|
|
}
|
|
|
|
old() {
|
|
ask-stuff-old
|
|
|
|
pen bold red "This is the old version"
|
|
|
|
for pkg in "${arr[@]} ${stuff[@]}"; do
|
|
if ! command-exists $pkg; then
|
|
pen bold blue "Installing $pkg"
|
|
pkg-install $pkg
|
|
else
|
|
pen bold yellow "$pkg is already installed"
|
|
fi
|
|
done
|
|
|
|
pen bold red "Done installing, now removing again.."
|
|
|
|
for pkg in "${arr[@]}"; do
|
|
if command-exists $pkg; then
|
|
pen bold blue "Removing $pkg"
|
|
pkg-remove $pkg
|
|
else
|
|
pen bold yellow "$pkg is not present"
|
|
fi
|
|
done
|
|
}
|
|
|
|
main() {
|
|
choose version "What version do you want to vew?" old new </dev/tty
|
|
|
|
case "$version" in
|
|
old) old ;;
|
|
new) new ;;
|
|
esac
|
|
|
|
line
|
|
|
|
pen bold red "This was the $version version"
|
|
|
|
line
|
|
|
|
if confirm "Do you want to rerun the script?" </dev/tty; then
|
|
line
|
|
echo "----------------------------------------"
|
|
echo "----------------------------------------"
|
|
line
|
|
main
|
|
fi
|
|
|
|
# seek package "What packages should also get installed? space separated list.." </dev/tty
|
|
# if confirm "Do you want to 'install-stuff'?" </dev/tty; then
|
|
# line
|
|
# install-stuff
|
|
# fi
|
|
# for i in {3..6}; do
|
|
# spin grey "Testing $i seconds.."
|
|
# if sleep $i; then
|
|
# upclear
|
|
# check green bold "Successfully waited $i seconds!"
|
|
# # line
|
|
# fi
|
|
# done
|
|
|
|
}
|
|
|
|
dream="https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh"
|
|
if getImports "$dream"; then
|
|
main
|
|
fi
|
|
}
|