101 lines
2.6 KiB
Bash
101 lines
2.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
|
|
)
|
|
}
|
|
|
|
install-stuff() {
|
|
ask-stuff
|
|
local err
|
|
|
|
arr=(
|
|
nautilus
|
|
firefox-esr
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
main() {
|
|
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
|
|
}
|