This commit is contained in:
pika 2025-05-19 08:44:21 +02:00
parent 3ac7e74fae
commit 4c91cc36a8

View file

@ -7,6 +7,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=hyprlock
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
@ -34,19 +58,6 @@ getImports() {
source "$import" source "$import"
sleep 0.2 sleep 0.2
rm "$import" rm "$import"
unset PACKAGE
PACKAGE=hyprlock &&
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() {
@ -163,7 +174,7 @@ cloneAndBuildUtils() {
} }
build() { build() {
echo_info "Building hyprlock" echo_pkg build "Building hyprlock"
run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
run cmake --build ./build --config Release --target hyprlock -j"$cores" run cmake --build ./build --config Release --target hyprlock -j"$cores"
} }
@ -173,11 +184,13 @@ cloneAndBuildLock() {
cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir
echo_pkg git "Cloning hyprlock into $cloneDir/hyprlock"
git clone https://github.com/hyprwm/hyprlock.git && git clone https://github.com/hyprwm/hyprlock.git &&
cd hyprlock cd hyprlock
if build; then if build; then
echo_info "Installing hyprlock.." echo_pkg install "Installing hyprlock.."
$_sudo cmake --install build $_sudo cmake --install build
else else
echo_error "Build has failed for $distro compiling hyprlock" echo_error "Build has failed for $distro compiling hyprlock"
@ -186,6 +199,14 @@ cloneAndBuildLock() {
} }
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 hyprlock _install hyprlock
@ -194,22 +215,12 @@ main() {
cloneAndBuildLock cloneAndBuildLock
;; ;;
*) *)
echo "$distro is not supported by this script!" echo_error "$distro is not supported by this script!"
exit 1 exit 1
;; ;;
esac esac
} }
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