#!/bin/bash # This file is a part of RSPlayer # Licensed under the GPL-3.0 License # Copyright (C) 2026 Salmonik @ salmonik@tuta.io # https://codeberg.org/salmonik/RSPlayer set -e if ping -W 2 -c 1 codeberg.org >&/dev/null; then echo "Updating the repo..." git pull 2>/dev/null fi echo "Building rsplayer in release mode..." cargo build --release echo "Stopping existing daemon..." systemctl --user stop rsplayer 2>/dev/null || true rsp stop-daemon 2>/dev/null || true echo "Installing to /usr/bin/rsp..." sudo install target/release/rsp /usr/bin/rsp echo "" echo "Installing systemd service..." mkdir -p ~/.config/systemd/user cp rsplayer.service ~/.config/systemd/user/ if systemctl --user is-active default.target &>/dev/null; then systemctl --user daemon-reload echo "Activating the daemon…" systemctl --user restart --now rsplayer.service else echo "Service installed but not enabled (no user session running)" echo "To enable later when logged in: systemctl --user enable rsplayer" fi echo "" echo "Installing shell completions..." shell_name=$(basename "${SHELL:-}") case "$shell_name" in bash) dest="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" mkdir -p "$dest" cp completions/rsp.bash "$dest/rsp" echo " → Bash completions: $dest/rsp" ;; zsh) dest="/usr/share/zsh/site-functions/_rsp" tmpfile=$(mktemp) /usr/bin/rsp completions zsh > "$tmpfile" cat completions/_rsp >> "$tmpfile" sudo cp "$tmpfile" "$dest" rm -f "$tmpfile" echo " → Zsh completions: $dest" ;; fish) dest="$HOME/.config/fish/completions/rsp.fish" mkdir -p "$(dirname "$dest")" /usr/bin/rsp completions fish > "$dest" echo " → Fish completions: $dest" ;; *) echo " → Unrecognized shell '$shell_name'; generate with: rsp completions " ;; esac echo "" echo "Done!"