caelestia-niri/scripts/02-build-shell.sh

35 lines
1.7 KiB
Shell
Executable file

#!/usr/bin/env bash
# Builds the shell and CLI (cargo, release) and installs them with the assets. The
# original builds a C++ plugin and Quickshell config here; ours is two binaries.
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/lib/log.sh"
BUNDLE_DIR="${BUNDLE_DIR:?BUNDLE_DIR not set}"
BIN="${CAELESTIA_BIN:-$HOME/.local/bin}"
DATA="${XDG_DATA_HOME:-$HOME/.local/share}/caelestia-niri"
echo
[[ -x "$BUNDLE_DIR/bin/caelestia-shell" ]] || command -v cargo >/dev/null 2>&1 || die "cargo is not installed (pacman -S rust, or https://rustup.rs)"
mkdir -p "$BIN"
if [[ -x "$BUNDLE_DIR/bin/caelestia-shell" ]]; then
# A release carries its binaries, so it needs no compiler.
install -m755 "$BUNDLE_DIR/bin/caelestia" "$BUNDLE_DIR/bin/caelestia-shell" "$BIN/"
else
build() { cd "$BUNDLE_DIR" && { cargo build --release --locked || cargo build --release; }; }
ui_run "Compiling (a first build takes a few minutes)" build || die "build failed"
install -m755 "$BUNDLE_DIR/target/release/caelestia" "$BUNDLE_DIR/target/release/caelestia-shell" "$BIN/"
fi
rm -rf "$DATA"
mkdir -p "$DATA"
cp -r "$BUNDLE_DIR/assets/." "$DATA/"
# The shell reads these from its data dir and says nothing when one is missing.
for need in sounds/notifications fonts/GoogleSansFlex.ttf images/dino_ground.png nexus/pages.json; do
[[ -e "$DATA/$need" ]] || warn "$DATA/$need is missing: sounds, fonts or pictures will not show"
done
if [[ -n "${CAELESTIA_DATA_DIR:-}" && "$CAELESTIA_DATA_DIR" != "$DATA" ]]; then
warn "CAELESTIA_DATA_DIR is $CAELESTIA_DATA_DIR, so the shell reads that and not $DATA"
fi
ok "Installed caelestia and caelestia-shell to $BIN, assets to $DATA"
case ":$PATH:" in *":$BIN:"*) ;; *) warn "$BIN is not on your PATH" ;; esac