From 43e88a3223d333f7451043322f95e2f1f61b0303 Mon Sep 17 00:00:00 2001 From: pika Date: Fri, 16 May 2025 10:16:56 +0200 Subject: [PATCH] wip --- hyprgraphics.sh => hypr/hyprgraphics.sh | 2 +- hyprutils.sh => hypr/hyprutils.sh | 0 hyprlock.sh | 82 ++++++++++++++++--------- 3 files changed, 53 insertions(+), 31 deletions(-) rename hyprgraphics.sh => hypr/hyprgraphics.sh (99%) rename hyprutils.sh => hypr/hyprutils.sh (100%) diff --git a/hyprgraphics.sh b/hypr/hyprgraphics.sh similarity index 99% rename from hyprgraphics.sh rename to hypr/hyprgraphics.sh index c1de553..f81f276 100644 --- a/hyprgraphics.sh +++ b/hypr/hyprgraphics.sh @@ -84,7 +84,7 @@ getDependencies() { case "$pkg" in hyprutils) 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 ;; *) diff --git a/hyprutils.sh b/hypr/hyprutils.sh similarity index 100% rename from hyprutils.sh rename to hypr/hyprutils.sh diff --git a/hyprlock.sh b/hyprlock.sh index 695b010..5ec0a38 100644 --- a/hyprlock.sh +++ b/hyprlock.sh @@ -1,10 +1,18 @@ #!/usr/bin/env bash +PACKAGE=hyprlock + # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { 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: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user @@ -42,20 +50,20 @@ getDependencies() { # │ You can define dependencies for various linux distros here. It will │ # │ 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=() - depsFedora=() - depsOpensuse=() - depsArch=() - depsAlpine=() + # depsFedora=() + # depsOpensuse=() + # depsArch=() + # depsAlpine=() declare -A deps=( [debian]="depsDebian" - [ubuntu]="depsUbuntu" - [fedora]="depsFedora" - [arch]="depsArch" - [alpine]="depsAlpine" - [opensuse]="depsOpensuse" + # [ubuntu]="depsUbuntu" + # [fedora]="depsFedora" + # [arch]="depsArch" + # [alpine]="depsAlpine" + # [opensuse]="depsOpensuse" ) # INFO: @@ -64,17 +72,43 @@ getDependencies() { # ╰────────────────────────────────────────────────────────────────╯ declare -n pkgArray="${deps[$distro]}" - case "$distro" in - debian | ubuntu | arch | fedora | alpine | opensuse) checkAndInstall "${pkgArray[@]}" ;; - *) - echo_error "Cannot install for $distro" - return 69 - ;; - esac + for pkg in "${pkgArray[@]}"; do + case "$pkg" in + hyprgraphics) + if checkComp; then + eval "$(curl -fsSL https://git.k4li.de/scripts/installs/raw/branch/main/hypr/hyprgraphics.sh)" + fi + ;; + *) + 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() { + 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() { @@ -83,19 +117,7 @@ main() { _install hyprlock ;; debian) - echo "debian" - ;; - ubuntu) - echo "ubuntu" - ;; - fedora) - echo "fedora" - ;; - alpine) - echo "alpine" - ;; - opensuse) - echo "opensuse" + cloneAndBuild ;; *) echo "$distro is not supported by this script!"