116 lines
3.7 KiB
Bash
116 lines
3.7 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="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
|
|
"$HOME/.cargo/bin/cargo" install --git https://github.com/neovide/neovide
|
|
else
|
|
cargo install --git https://github.com/neovide/neovide
|
|
fi
|
|
|
|
if [ -e "$HOME/.cargo/bin/neovide" ]; then
|
|
$_sudo ln -rs "$HOME/.cargo/bin/neovide" /bin/neovide
|
|
fi
|
|
}
|
|
|
|
i_arch() {
|
|
deps="base-devel fontconfig freetype2 libglvnd sndio cmake git gtk3 python sdl2 vulkan-intel libxkbcommon-x11"
|
|
for dep in $deps; do
|
|
if ! command_exists $dep; then
|
|
_install "$dep" || echo_error "Couldn't install $dep"
|
|
fi
|
|
done
|
|
}
|
|
|
|
i_debian() {
|
|
deps="curl gnupg ca-certificates git gcc-multilib g++-multilib cmake libssl-dev pkg-config libfreetype6-dev libasound2-dev libexpat1-dev libxcb-composite0-dev libbz2-dev libsndio-dev freeglut3-dev libxmu-dev libxi-dev libfontconfig1-dev libxcursor-dev"
|
|
for dep in $deps; do
|
|
if ! command_exists $dep; then
|
|
silentexec $_sudo apt-get install --assume-yes "$dep" || echo_error "Couldn't install $dep"
|
|
fi
|
|
done
|
|
}
|
|
|
|
i_fedora() {
|
|
deps="fontconfig-devel freetype-devel libX11-xcb libX11-devel libstdc++-static libstdc++-devel dnf-plugins-core"
|
|
for dep in $deps; do
|
|
if ! command_exists $dep; then
|
|
_install "$dep" || echo_error "Couldn't install $dep"
|
|
fi
|
|
done
|
|
$_sudo dnf groupinstall "Development Tools" "Development Libraries"
|
|
}
|
|
|
|
_setup() {
|
|
case "$distro" in
|
|
arch) i_arch ;;
|
|
fedora) i_fedora ;;
|
|
debian | ubuntu) i_debian ;;
|
|
*)
|
|
echo_error "$distro is not supported by this script"
|
|
return 69
|
|
;;
|
|
esac
|
|
}
|
|
|
|
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
|