Files
dotfiles/hypr/scripts/setup.sh
T
2026-09-20 14:40:45 +02:00

120 lines
3.9 KiB
Bash

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PACKAGES_FILE="$SCRIPT_DIR/packages.txt"
# ---------------------------------------------------------------------------
# Read packages.txt, split into pacman / aur / npm sections.
# ---------------------------------------------------------------------------
read_packages() {
local section="pacman"
local current
current=""
while IFS= read -r line || [[ -n "$line" ]]; do
current="${line%%#*}"
current="${current##*( )}"
current="${current%%*( )}"
[[ -z "$current" ]] && continue
case "$current" in
@pacman) section="pacman" ;;
@aur) section="aur" ;;
@npm) section="npm" ;;
*)
case "$section" in
pacman) pacman_pkgs+=("$current") ;;
aur) aur_pkgs+=("$current") ;;
npm) npm_pkgs+=("$current") ;;
esac
;;
esac
done < "$PACKAGES_FILE"
}
declare -a pacman_pkgs=() aur_pkgs=() npm_pkgs=()
# ---------------------------------------------------------------------------
# Install sections.
# ---------------------------------------------------------------------------
install_pacman() {
if ((${#pacman_pkgs[@]})); then
echo "==> Installiere Pacman-Pakete: ${pacman_pkgs[*]}"
yay -S --needed "${pacman_pkgs[@]}"
fi
}
install_aur() {
if ((${#aur_pkgs[@]})); then
echo "==> Installiere AUR-Pakete: ${aur_pkgs[*]}"
yay -S --needed "${aur_pkgs[@]}"
fi
}
install_npm() {
if ((${#npm_pkgs[@]})); then
echo "==> Installiere globale npm-Pakete: ${npm_pkgs[*]}"
npm install -g "${npm_pkgs[@]}"
fi
}
# ---------------------------------------------------------------------------
# Post-install: hyprltm (network manager) via upstream script.
# ---------------------------------------------------------------------------
install_hyprltm() {
if command -v hyprltm >/dev/null 2>&1; then
echo "hyprltm bereits installiert; fahre fort."
return
fi
echo "Installiere hyprltm (Network Manager) ..."
curl -s https://raw.githubusercontent.com/hyprltm/hyprltm-net/main/setup.sh | bash
}
# ---------------------------------------------------------------------------
# Post-install: ensure fish PATH includes ~/.local/bin (for hyprltm).
# ---------------------------------------------------------------------------
add_fish_local_bin_path() {
local fish_config="$HOME/.config/fish/config.fish"
if [[ -f "$fish_config" ]] && grep -q '\$HOME/.local/bin' "$fish_config"; then
echo "fish ~/.local/bin PATH bereits gesetzt; fahre fort."
return
fi
echo "Fuege ~/.local/bin zum fish-PATH hinzu ..."
echo 'fish_add_path -m $HOME/.local/bin' >> "$fish_config"
}
# ---------------------------------------------------------------------------
# Post-install: run Hyprland environment & desktop integration scripts.
# ---------------------------------------------------------------------------
run_hypr_scripts() {
local scripts_dir="$SCRIPT_DIR/../.config/hypr/scripts"
echo "==> Fuehre ensure-env.sh aus ..."
bash "$scripts_dir/ensure-env.sh"
echo "==> Fuehre portal-host-override.sh aus ..."
bash "$scripts_dir/portal-host-override.sh"
echo "==> Fuehre fix_dolphin_file_associations.sh aus ..."
bash "$scripts_dir/fix_dolphin_file_associations.sh"
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
main() {
echo "==> Lese Paketliste: $PACKAGES_FILE"
read_packages
install_pacman
install_aur
install_npm
install_hyprltm
add_fish_local_bin_path
run_hypr_scripts
echo "Fertig. Hyprland und das Compositor-Okosystem sind eingerichtet."
}
main