#!/usr/bin/zsh

# Find your specific touchscreen device name via: libinput list-devices
# Or leave it generic to catch all touch events.
TARGET_EVENT="TOUCH_DOWN"
SOUND_FILE="/home/josh/battery_sounds/click_sounds/click.mp3"

# Note: Monitoring libinput requires being in the 'input' group or running as root
sudo libinput debug-events | while read -r line; do
    if [[ "$line" == *"$TARGET_EVENT"* ]]; then
        # Play sound asynchronously so it doesn't delay the next click
        paplay "$SOUND_FILE" &!
    fi
done
