aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
blob: 37a702149a913501dae89006f92c3c7625fcacce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e

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 cp target/release/rsp /usr/bin/rsp
sudo chmod +x /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"
        /usr/bin/rsp completions bash > "$dest/rsp"
        echo "  → Bash completions: $dest/rsp"
        ;;
    zsh)
        dest="/usr/share/zsh/site-functions/_rsp"
        /usr/bin/rsp completions zsh | sudo tee "$dest" > /dev/null
        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 <bash|zsh|fish|powershell|elvish>"
        ;;
esac

echo ""
echo "Done!"