#!/usr/bin/env bash # Reverse of install.sh. Leaves user data in ~/.config/sunshine/ alone unless --purge. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=lib/common.sh source "$SCRIPT_DIR/lib/common.sh" # shellcheck source=lib/distro.sh source "$SCRIPT_DIR/lib/distro.sh" detect_distro PURGE=0 KEEP_MOONLIGHT=0 REMOVE_CA_TRUST=0 while [[ $# -gt 0 ]]; do case "$1" in --purge) PURGE=1 ;; --keep-moonlight) KEEP_MOONLIGHT=1 ;; --remove-ca-trust) REMOVE_CA_TRUST=1 ;; -h|--help) cat </dev/null || true systemctl --user disable --now sway-headless.service 2>/dev/null || true step "Removing user lingering (if enabled by us)" if loginctl show-user "$USER" -p Linger --value 2>/dev/null | grep -qx yes; then warn "Lingering is enabled. Leaving it on — other user services may rely on it." warn "Disable manually with: sudo loginctl disable-linger $USER" fi step "Removing packages" case "$DISTRO" in arch) # Remove -debug siblings first so they don't collide with re-installation later. pkg_remove sunshine-debug sunshine-bin-debug sunshine sunshine-bin if [[ $KEEP_MOONLIGHT -eq 0 ]]; then pkg_remove moonlight-qt moonlight-qt-bin fi ;; debian) pkg_remove sunshine if [[ $KEEP_MOONLIGHT -eq 0 ]]; then pkg_remove moonlight-qt fi ;; *) warn "Unknown distro; skipping package removal." ;; esac step "Removing user-installed systemd units + drop-ins" rm -f \ "$HOME/.config/systemd/user/sway-headless.service" \ "$HOME/.config/systemd/user/sunshine.service.d/sway-headless.conf" \ "$HOME/.config/systemd/user/sunshine.service.d/headless-prestart.conf" \ "$HOME/.config/systemd/user/app-dev.lizardbyte.app.Sunshine.service.d/headless-prestart.conf" # Clean empty .d directories rmdir --ignore-fail-on-non-empty \ "$HOME/.config/systemd/user/sunshine.service.d" \ "$HOME/.config/systemd/user/app-dev.lizardbyte.app.Sunshine.service.d" \ 2>/dev/null || true systemctl --user daemon-reload 2>/dev/null || true step "Removing udev rule (if we wrote one)" if [[ -f /etc/udev/rules.d/60-uinput.rules ]]; then as_root rm -f /etc/udev/rules.d/60-uinput.rules as_root udevadm control --reload-rules fi if [[ $REMOVE_CA_TRUST -eq 1 ]]; then step "Removing omarchy-stream CA from system trust store" anchor="$(ca_anchor_path)" if [[ -n "$anchor" && -f "$anchor" ]]; then as_root rm -f "$anchor" ca_update_trust ok "Removed $anchor and refreshed trust store" else info "CA anchor not present; nothing to remove" fi fi if [[ $PURGE -eq 1 ]]; then step "Purging Sunshine + sway-headless user data" rm -rf "$HOME/.config/sunshine" "$HOME/.local/share/sunshine" "$HOME/.local/share/omarchy-moonlight" rm -f "$HOME/.config/sway/config-headless" fi ok "Uninstall complete. Firewall rules and 'input' group membership were left in place." if [[ $REMOVE_CA_TRUST -eq 0 ]]; then info "The omarchy-stream CA was left in the system trust store (--remove-ca-trust to drop it)." fi