This commit is contained in:
pika 2025-05-16 10:16:56 +02:00
parent c7e49404ea
commit 43e88a3223
3 changed files with 53 additions and 31 deletions

View file

@ -84,7 +84,7 @@ getDependencies() {
case "$pkg" in case "$pkg" in
hyprutils) hyprutils)
if checkComp; then if checkComp; then
eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/hyprutils.sh)" eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/hypr/hyprutils.sh)"
fi fi
;; ;;
*) *)

View file

@ -1,10 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PACKAGE=hyprlock
# ─< 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
} }
if command_exists $PACKAGE; then
echo_warning "$PACKAGE is alread installed!"
echo_warning "Exiting now!"
exit 69
fi
# WHY: # WHY:
# This import will give you the following variables: # This import will give you the following variables:
# _sudo="sudo -E" <- only if non root user # _sudo="sudo -E" <- only if non root user
@ -42,20 +50,20 @@ getDependencies() {
# │ You can define dependencies for various linux distros here. It will │ # │ You can define dependencies for various linux distros here. It will │
# │ automagically be pulled via the $pkgArray[$distro] variable │ # │ automagically be pulled via the $pkgArray[$distro] variable │
# ╰─────────────────────────────────────────────────────────────────────────╯ # ╰─────────────────────────────────────────────────────────────────────────╯
depsDebian=(libcairo2-dev mesa-common-dev cmake libgbm-dev libdrm-dev libopengl-dev wayland-protocols wayland-utils libsdbus-c++-dev) depsDebian=(libcairo2-dev mesa-common-dev cmake libgbm-dev libdrm-dev libopengl-dev wayland-protocols wayland-utils libsdbus-c++-dev libhyprlang-dev hyprgraphics)
# depsUbuntu=() # depsUbuntu=()
depsFedora=() # depsFedora=()
depsOpensuse=() # depsOpensuse=()
depsArch=() # depsArch=()
depsAlpine=() # depsAlpine=()
declare -A deps=( declare -A deps=(
[debian]="depsDebian" [debian]="depsDebian"
[ubuntu]="depsUbuntu" # [ubuntu]="depsUbuntu"
[fedora]="depsFedora" # [fedora]="depsFedora"
[arch]="depsArch" # [arch]="depsArch"
[alpine]="depsAlpine" # [alpine]="depsAlpine"
[opensuse]="depsOpensuse" # [opensuse]="depsOpensuse"
) )
# INFO: # INFO:
@ -64,17 +72,43 @@ getDependencies() {
# ╰────────────────────────────────────────────────────────────────╯ # ╰────────────────────────────────────────────────────────────────╯
declare -n pkgArray="${deps[$distro]}" declare -n pkgArray="${deps[$distro]}"
case "$distro" in for pkg in "${pkgArray[@]}"; do
debian | ubuntu | arch | fedora | alpine | opensuse) checkAndInstall "${pkgArray[@]}" ;; case "$pkg" in
*) hyprgraphics)
echo_error "Cannot install for $distro" if checkComp; then
return 69 eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/hypr/hyprgraphics.sh)"
;; fi
esac ;;
*)
if checkComp; then
checkAndInstall "$pkg"
fi
;;
esac
done
}
build() {
echo_info "Building $package"
run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
run cmake --build ./build --config Release --target hyprlock -j$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)
} }
cloneAndBuild() { cloneAndBuild() {
local cloneDir="$(mktemp -d)"
cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir
git clone https://github.com/hyprwm/hyprlock.git &&
cd hyprlock
if build; then
echo_info "Installing $PACKAGE.."
$_sudo cmake --install build
else
echo_error "Build has failed for $distro compiling $package"
return 69
fi
} }
main() { main() {
@ -83,19 +117,7 @@ main() {
_install hyprlock _install hyprlock
;; ;;
debian) debian)
echo "debian" cloneAndBuild
;;
ubuntu)
echo "ubuntu"
;;
fedora)
echo "fedora"
;;
alpine)
echo "alpine"
;;
opensuse)
echo "opensuse"
;; ;;
*) *)
echo "$distro is not supported by this script!" echo "$distro is not supported by this script!"