This commit is contained in:
pika 2025-05-19 10:40:50 +02:00
parent 919384e261
commit c37cdde63f
4 changed files with 78 additions and 53 deletions

View file

@ -5,6 +5,30 @@ command_exists() {
command -v "$@" >/dev/null 2>&1 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: # 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
@ -32,19 +56,6 @@ getImports() {
source "$import" source "$import"
sleep 0.2 sleep 0.2
rm "$import" 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() { checkComp() {
@ -101,7 +112,7 @@ getDependencies() {
} }
build() { 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 --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) 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)" local cloneDir="$(mktemp -d)"
cd $cloneDir || mkdir -p "$cloneDir" && cd "$cloneDir" cd $cloneDir || mkdir -p "$cloneDir" && cd "$cloneDir"
echo_pkg clone
git clone --depth=1 https://github.com/hyprwm/hyprgraphics.git && git clone --depth=1 https://github.com/hyprwm/hyprgraphics.git &&
cd hyprgraphics cd hyprgraphics
if build; then if build; then
echo_info "Installing package.." echo_pkg install "Installing package.."
$_sudo cmake --install build $_sudo cmake --install build
else else
echo_error "Build has failed for $distro compiling $PACKAGE" echo_error "Build has failed for $distro compiling $PACKAGE"
@ -123,6 +135,14 @@ cloneAndInstall() {
} }
main() { main() {
if $silent; then
echo_warning "Executing script silently!"
fi
if ! getDependencies; then
echo_error "Error when installing dependencies.."
fi
case "$distro" in case "$distro" in
arch) arch)
_install hyprgraphics _install hyprgraphics
@ -134,15 +154,5 @@ main() {
} }
if getImports; then if getImports; then
case "$@" in
--silent | -s)
silent=true
echo_warning "Running script silently!"
;;
*)
silent=false
;;
esac
getDependencies
main main
fi fi

View file

@ -5,6 +5,30 @@ command_exists() {
command -v "$@" >/dev/null 2>&1 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: # 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
@ -32,23 +56,10 @@ getImports() {
source "$import" source "$import"
sleep 0.2 sleep 0.2
rm "$import" 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() { getDependencies() {
echo_info "Checking build dependencies.." echo_pkg deps "Checking build dependencies.."
# INFO: # INFO:
# ╭─────────────────────────────────────────────────────────────────────────╮ # ╭─────────────────────────────────────────────────────────────────────────╮
@ -84,7 +95,7 @@ getDependencies() {
} }
build() { 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 --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) 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 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 && git clone --depth=1 https://github.com/hyprwm/hyprutils.git &&
cd hyprutils cd hyprutils
if build; then if build; then
echo_info "Installing package.." echo_pkg install "Installing package.."
$_sudo cmake --install build $_sudo cmake --install build
else else
echo_error "Build has failed for $distro compiling $package" echo_error "Build has failed for $distro compiling $package"
@ -109,6 +120,14 @@ cloneAndInstall() {
} }
main() { main() {
if $silent; then
echo_warning "Executing script silently!"
fi
if ! getDependencies; then
echo_error "Error when installing dependencies.."
fi
case "$distro" in case "$distro" in
arch) arch)
_install hyprutils _install hyprutils
@ -127,13 +146,5 @@ checkComp() {
} }
if getImports; then if getImports; then
silent=false
case "$@" in
--silent | -s)
silent=true
echo_warning "Running script silently!"
;;
esac
getDependencies
main main
fi fi

View file

@ -19,8 +19,8 @@ sleep 0.1
PACKAGE=hyprland PACKAGE=hyprland
if command_exists "$PACKAGE"; then if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!" echo "$PACKAGE is already installed!"
echo_warning "Exiting now!" echo "Exiting now!"
exit 69 exit 69
fi fi

View file

@ -76,12 +76,16 @@ getDependencies() {
"nano" "nano"
) )
depsDebian=() depsDebian=(
"eza"
)
depsFedora=() depsFedora=()
depsOpensuse=() depsOpensuse=()
depsArch=( depsArch=(
"tldr" "tldr"
"oh-my-posh" "oh-my-posh"
"eza"
) )
depsAlpine=() depsAlpine=()