From c37cdde63f7f3f7d3411a26251ec32a461499883 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 19 May 2025 10:40:50 +0200 Subject: [PATCH] testing --- hypr/hyprgraphics.sh | 60 +++++++++++++++++++++++++------------------ hypr/hyprutils.sh | 61 ++++++++++++++++++++++++++------------------ hyprland.sh | 4 +-- postinstall.sh | 6 ++++- 4 files changed, 78 insertions(+), 53 deletions(-) diff --git a/hypr/hyprgraphics.sh b/hypr/hyprgraphics.sh index 9a380b3..2491522 100644 --- a/hypr/hyprgraphics.sh +++ b/hypr/hyprgraphics.sh @@ -5,6 +5,30 @@ command_exists() { command -v "$@" >/dev/null 2>&1 } +# ─< package variable >─────────────────────────────────────────────────────────────────── +unset PACKAGE + +# ─< argument list variables >──────────────────────────────────────────────────────────── +silent=false + +sleep 0.1 + +PACKAGE=hyprgraphics +if command_exists "$PACKAGE"; then + echo "$PACKAGE is already installed!" + echo "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 + # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user @@ -32,19 +56,6 @@ getImports() { source "$import" sleep 0.2 rm "$import" - - unset PACKAGE - - PACKAGE=hyprgraphics && - echo_note "Installing $PACKAGE.." - - sleep 1 - - if command_exists $PACKAGE; then - echo_warning "$PACKAGE is alread installed!" - echo_warning "Exiting now!" - exit 69 - fi } checkComp() { @@ -101,7 +112,7 @@ getDependencies() { } build() { - echo_info "Building $PACKAGE" + echo_pkg build 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) } @@ -110,11 +121,12 @@ cloneAndInstall() { local cloneDir="$(mktemp -d)" cd $cloneDir || mkdir -p "$cloneDir" && cd "$cloneDir" + echo_pkg clone git clone --depth=1 https://github.com/hyprwm/hyprgraphics.git && cd hyprgraphics if build; then - echo_info "Installing package.." + echo_pkg install "Installing package.." $_sudo cmake --install build else echo_error "Build has failed for $distro compiling $PACKAGE" @@ -123,6 +135,14 @@ cloneAndInstall() { } main() { + if $silent; then + echo_warning "Executing script silently!" + fi + + if ! getDependencies; then + echo_error "Error when installing dependencies.." + fi + case "$distro" in arch) _install hyprgraphics @@ -134,15 +154,5 @@ main() { } if getImports; then - case "$@" in - --silent | -s) - silent=true - echo_warning "Running script silently!" - ;; - *) - silent=false - ;; - esac - getDependencies main fi diff --git a/hypr/hyprutils.sh b/hypr/hyprutils.sh index 2044190..ae070a3 100644 --- a/hypr/hyprutils.sh +++ b/hypr/hyprutils.sh @@ -5,6 +5,30 @@ command_exists() { command -v "$@" >/dev/null 2>&1 } +# ─< package variable >─────────────────────────────────────────────────────────────────── +unset PACKAGE + +# ─< argument list variables >──────────────────────────────────────────────────────────── +silent=false + +sleep 0.1 + +PACKAGE=hyprutils +if command_exists "$PACKAGE"; then + echo "$PACKAGE is already installed!" + echo "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 + # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user @@ -32,23 +56,10 @@ getImports() { source "$import" sleep 0.2 rm "$import" - - unset PACKAGE - - PACKAGE=hyprutils && - echo_note "Installing $PACKAGE.." - - sleep 1 - - if command_exists $PACKAGE; then - echo_warning "$PACKAGE is alread installed!" - echo_warning "Exiting now!" - exit 69 - fi } getDependencies() { - echo_info "Checking build dependencies.." + echo_pkg deps "Checking build dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ @@ -84,7 +95,7 @@ getDependencies() { } build() { - echo_info "Building $package" + echo_pkg build 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) } @@ -95,12 +106,12 @@ cloneAndInstall() { cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir - echo_info "Cloning sources for $PACKAGE into $cloneDir/$PACKAGE" + echo_pkg clone git clone --depth=1 https://github.com/hyprwm/hyprutils.git && cd hyprutils if build; then - echo_info "Installing package.." + echo_pkg install "Installing package.." $_sudo cmake --install build else echo_error "Build has failed for $distro compiling $package" @@ -109,6 +120,14 @@ cloneAndInstall() { } main() { + if $silent; then + echo_warning "Executing script silently!" + fi + + if ! getDependencies; then + echo_error "Error when installing dependencies.." + fi + case "$distro" in arch) _install hyprutils @@ -127,13 +146,5 @@ checkComp() { } if getImports; then - silent=false - case "$@" in - --silent | -s) - silent=true - echo_warning "Running script silently!" - ;; - esac - getDependencies main fi diff --git a/hyprland.sh b/hyprland.sh index 5814e3b..a3c3767 100644 --- a/hyprland.sh +++ b/hyprland.sh @@ -19,8 +19,8 @@ sleep 0.1 PACKAGE=hyprland if command_exists "$PACKAGE"; then - echo_warning "$PACKAGE is already installed!" - echo_warning "Exiting now!" + echo "$PACKAGE is already installed!" + echo "Exiting now!" exit 69 fi diff --git a/postinstall.sh b/postinstall.sh index a24c2bd..649432d 100644 --- a/postinstall.sh +++ b/postinstall.sh @@ -76,12 +76,16 @@ getDependencies() { "nano" ) - depsDebian=() + depsDebian=( + "eza" + ) + depsFedora=() depsOpensuse=() depsArch=( "tldr" "oh-my-posh" + "eza" ) depsAlpine=()