#!/bin/sh

WMCLASS="$1"
WMNAME="$2"
ACTION="$3"

# You must exit 0 if you handled the input to not trigger default behaviors

if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
	# Here you could override locked input handlers
	exit 1
fi

# Here you can handle normal input handler

exit 1 # Remove this in your user hook

# Here is an example of possible custom actions
# We already exited but you may adapt it for you own use cases
# Please share your recipes to the community :D

case "$WMCLASS" in
	*"foot"*)
		case "$WMNAME" in
			*"weechat"*)
				case "$ACTION" in
					*"oneleft")
						sxmo_type.sh -M Alt -k a
						exit 0
						;;
					*"oneright")
						sxmo_type.sh -M Alt -k less
						exit 0
						;;
					*"oneup")
						sxmo_type.sh -k Page_Down
						exit 0
						;;
					*"onedown")
						sxmo_type.sh -k Page_Up
						exit 0
						;;
			esac
			;;
		esac
		;;
	*"mpv"*)
		case "$ACTION" in
			"oneright")
				sxmo_type.sh -k Left
				exit 0
				;;
			"oneleft")
				sxmo_type.sh -k Right
				exit 0
				;;
			"oneup")
				sxmo_type.sh m
				exit 0
				;;
			"onedown")
				sxmo_type.sh p
				exit 0
				;;
		esac
		;;
esac