#!/usr/bin/env bash set -euo pipefail if (( EUID == 0 )); then printf 'Run as the desktop user, without sudo.\n' >&2 exit 1 fi BIN_DIR="$HOME/.local/bin" SYSTEMD_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" LIB_DIR="$HOME/.local/lib/hyprland-hdmi-revive" SERVICE=revive-monitor-drm-watch.service [[ "$SYSTEMD_DIR" == /* ]] || { printf 'XDG_CONFIG_HOME must be absolute\n' >&2; exit 1; } systemctl --user show-environment >/dev/null # Stop must succeed before removing a running service's files. if systemctl --user cat "$SERVICE" >/dev/null 2>&1; then systemctl --user disable --now "$SERVICE" fi rm -f -- "$SYSTEMD_DIR/$SERVICE" "$BIN_DIR/revive-monitor-fix" "$BIN_DIR/revive-monitor-drm-watch" "$LIB_DIR/common.sh" rmdir -- "$LIB_DIR" 2>/dev/null || true systemctl --user daemon-reload # Never reset failure information for unrelated user services. systemctl --user reset-failed "$SERVICE" 2>/dev/null || true cat <<'MSG' Removed the user service and installed scripts. Preserved config.env and /etc/sudoers.d/revive-monitor-chvt. Remove the Hyprland startup hook and sudoers entry manually if no longer needed. MSG