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
}
# ─< 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