#!/bin/sh # SPDX-License-Identifier: GPL-3.0-or-later # hypr-live-update-guard - abort a live GPU/compositor library upgrade. # # Installed as a pacman PreTransaction hook. When an upgrade transaction # includes GPU/compositor runtime libraries (mesa, hyprland, wayland, GPU # drivers, ...) AND a Hyprland session is running, this aborts the # transaction BEFORE any package is swapped. Replacing those libraries out # from under a live compositor makes the next GPU-lib call hit a now # "(deleted)" file and SIGABRT, taking the Wayland clients down with it # (hit on ratio 2026-06-07: mesa + hyprland upgraded live, Hyprland crashed # and took awww/insync/emacs with it). Aborting at PreTransaction is the # safe point: nothing has been replaced yet, so the running session is # untouched and the user can re-run the upgrade from a TTY. # # Pacman feeds the matched package names on stdin (NeedsTargets). # # Test seams / overrides (env): # HYPR_GUARD_RUNNING 1/0 forces the running check (default: pgrep Hyprland) # HYPR_ALLOW_LIVE_UPDATE 1 proceeds anyway (skip the guard) # HYPR_GUARD_SENTINEL path whose existence also proceeds anyway # (default /run/archsetup-allow-live-gpu-update, # cleared on reboot since /run is tmpfs) set -u sentinel="${HYPR_GUARD_SENTINEL:-/run/archsetup-allow-live-gpu-update}" # Explicit override: the user knows what they're doing. if [ "${HYPR_ALLOW_LIVE_UPDATE:-0}" = "1" ] || [ -e "$sentinel" ]; then exit 0 fi hyprland_running() { if [ -n "${HYPR_GUARD_RUNNING:-}" ]; then [ "$HYPR_GUARD_RUNNING" = "1" ] return fi pgrep -x Hyprland >/dev/null 2>&1 } # No live session means no live swap to worry about. Let the upgrade run -- # this is exactly the from-a-TTY-after-logout path the warning points to. hyprland_running || exit 0 # Collect the triggering packages (stdin from NeedsTargets) for the message. pkgs=$(cat 2>/dev/null | sort -u | tr '\n' ' ') cat >&2 <