#!/bin/sh

device=$(swaymsg -t get_inputs --raw | jq '.[] | select(.type == "touchpad") | .identifier' | tr -d '"')
status=$(swaymsg -t get_inputs --raw | jq '.[] | select(.type == "touchpad") | .libinput.send_events' | tr -d '"')

if [ "${status}" = "disabled" ]; then
	swaymsg input "${device}" events enabled
	notify-send -u low -t 2000 -a 'Touchpad control' \
		-i "${XDG_DATA_HOME:-$HOME/.local/share}/icons/notifications/trackpad.png" \
		'Touchpad enabled'
else
	swaymsg input "${device}" events disabled
	notify-send -u low -t 2000 -a 'Touchpad control' \
		-i "${XDG_DATA_HOME:-$HOME/.local/share}/icons/notifications/notrackpad.png" \
		'Touchpad disabled'
fi
