#!/usr/bin/env zsh
touchpad_name=$(libinput list-devices | grep -B 5 "pointer gesture" | awk '/Device/ {for (i=2; i<NF; i++) printf $i " "; print $NF}')

[[ $touchpad_name == "" ]] && exit

touchpad_status=$(xinput list-props "$touchpad_name" | awk '/Device Enabled/ {print $4}')

if [[ $touchpad_status == "0" ]]; then
  xinput --enable "$touchpad_name"
else
  xinput --disable "$touchpad_name"
fi