78 lines · 2.0 KB · executable
#!/usr/bin/env bash
set -euo pipefail

# Install the local udev hwdb override that marks the ASUS GZ302EA
# detachable touchpad as internal so libinput enables
# disable-while-typing. See hypr/71-touchpad-local.hwdb for details.
#
# Idempotent: exits early if the hwdb file is already installed and
# every detected touchpad is tagged as internal.

SRC="$(cd "$(dirname "$0")/.." && pwd)/hypr/71-touchpad-local.hwdb"
DEST="/etc/udev/hwdb.d/71-touchpad-local.hwdb"

if [[ ! -f "$SRC" ]]; then
	echo "error: source hwdb not found at $SRC" >&2
	exit 1
fi

# Check whether the setup is already in the desired state.
already_set_up() {
	[[ -f "$DEST" ]] || return 1
	cmp -s "$SRC" "$DEST" || return 1

	local found=0
	for ev in /dev/input/event*; do
		udevadm info "$ev" 2>/dev/null | grep -q "ID_INPUT_TOUCHPAD=1" || continue
		found=1
		udevadm info "$ev" 2>/dev/null |
			grep -q "ID_INPUT_TOUCHPAD_INTEGRATION=internal" || return 1
	done
	[[ $found -eq 1 ]]
}

if already_set_up; then
	echo "Touchpad quirk already installed and active. Nothing to do."
	exit 0
fi

SUDO=""
if [[ $EUID -ne 0 ]]; then