#!/usr/bin/env bash # uninstall-linux-x11.sh — remove ahfail PAM module from X11 screen lockers # Run from the repository root (uses ninja uninstall if builddir is present). set -euo pipefail BOLD=$(tput bold 2>/dev/null || true) RESET=$(tput sgr0 2>/dev/null || true) step() { echo "${BOLD}==> $*${RESET}"; } [[ "$(uname)" == "Linux" ]] || { echo "This script is for Linux only." >&2; exit 1; } # ── 1. Remove PAM config lines ──────────────────────────────────────────────── step "Removing ahfail from PAM service files..." removed_pam=0 for pam_file in /etc/pam.d/i3lock /etc/pam.d/xscreensaver /etc/pam.d/lightdm \ /etc/pam.d/gdm /etc/pam.d/sddm /etc/pam.d/gtklock; do if [[ -f "$pam_file" ]] && grep -q "ahfail" "$pam_file"; then echo " Patching ${pam_file}..." sudo sed -i '/ahfail/d' "$pam_file" removed_pam=1 fi done [[ $removed_pam -eq 0 ]] && echo " No ahfail PAM entries found in common service files." # ── 2. Remove installed files ───────────────────────────────────────────────── step "Removing installed files..." # Prefer meson's own uninstall if the builddir is still present SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUILDDIR="${SCRIPT_DIR}/../builddir" if [[ -f "${BUILDDIR}/build.ninja" ]]; then echo " Running meson uninstall..." sudo ninja -C "$BUILDDIR" uninstall else echo " builddir not found — removing known paths manually..." for dir in /usr/lib/ahfail /usr/local/lib/ahfail \ /usr/lib64/ahfail /usr/lib/x86_64-linux-gnu/ahfail; do if [[ -d "$dir" ]]; then sudo rm -rf "$dir" echo " Removed ${dir}." fi done for f in /usr/lib/gtklock/ahfail-module.so \ /usr/local/lib/gtklock/ahfail-module.so; do if [[ -f "$f" ]]; then sudo rm -f "$f" echo " Removed ${f}." fi done fi echo "" echo "${BOLD}Done.${RESET}"