This commit is contained in:
pika 2025-05-19 18:36:16 +02:00
parent 18ef26e1df
commit 35f5f379f7

View file

@ -1,5 +1,39 @@
#!/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="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
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
source "$import"
sleep 0.1
rm -f "$import"
}
installNeovide() {
if ! command_exists cargo; then
curl --proto '=https' --tlsv1.2 -sSf "https://sh.rustup.rs" | sh
@ -41,7 +75,7 @@ i_fedora() {
$_sudo dnf groupinstall "Development Tools" "Development Libraries"
}
setup() {
_setup() {
case "$distro" in
arch) i_arch ;;
fedora) i_fedora ;;
@ -53,6 +87,30 @@ setup() {
esac
}
if setup; then
if getImports; then
# ─< package variable >───────────────────────────────────────────────────────────────────
unset PACKAGE
# ─< argument list variables >────────────────────────────────────────────────────────────
unset silent
sleep 0.1
PACKAGE=hyprpolkit-agent
if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!"
echo_warning "Exiting now!"
exit 69
fi
# ─< parse arguments and get variable contents >──────────────────────────────────────────
for arg in "$@"; do
case "$arg" in
--silent | -s)
export silent=true
;;
esac
done
_setup
installNeovide
fi