This script allows one to enable and disable the touchpad on niri, which relies on the niri configuration file having either of the values shown below.

//off // touchpad enabled
off // touchpad disabled

The script does a grep for touchpad enabled and acts accordingly.

#!/bin/bash
FILE="/home/karmst/.config/niri/input.kdl"

# cmd=$(grep -E "touchpad enabled" $FILE)
cmd=$(grep -zoP ".+touchpad.+\n.+\/\/off" $FILE)

echo $cmd
if [[ $cmd =~ ^.+ ]]; then
    sed -i -e 's/\/\/off \/\/ touchpad enabled/off \/\/ touchpad disabled/g' $FILE
    dunstify "Touchpad is disabled"
else
    sed -i -e 's/off \/\/ touchpad disabled/\/\/off \/\/ touchpad enabled/g' $FILE
    dunstify "Touchpad is enabled"
fi