#!/bin/sh
# configversion: 1

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

# You must exit 0 if you handled the input to not trigger default behaviors
# You must exit 1 at the end in order for sxmo_inputhandler.sh to handle the
# other behaviours.

if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
	# Here you could override locked input handlers
	# You must exit 1 at the end to allow defaults too
	exit 1
fi

# Here you can handle normal input handler

# Here is an example of possible custom actions
# 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

# Don't forget to exit 1 at end!
exit 1
