From 9c879b5f3f2fef52cce4e2cf754924fcdfbd30cf Mon Sep 17 00:00:00 2001 From: pika Date: Fri, 16 May 2025 10:59:23 +0200 Subject: [PATCH] wip --- hyprlock.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/hyprlock.sh b/hyprlock.sh index a44eb3b..32bce2e 100644 --- a/hyprlock.sh +++ b/hyprlock.sh @@ -62,18 +62,18 @@ 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 libhyprlang-dev hyprgraphics) + depsDebian=(libpixman-1-dev libcairo2-dev cmake wayland-protocols libwebp-dev libjpeg-dev libspng-dev libmagic-dev libcairo2-dev mesa-common-dev cmake libgbm-dev libdrm-dev libopengl-dev wayland-protocols wayland-utils libsdbus-c++-dev libhyprlang-dev hyprgraphics) + depsArch=(hyprutils hyprgraphics) # depsUbuntu=() # depsFedora=() # depsOpensuse=() - # depsArch=() # depsAlpine=() declare -A deps=( [debian]="depsDebian" + [arch]="depsArch" # [ubuntu]="depsUbuntu" # [fedora]="depsFedora" - # [arch]="depsArch" # [alpine]="depsAlpine" # [opensuse]="depsOpensuse" ) @@ -87,9 +87,15 @@ getDependencies() { 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 + case "$distro" in + arch) checkAndInstall hyprgraphics ;; + debian) + if ! command_exists hyprutils; then + cloneAndBuildUtils && + cloneAndBuildGraphics + fi + ;; + esac ;; *) if checkComp; then @@ -100,13 +106,60 @@ getDependencies() { done } +buildGraphics() { + echo_info "Building hyprgraphics" + run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build + run cmake --build ./build --config Release --target all -j$(nproc 2>/dev/null || getconf NPROCESSORS_CONF) +} + +cloneAndBuildGraphics() { + local cloneDir="$(mktemp -d)" + cd $cloneDir || mkdir -p "$cloneDir" && cd "$cloneDir" + + git clone --depth=1 https://github.com/hyprwm/hyprgraphics.git && + cd hyprgraphics + + if build; then + echo_info "Installing package.." + $_sudo cmake --install build + else + echo_error "Build has failed for $distro compiling $PACKAGE" + return 69 + fi +} + +buildUtils() { + echo_info "Building hyprutils" + run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build + run cmake --build ./build --config Release --target all -j$(nproc 2>/dev/null || getconf NPROCESSORS_CONF) +} + +cloneAndBuildUtils() { + local cloneDir="$(mktemp -d)" + # local cloneDir="$HOME/.builds" + + cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir + + echo_info "Cloning sources for $PACKAGE into $cloneDir/$PACKAGE" + git clone --depth=1 https://github.com/hyprwm/hyprutils.git && + cd hyprutils + + if build; then + echo_info "Installing package.." + $_sudo cmake --install build + else + echo_error "Build has failed for $distro compiling $package" + return 69 + fi +} + 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() { +cloneAndBuildLock() { local cloneDir="$(mktemp -d)" cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir @@ -126,10 +179,18 @@ cloneAndBuild() { main() { case "$distro" in arch) - _install hyprlock + _install hyprlock hyprgraphics hyprutils ;; debian) - cloneAndBuild + if ! command_exists hyprutils; then + cloneAndBuildUtils + fi + + if ! command_exists hyprgraphics; then + cloneAndBuildGraphics + fi + + cloneAndBuildLock ;; *) echo "$distro is not supported by this script!"