335 lines
9.2 KiB
Bash
335 lines
9.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
cores="$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)"
|
|
|
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
source-script() {
|
|
local url="$1"
|
|
local import="$(mktemp)"
|
|
|
|
# ─< if $1 is a local file, source this one instead >─────────────────────────────────────
|
|
if [ -f "$url" ]; then
|
|
source "$url"
|
|
sleep 0.1
|
|
return 0
|
|
else
|
|
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
|
|
if command_exists curl; then
|
|
curl -fsSL $url -o $import
|
|
elif command_exists wget; then
|
|
wget -o $import $url
|
|
else
|
|
echo "curl/wget is required, but missing.."
|
|
exit 69
|
|
fi
|
|
|
|
source "$import"
|
|
|
|
echo "${BLUE}Sourcing external script:${NC} $url"
|
|
line
|
|
sleep 0.1
|
|
rm -f "$import"
|
|
fi
|
|
}
|
|
|
|
checkComp() {
|
|
if ! $arch && ! $debian; then
|
|
echo-error "Your distro $distro is not compatible with this script"
|
|
return 69
|
|
fi
|
|
|
|
if $debian; then
|
|
if ! $trixie; then
|
|
echo-error "Your debian version is not compatible with this script"
|
|
return 69
|
|
fi
|
|
fi
|
|
}
|
|
|
|
getDependencies() {
|
|
echo_pkg deps "Checking build dependencies.."
|
|
|
|
# INFO:
|
|
# ╭─────────────────────────────────────────────────────────────────────────╮
|
|
# │ You can define dependencies for various linux distros here. It will │
|
|
# │ automagically be pulled via the $pkgArray[$distro] variable │
|
|
# ╰─────────────────────────────────────────────────────────────────────────╯
|
|
depsDebian=(libpam0g-dev libpugixml-dev libpixman-1-dev libcairo2-dev cmake libxkbcommon-dev wayland-protocols libpango1.0-dev libwayland-client-extra++1 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 hyprgraphics)
|
|
depsArch=(hyprutils hyprlang hyprgraphics)
|
|
# depsUbuntu=()
|
|
# depsFedora=()
|
|
# depsOpensuse=()
|
|
# depsAlpine=()
|
|
|
|
declare -A deps=(
|
|
[debian]="depsDebian"
|
|
[arch]="depsArch"
|
|
# [ubuntu]="depsUbuntu"
|
|
# [fedora]="depsFedora"
|
|
# [alpine]="depsAlpine"
|
|
# [opensuse]="depsOpensuse"
|
|
)
|
|
|
|
# INFO:
|
|
# ╭────────────────────────────────────────────────────────────────╮
|
|
# │ This variable stores the packages you provided for each distro │
|
|
# ╰────────────────────────────────────────────────────────────────╯
|
|
declare -n pkgArray="${deps[$distro]}"
|
|
|
|
case "$distro" in
|
|
arch) check-and-install ${pkgArray[@]} ;;
|
|
debian)
|
|
for pkg in "${pkgArray[@]}"; do
|
|
case "$pkg" in
|
|
hyprgraphics)
|
|
cloneAndBuildUtils
|
|
cloneAndBuildGraphics
|
|
cloneAndBuildScanner
|
|
cloneAndBuildLang
|
|
;;
|
|
*)
|
|
pkg-install $pkg
|
|
;;
|
|
esac
|
|
done
|
|
;;
|
|
*)
|
|
pen bold red "Cannot install currently for $distro!"
|
|
return 69
|
|
;;
|
|
esac
|
|
|
|
# for pkg in "${pkgArray[@]}"; do
|
|
# case "$pkg" in
|
|
# hyprgraphics)
|
|
# case "$distro" in
|
|
# arch) check-and-install hyprgraphics ;;
|
|
# debian)
|
|
# cloneAndBuildUtils
|
|
# cloneAndBuildGraphics
|
|
# cloneAndBuildScanner
|
|
# cloneAndBuildLang
|
|
# ;;
|
|
# esac
|
|
# ;;
|
|
# *)
|
|
# if checkComp; then
|
|
# check-and-install "$pkg"
|
|
# fi
|
|
# ;;
|
|
# esac
|
|
# done
|
|
}
|
|
|
|
buildGraphicsAndUtils() {
|
|
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"$cores"
|
|
}
|
|
|
|
cloneAndBuildGraphics() {
|
|
PACKAGE=hyprgraphics
|
|
|
|
if command_exists $PACKAGE; then
|
|
echo-error "hyprlang is already installed!"
|
|
return 69
|
|
fi
|
|
|
|
local cloneDir="$(mktemp -d)"
|
|
cd $cloneDir || mkdir -p "$cloneDir" && cd "$cloneDir"
|
|
|
|
git clone --depth=1 https://github.com/hyprwm/hyprgraphics.git &&
|
|
cd hyprgraphics
|
|
|
|
if buildGraphicsAndUtils; then
|
|
echo_pkg install
|
|
$_sudo cmake --install build
|
|
else
|
|
echo-error "Build has failed for $distro compiling hyprgraphics"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
cloneAndBuildUtils() {
|
|
PACKAGE=hyprutils
|
|
|
|
if command_exists $PACKAGE; then
|
|
echo-error "hyprlang is already installed!"
|
|
return 69
|
|
fi
|
|
|
|
local cloneDirUtils="$(mktemp -d)"
|
|
# local cloneDir="$HOME/.builds"
|
|
|
|
cd $cloneDirUtils || mkdir -p $cloneDirUtils && cd $cloneDirUtils
|
|
|
|
echo_pkg clone
|
|
|
|
git clone --depth=1 https://github.com/hyprwm/hyprutils.git &&
|
|
cd hyprutils
|
|
|
|
if buildGraphicsAndUtils; then
|
|
echo_pkg install
|
|
$_sudo cmake --install build
|
|
else
|
|
echo-error "Build has failed for $distro compiling hyprutils"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
buildScanner() {
|
|
echo_pkg build "Building hyprwayland-scanner"
|
|
run cmake -DCMAKE_INSTALL_PREFIX=/usr -B build
|
|
run cmake --build build -j $(nproc)
|
|
}
|
|
|
|
cloneAndBuildScanner() {
|
|
PACKAGE=hyprwayland-scanner
|
|
|
|
if command_exists $PACKAGE; then
|
|
echo-error "hyprlang is already installed!"
|
|
return 69
|
|
fi
|
|
|
|
local cloneDir="$(mktemp -d)"
|
|
|
|
cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir
|
|
|
|
echo_pkg git "Cloning hyprwayland-scanner into $cloneDir/hyprwayland-scanner"
|
|
|
|
git clone https://github.com/hyprwm/hyprwayland-scanner &&
|
|
cd hyprwayland-scanner
|
|
|
|
if buildScanner; then
|
|
echo_pkg install
|
|
$_sudo cmake --install build
|
|
else
|
|
echo-error "Build has failed for $distro compiling hyprlock"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
buildLang() {
|
|
echo_pkg build "Building hyprlang"
|
|
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 hyprlang -j$(nproc 2>/dev/null || getconf _NPROCESSORS_CONF)
|
|
}
|
|
|
|
cloneAndBuildLang() {
|
|
PACKAGE=hyprlang
|
|
|
|
if command_exists $PACKAGE; then
|
|
echo-error "hyprlang is already installed!"
|
|
return 69
|
|
fi
|
|
|
|
local cloneDir="$(mktemp -d)"
|
|
|
|
cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir
|
|
|
|
echo_pkg git "Cloning hyprwayland-scanner into $cloneDir/hyprlang"
|
|
|
|
git clone https://github.com/hyprwm/hyprlang.git hyprlang &&
|
|
cd hyprlang
|
|
|
|
if buildLang; then
|
|
echo_pkg install "Installing hyprlang"
|
|
$_sudo cmake --install build
|
|
else
|
|
echo-error "Build has failed for $distro compiling hyprlock"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
build() {
|
|
echo_pkg build "Building hyprlock"
|
|
run cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
|
|
run cmake --build ./build --config Release --target hyprlock -j"$cores"
|
|
}
|
|
|
|
cloneAndBuildLock() {
|
|
PACKAGE=hyprlock
|
|
|
|
local cloneDir="$(mktemp -d)"
|
|
|
|
cd $cloneDir || mkdir -p $cloneDir && cd $cloneDir
|
|
|
|
echo_pkg git "Cloning hyprlock into $cloneDir/hyprlock"
|
|
|
|
git clone https://github.com/hyprwm/hyprlock.git &&
|
|
cd hyprlock
|
|
|
|
if build; then
|
|
echo_pkg install
|
|
$_sudo cmake --install build
|
|
else
|
|
echo-error "Build has failed for $distro compiling hyprlock"
|
|
return 69
|
|
fi
|
|
}
|
|
|
|
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 hyprlock
|
|
;;
|
|
debian)
|
|
cloneAndBuildLock
|
|
;;
|
|
*)
|
|
echo-error "$distro is not supported by this script!"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
setup-env() {
|
|
# local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh
|
|
# local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh
|
|
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
|
|
|
|
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists spin; then
|
|
source-script $dream
|
|
line
|
|
fi
|
|
}
|
|
|
|
if setup-env; then
|
|
# ─< package variable >───────────────────────────────────────────────────────────────────
|
|
unset PACKAGE
|
|
|
|
# ─< argument list variables >────────────────────────────────────────────────────────────
|
|
silent=false
|
|
|
|
sleep 0.1
|
|
|
|
PACKAGE=hyprlock
|
|
if command_exists "$PACKAGE"; then
|
|
echo_warning "$PACKAGE is already installed!"
|
|
echo_warning "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
|
|
|
|
main
|
|
fi
|