82 lines
3.7 KiB
Shell
Executable file
82 lines
3.7 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# What a bare niri session lacks to be a usable desktop, installed by group: build tools,
|
|
# desktop plumbing (portals, polkit, keyring), audio/network services, the tools the shell
|
|
# shells out to, and fonts/icons/themes, plus what was ticked on the Setup page. They go in as
|
|
# one transaction, after one password.
|
|
|
|
set -euo pipefail
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/log.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/privileges.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/packages.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/selection.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/package-sets.sh"
|
|
|
|
echo
|
|
info "Checking what a niri desktop needs ($BASE_DISTRO)"
|
|
|
|
# Files and commands that are not plain packages on every distro.
|
|
GROUPS_ORDER=(BUILD DESKTOP SERVICES TOOLS THEME)
|
|
declare -A GROUP_LABEL=(
|
|
[BUILD]="Build tools (to compile the shell)"
|
|
[DESKTOP]="Desktop plumbing (compositor extras, portals, polkit, keyring)"
|
|
[SERVICES]="Audio, network, bluetooth, power, brightness"
|
|
[TOOLS]="Tools the shell uses (clipboard, capture, colours, visualiser, lyrics)"
|
|
[THEME]="Fonts, icons and themes"
|
|
)
|
|
|
|
if [[ "$BASE_DISTRO" == "unknown" ]]; then
|
|
warn "Unknown distribution: install the packages listed in scripts/lib/package-sets.sh yourself."
|
|
exit 0
|
|
fi
|
|
|
|
# What the groups and the ticked options want, all together. Build tools are noted, so they can
|
|
# go again afterwards. A compiler already here, or binaries from a release, means none is added.
|
|
state="${XDG_CACHE_HOME:-$HOME/.cache}/caelestia-niri"
|
|
mkdir -p "$state"
|
|
: >"$state/build-added"
|
|
need=()
|
|
for group in "${GROUPS_ORDER[@]}"; do
|
|
[[ " ${SKIP_GROUPS:-} " != *" $group "* ]] || continue
|
|
if [[ "$group" == BUILD && -x "$BUNDLE_DIR/bin/caelestia-shell" ]]; then continue; fi
|
|
while IFS='|' read -r why pkg; do
|
|
[[ -n "${pkg:-}" ]] || continue
|
|
if [[ "$pkg" =~ ^(rust|cargo)$ ]] && command -v cargo >/dev/null 2>&1; then continue; fi
|
|
package_present "$pkg" && continue
|
|
need+=("$pkg")
|
|
if [[ "$group" == BUILD ]]; then echo "$pkg" >>"$state/build-added"; fi
|
|
done < <(package_set "$group")
|
|
done
|
|
need+=(${APPS_ON:-})
|
|
for option in ${OPTIONS-terminal portals keyring qt automount nightlight clipboard recording ocr annotate cursor monitors lock}; do
|
|
for pkg in $(option_packages "$option"); do
|
|
package_present "$pkg" || need+=("$pkg")
|
|
done
|
|
done
|
|
mapfile -t need < <(printf '%s\n' "${need[@]+"${need[@]}"}" | sed '/^$/d' | sort -u)
|
|
if ((${#need[@]})); then
|
|
info "To install: ${need[*]}"
|
|
caelestia_prime_sudo || true
|
|
install_bulk "${need[@]}"
|
|
else
|
|
ok "Everything needed is already here."
|
|
fi
|
|
|
|
# Fedora and Debian have no package for this one.
|
|
if [[ " ${OPTIONS-clipboard} " == *" clipboard "* ]] && ! command -v wl-clip-persist >/dev/null 2>&1 && command -v cargo >/dev/null 2>&1; then
|
|
ui_run "Building wl-clip-persist" cargo install wl-clip-persist --root "$HOME/.local" || warn "wl-clip-persist is missing: copies are lost when the app they came from closes"
|
|
fi
|
|
|
|
# Services a desktop expects to be running.
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
for unit in NetworkManager bluetooth power-profiles-daemon; do
|
|
systemctl list-unit-files "$unit.service" >/dev/null 2>&1 &&
|
|
! systemctl is-enabled --quiet "$unit.service" 2>/dev/null &&
|
|
{ [[ "${ASSUME_YES:-0}" == 1 ]] || read -r -p " Enable $unit.service? [Y/n] " a </dev/tty; [[ "${a:-y}" =~ ^[Yy] ]]; } &&
|
|
caelestia_sudo systemctl enable --now "$unit.service" || true
|
|
done
|
|
systemctl --user enable --now pipewire pipewire-pulse wireplumber >/dev/null 2>&1 || true
|
|
fi
|
|
command -v xdg-user-dirs-update >/dev/null 2>&1 && xdg-user-dirs-update || true
|
|
|
|
caelestia_stop_sudo_keepalive
|
|
ok "Prerequisites done."
|