~mil/sxmo-devel

sxmo-utils: Tentative to modularize inputhandler v1 NEEDS REVISION

Florent de Lamotte: 1
 Tentative to modularize inputhandler

 16 files changed, 522 insertions(+), 235 deletions(-)
#1213930 test.yml success
Hi Aren, 

Thanks for taking the time to review my patch, your comments are
relevant and will help me provide a better solution (at least for my 
use ;)).

I will not reply to everything now and will take some time to take
everyting into account (if you find there is some interest in my proposal).
Next
Hi Stacy and Aren,

Made some progress yesterday (bored at work ;)) and think I need some
guidance.

First, the sourcing of scripts has been a great success, on performance
side, there is a 2-3ms improvement, but that is on the readability that
the gain is important, exit structure is clearer ;). Now I am faster
than the original script on the op6 ... (I'd need to check profundly but
it is not bad)

Where I need you is for two points :
 - loop structure
 - directory structure/file naming

For the loop structure, I've tried Stacy's proposal and I get a 5-6ms
penalty (on the op6). The structure is clearer and edge cases are better
treated (no files in the dir for instance).
 => is a 6ms gain worth going in a less elegant solution ?

As for directories, I've tested different solutions :
 - current solution : a root directory (inputhandler.d) and a subdir for
   applications that run in the terminal and are matched with wmname
 - I've tried using two subdirs (wmclass and wmname) and I find it
   clearer (and I can put base scripts to be sourced at the root, for
   common actions)

There does not seem to be penalties, so I ask you what you think (I'll
personally go for the second choice).

I've also test changing the names :
 1- current scheme : scripts have a .actions extension
 2- tried using a "sxmo_actions_" prefix so I don't have to remove
   extension
 3- removed both extension and prefix

The second scheme induced a time penalty (I think a match with
##*/sxmo_actions_ was costly so could probably be enhanced to match 1)

There is no noticeable gain from the third scheme.

I prefer the third scheme but will let you choose ;)


Have a nice weekend (don't know if i'll make much process because the
sun arrived),
--
Florent
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/sxmo-devel/patches/51634/mbox | git am -3
Learn more about email & git

[PATCH sxmo-utils] Tentative to modularize inputhandler Export this patch

The idea is to split the big switch into sxmo_hook_inputhandler.sh into
a script for each possible action. These script are stored in local and
global inputhandler.d directories.
Some benchmarks have been done with hyperfine on op6 and moto-g3. On op6
the scripts runs in 50ms, on moto-g3, there is a small penalty (from
105ms to 110ms).
Some optimizations can be done, for instance the loop could be exited as
soon as the first match has been found. Currently I let it continue, it
enables some sort of "inheritance" ...

---
 .../default_hooks/sxmo_hook_inputhandler.sh   | 263 ++----------------
 configs/inputhandler.d/acme.actions           |  22 ++
 configs/inputhandler.d/foot.actions           |  59 ++++
 .../inputhandler.d/interminal/amfora.actions  |  33 +++
 configs/inputhandler.d/interminal/epr.actions |  21 ++
 configs/inputhandler.d/interminal/epy.actions |  21 ++
 .../inputhandler.d/interminal/less.actions    |  25 ++
 configs/inputhandler.d/interminal/lf.actions  |  18 ++
 configs/inputhandler.d/interminal/nnn.actions |  18 ++
 configs/inputhandler.d/interminal/sms.actions |  16 ++
 .../inputhandler.d/interminal/tuir.actions    |  14 +
 .../inputhandler.d/interminal/weechat.actions |  17 ++
 configs/inputhandler.d/mpv.actions            |  28 ++
 configs/inputhandler.d/st.actions             |  84 ++++++
 configs/inputhandler.d/terminal.actions       |  59 ++++
 configs/inputhandler.d/vte.actions            |  59 ++++
 16 files changed, 522 insertions(+), 235 deletions(-)
 create mode 100755 configs/inputhandler.d/acme.actions
 create mode 100755 configs/inputhandler.d/foot.actions
 create mode 100755 configs/inputhandler.d/interminal/amfora.actions
 create mode 100755 configs/inputhandler.d/interminal/epr.actions
 create mode 100755 configs/inputhandler.d/interminal/epy.actions
 create mode 100755 configs/inputhandler.d/interminal/less.actions
 create mode 100755 configs/inputhandler.d/interminal/lf.actions
 create mode 100755 configs/inputhandler.d/interminal/nnn.actions
 create mode 100755 configs/inputhandler.d/interminal/sms.actions
 create mode 100755 configs/inputhandler.d/interminal/tuir.actions
 create mode 100755 configs/inputhandler.d/interminal/weechat.actions
 create mode 100755 configs/inputhandler.d/mpv.actions
 create mode 100755 configs/inputhandler.d/st.actions
 create mode 100755 configs/inputhandler.d/terminal.actions
 create mode 100755 configs/inputhandler.d/vte.actions

diff --git a/configs/default_hooks/sxmo_hook_inputhandler.sh b/configs/default_hooks/sxmo_hook_inputhandler.sh
index b0bba6d..c0a5e00 100755
--- a/configs/default_hooks/sxmo_hook_inputhandler.sh
+++ b/configs/default_hooks/sxmo_hook_inputhandler.sh
@@ -15,10 +15,32 @@ stop_proximity_lock() {
	sxmo_jobs.sh stop proximity_lock
}

run_actiondir () {
	WMCLASS="$1"
	WMNAME="$2"
	ACTION="$3"
	WMID="$4"		# either WMCLASS or WMNAME
	ADIR="$5"		# directory where are actions scripts
	
	for APATH in "$ADIR"/*.actions; do
		AFILE=${APATH##*/}
		if [ -z "${WMID##*"${AFILE%.actions}"*}" ] ; then
			$APATH "$WMCLASS" "$WMNAME" "$ACTION" 
			ret=$?
			[ $ret -eq 0 ] && exit 0
			return 1
		fi
	done
}

export HOME_INPUTHANDLER_D="$XDG_CONFIG_HOME"/sxmo/inputhandler.d
export SXMO_INPUTHANDLER_D=/usr/share/sxmo/inputhandler.d

XPROPOUT="$(sxmo_wm.sh focusedwindow)"
WMCLASS="$(printf %s "$XPROPOUT" | grep app: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')"
WMNAME="$(printf %s "$XPROPOUT" | grep title: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')"


sxmo_debug "STATE: $(sxmo_state.sh get) ACTION: $ACTION WMCLASS: $WMCLASS WMNAME: $WMNAME"

if ! sxmo_state.sh get | grep -q unlock; then
@@ -75,241 +97,12 @@ if ! sxmo_state.sh get | grep -q unlock; then
	exit 0
fi

#special context-sensitive handling
case "$WMCLASS" in
	*"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
		;;
	*"acme"*)
		case "$ACTION" in
			"volup_one")
				xdotool click 3
				exit 0
				;;
			"voldown_one")
				xdotool click 2
				exit 0
				;;
		esac
		;;
	*"foot"*|*"st"*|*"vte"*|"terminal") # Terminals
		case "$WMCLASS" in # Handle programs without touch support
			*"st"*)
				case "$WMNAME" in
					*"weechat"*|*'gomuks'*)
						case "$ACTION" in
							*"onedown")
								sxmo_type.sh -k Page_Up
								exit 0
								;;
							*"oneup")
								sxmo_type.sh -k Page_Down
								exit 0
								;;
						esac
						;;
					*"less"*|*"amfora"*)
						case "$ACTION" in
							*"onedown")
								sxmo_type.sh u
								exit 0
								;;
							*"oneup")
								sxmo_type.sh d
								exit 0
								;;
						esac
						;;
					*'irssi'*)
						case "$ACTION" in
							"onedown")
								sxmo_type.sh -M Alt p
								exit 0
								;;
							"oneup")
								sxmo_type.sh -M Alt n
								exit 0
								;;
						esac
						;;
					*'epy'*|*'epr'*)
						case "$ACTION" in
							"onedown")
								sxmo_type.sh h
								exit 0
								;;
							"oneup")
								sxmo_type.sh l
								exit 0
								;;
						esac
						;;
					*'nnn'*|'lf')
						case "$ACTION" in
							"onedown")
								sxmo_type.sh -k Down
								exit 0
								;;
							"oneup")
								sxmo_type.sh -k Up
								exit 0
								;;
						esac
						;;
				esac
				;;
		esac

		case "$WMNAME" in # Handle programs
			*"weechat"*)
				case "$ACTION" in
					*"oneleft")
						sxmo_type.sh -M Alt -k a
						exit 0
						;;
					*"oneright")
						sxmo_type.sh -M Alt -k less
						exit 0
						;;
				esac
				;;
			*" sms")
				case "$ACTION" in
					*"upbottomedge")
						number="$(printf %s "$WMNAME" | sed -e 's|^\"||' -e 's|\"$||' | cut -f1 -d' ')"
						sxmo_terminal.sh sxmo_modemtext.sh conversationloop "$number"
						exit 0
						;;
				esac
				;;
			*"tuir"*)
				if [ "$ACTION" = "rightbottomedge" ]; then
					sxmo_type.sh o
					exit 0
				elif [ "$ACTION" = "leftbottomedge" ]; then
					sxmo_type.sh s
					exit 0
				fi
				;;
			*"less"*)
				case "$ACTION" in
					"leftbottomedge")
						sxmo_type.sh q
						exit 0
						;;
					"leftrightedge_short")
						sxmo_type.sh q
						exit 0
						;;
					*"oneleft")
						sxmo_type.sh ":n" -k Return
						exit 0
						;;
					*"oneright")
						sxmo_type.sh ":p" -k Return
						exit 0
						;;
				esac
				;;
			*"amfora"*)
				case "$ACTION" in
					"downright")
						sxmo_type.sh -k Tab
						exit 0
						;;
					"upleft")
						sxmo_type.sh -M Shift -k Tab
						exit 0
						;;
					*"oneright")
						sxmo_type.sh -k Return
						exit 0
						;;
					"upright")
						sxmo_type.sh -M Ctrl t
						exit 0
						;;
					*"oneleft")
						sxmo_type.sh b
						exit 0
						;;
					"downleft")
						sxmo_type.sh -M Ctrl w
						exit 0
						;;
				esac
				;;
			*"epy"*|*"epr"*)
				case "$ACTION" in
					*"left"|"voldown_one")
						sxmo_type.sh l
						exit 0
						;;
					*"right"|"volup_one")
						sxmo_type.sh h
						exit 0
						;;
					"voldown_three"|"twodownbottomedge")
						sxmo_type.sh q
						exit
						;;
				esac
				;;
			*'nnn'*|'lf')
				case "$ACTION" in
					*"left")
						sxmo_type.sh -k Right
						exit 0
						;;
					*"right")
						sxmo_type.sh -k Left
						exit 0
						;;
				esac
				;;
		esac

		case "$WMCLASS" in # Handle general scrolling without touch support
			*"st"*)
				case "$ACTION" in
					*"onedown")
						sxmo_type.sh -M Ctrl -M Shift -k b
						exit 0
						;;
					*"oneup")
						sxmo_type.sh -M Ctrl -M Shift -k f
						exit 0
						;;
				esac
				;;
			"org.gnome.vte.application"|"terminal")
				case "$ACTION" in
					# For VTE, fallback to doing nothing,
					# you're probably dragging the scrollbar
					*"uprightedge") exit 0 ;;
					*"downrightedge") exit 0 ;;
				esac
				;;
		esac
		;;
esac
# Process actions for current application
for DIR in "$HOME_INPUTHANDLER_D" "$SXMO_INPUTHANDLER_D" ; do
	if [ -n "$WMCLASS" ] && [ -d "$DIR" ]; then 
		run_actiondir "$WMCLASS" "$WMNAME" "$ACTION" "$WMCLASS" "$DIR"
	fi
done

#standard handling
case "$ACTION" in
diff --git a/configs/inputhandler.d/acme.actions b/configs/inputhandler.d/acme.actions
new file mode 100755
index 0000000..f96175a
--- /dev/null
+++ b/configs/inputhandler.d/acme.actions
@@ -0,0 +1,22 @@
#!/bin/sh

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

case "$ACTION" in
	"volup_one")
		xdotool click 3
		exit 0
		;;
	"voldown_one")
		xdotool click 2
		exit 0
		;;
esac

# no branch taken
exit 1



diff --git a/configs/inputhandler.d/foot.actions b/configs/inputhandler.d/foot.actions
new file mode 100755
index 0000000..278bbd3
--- /dev/null
+++ b/configs/inputhandler.d/foot.actions
@@ -0,0 +1,59 @@
#!/bin/sh

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

run_actiondir () {
	WMCLASS="$1"
	WMNAME="$2"
	ACTION="$3"
	WMID="$4"		# either WMCLASS or WMNAME
	ADIR="$5"		# directory where are actions scripts
	
	for APATH in "$ADIR"/*.actions; do
		AFILE=${APATH##*/}
		if [ -z "${WMID##*"${AFILE%.actions}"*}" ] ; then
			$APATH "$WMCLASS" "$WMNAME" "$ACTION" 
			ret=$? 
			[ $ret -eq 0 ] && exit 0
		fi
	done
}

for DIR in $HOME_INPUTHANDLER_D/interminal $SXMO_INPUTHANDLER_D/interminal 
do
	if [ -n "$WMNAME" ] && [ -d "$DIR" ]; then 
		run_actiondir "$WMCLASS" "$WMNAME" "$ACTION" "$WMNAME" "$DIR"
	fi
done

# Now we try generic actions for terminal
case "$WMCLASS" in # Handle general scrolling without touch support
	*"st"*)
		case "$ACTION" in
			*"onedown")
				sxmo_type.sh -M Ctrl -M Shift -k b
				exit 0
				;;
			*"oneup")
				sxmo_type.sh -M Ctrl -M Shift -k f
				exit 0
				;;
		esac
		;;
	"org.gnome.vte.application"|"terminal")
		case "$ACTION" in
			# For VTE, fallback to doing nothing,
			# you're probably dragging the scrollbar
			*"uprightedge") exit 0 ;;
			*"downrightedge") exit 0 ;;
		esac
		;;
esac

# no branch taken
exit 1



diff --git a/configs/inputhandler.d/interminal/amfora.actions b/configs/inputhandler.d/interminal/amfora.actions
new file mode 100755
index 0000000..c97b253
--- /dev/null
+++ b/configs/inputhandler.d/interminal/amfora.actions
@@ -0,0 +1,33 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	"downright")
		sxmo_type.sh -k Tab
		exit 0
		;;
	"upleft")
		sxmo_type.sh -M Shift -k Tab
		exit 0
		;;
	*"oneright")
		sxmo_type.sh -k Return
		exit 0
		;;
	"upright")
		sxmo_type.sh -M Ctrl t
		exit 0
		;;
	*"oneleft")
		sxmo_type.sh b
		exit 0
		;;
	"downleft")
		sxmo_type.sh -M Ctrl w
		exit 0
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/interminal/epr.actions b/configs/inputhandler.d/interminal/epr.actions
new file mode 100755
index 0000000..c831b63
--- /dev/null
+++ b/configs/inputhandler.d/interminal/epr.actions
@@ -0,0 +1,21 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	*"left"|"voldown_one")
		sxmo_type.sh l
		exit 0
		;;
	*"right"|"volup_one")
		sxmo_type.sh h
		exit 0
		;;
	"voldown_three"|"twodownbottomedge")
		sxmo_type.sh q
		exit
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/interminal/epy.actions b/configs/inputhandler.d/interminal/epy.actions
new file mode 100755
index 0000000..c831b63
--- /dev/null
+++ b/configs/inputhandler.d/interminal/epy.actions
@@ -0,0 +1,21 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	*"left"|"voldown_one")
		sxmo_type.sh l
		exit 0
		;;
	*"right"|"volup_one")
		sxmo_type.sh h
		exit 0
		;;
	"voldown_three"|"twodownbottomedge")
		sxmo_type.sh q
		exit
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/interminal/less.actions b/configs/inputhandler.d/interminal/less.actions
new file mode 100755
index 0000000..fd90a44
--- /dev/null
+++ b/configs/inputhandler.d/interminal/less.actions
@@ -0,0 +1,25 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	"leftbottomedge")
		sxmo_type.sh q
		exit 0
		;;
	"leftrightedge_short")
		sxmo_type.sh q
		exit 0
		;;
	*"oneleft")
		sxmo_type.sh ":n" -k Return
		exit 0
		;;
	*"oneright")
		sxmo_type.sh ":p" -k Return
		exit 0
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/interminal/lf.actions b/configs/inputhandler.d/interminal/lf.actions
new file mode 100755
index 0000000..6f651be
--- /dev/null
+++ b/configs/inputhandler.d/interminal/lf.actions
@@ -0,0 +1,18 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	*"left")
		sxmo_type.sh -k Right
		exit 0
		;;
	*"right")
		sxmo_type.sh -k Left
		exit 0
		;;
esac


exit 1

diff --git a/configs/inputhandler.d/interminal/nnn.actions b/configs/inputhandler.d/interminal/nnn.actions
new file mode 100755
index 0000000..6f651be
--- /dev/null
+++ b/configs/inputhandler.d/interminal/nnn.actions
@@ -0,0 +1,18 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	*"left")
		sxmo_type.sh -k Right
		exit 0
		;;
	*"right")
		sxmo_type.sh -k Left
		exit 0
		;;
esac


exit 1

diff --git a/configs/inputhandler.d/interminal/sms.actions b/configs/inputhandler.d/interminal/sms.actions
new file mode 100755
index 0000000..1f9db39
--- /dev/null
+++ b/configs/inputhandler.d/interminal/sms.actions
@@ -0,0 +1,16 @@
#!/bin/sh

WMNAME="$2"
ACTION="$3"

number="$(printf %s "$WMNAME" | sed -e 's|^\"||' -e 's|\"$||' | cut -f1 -d' ')"
case "$ACTION" in
	*"upbottomedge")
		number="$(printf %s "$WMNAME" | sed -e 's|^\"||' -e 's|\"$||' | cut -f1 -d' ')"
		sxmo_terminal.sh sxmo_modemtext.sh conversationloop "$number" &
		exit 0
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/interminal/tuir.actions b/configs/inputhandler.d/interminal/tuir.actions
new file mode 100755
index 0000000..7e0acd9
--- /dev/null
+++ b/configs/inputhandler.d/interminal/tuir.actions
@@ -0,0 +1,14 @@
#!/bin/sh

ACTION="$3"

if [ "$ACTION" = "rightbottomedge" ]; then
	sxmo_type.sh o
	exit 0
elif [ "$ACTION" = "leftbottomedge" ]; then
	sxmo_type.sh s
	exit 0
fi

exit 1

diff --git a/configs/inputhandler.d/interminal/weechat.actions b/configs/inputhandler.d/interminal/weechat.actions
new file mode 100755
index 0000000..4e52a8c
--- /dev/null
+++ b/configs/inputhandler.d/interminal/weechat.actions
@@ -0,0 +1,17 @@
#!/bin/sh

ACTION="$3"

case "$ACTION" in
	*"oneleft")
		sxmo_type.sh -M Alt -k a
		exit 0
		;;
	*"oneright")
		sxmo_type.sh -M Alt -k less
		exit 0
		;;
esac

exit 1

diff --git a/configs/inputhandler.d/mpv.actions b/configs/inputhandler.d/mpv.actions
new file mode 100755
index 0000000..3b1dca2
--- /dev/null
+++ b/configs/inputhandler.d/mpv.actions
@@ -0,0 +1,28 @@
#!/bin/sh

ACTION="$3"

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

# no branch taken
exit 1



diff --git a/configs/inputhandler.d/st.actions b/configs/inputhandler.d/st.actions
new file mode 100755
index 0000000..5926f4a
--- /dev/null
+++ b/configs/inputhandler.d/st.actions
@@ -0,0 +1,84 @@
#!/bin/sh

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

# specific actions to st (for handling scrolling)
case "$WMNAME" in
	*"weechat"*|*'gomuks'*)
		case "$ACTION" in
			*"onedown")
				sxmo_type.sh -k Page_Up
				exit 0
				;;
			*"oneup")
				sxmo_type.sh -k Page_Down
				exit 0
				;;
		esac
		;;
	*"less"*|*"amfora"*)
		case "$ACTION" in
			*"onedown")
				sxmo_type.sh u
				exit 0
				;;
			*"oneup")
				sxmo_type.sh d
				exit 0
				;;
		esac
		;;
	*'irssi'*)
		case "$ACTION" in
			"onedown")
				sxmo_type.sh -M Alt p
				exit 0
				;;
			"oneup")
				sxmo_type.sh -M Alt n
				exit 0
				;;
		esac
		;;
	*'epy'*|*'epr'*)
		case "$ACTION" in
			"onedown")
				sxmo_type.sh h
				exit 0
				;;
			"oneup")
				sxmo_type.sh l
				exit 0
				;;
		esac
		;;
	*'nnn'*|'lf')
		case "$ACTION" in
			"onedown")
				sxmo_type.sh -k Down
				exit 0
				;;
			"oneup")
				sxmo_type.sh -k Up
				exit 0
				;;
		esac
		;;
esac

# handle generic terminal actions
if [ -e "$HOME_INPUTHANDLER_D"/terminal.actions ]; then
	"$HOME_INPUTHANDLER_D"/terminal.actions "$WMCLASS" "$WMNAME" "$ACTION"
	[ $? -eq 0 ] && exit 0
else
	"$SXMO_INPUTHANDLER_D"/terminal.actions "$WMCLASS" "$WMNAME" "$ACTION"
	[ $? -eq 0 ] && exit 0
fi

# no branch taken
exit 1



diff --git a/configs/inputhandler.d/terminal.actions b/configs/inputhandler.d/terminal.actions
new file mode 100755
index 0000000..278bbd3
--- /dev/null
+++ b/configs/inputhandler.d/terminal.actions
@@ -0,0 +1,59 @@
#!/bin/sh

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

run_actiondir () {
	WMCLASS="$1"
	WMNAME="$2"
	ACTION="$3"
	WMID="$4"		# either WMCLASS or WMNAME
	ADIR="$5"		# directory where are actions scripts
	
	for APATH in "$ADIR"/*.actions; do
		AFILE=${APATH##*/}
		if [ -z "${WMID##*"${AFILE%.actions}"*}" ] ; then
			$APATH "$WMCLASS" "$WMNAME" "$ACTION" 
			ret=$? 
			[ $ret -eq 0 ] && exit 0
		fi
	done
}

for DIR in $HOME_INPUTHANDLER_D/interminal $SXMO_INPUTHANDLER_D/interminal 
do
	if [ -n "$WMNAME" ] && [ -d "$DIR" ]; then 
		run_actiondir "$WMCLASS" "$WMNAME" "$ACTION" "$WMNAME" "$DIR"
	fi
done

# Now we try generic actions for terminal
case "$WMCLASS" in # Handle general scrolling without touch support
	*"st"*)
		case "$ACTION" in
			*"onedown")
				sxmo_type.sh -M Ctrl -M Shift -k b
				exit 0
				;;
			*"oneup")
				sxmo_type.sh -M Ctrl -M Shift -k f
				exit 0
				;;
		esac
		;;
	"org.gnome.vte.application"|"terminal")
		case "$ACTION" in
			# For VTE, fallback to doing nothing,
			# you're probably dragging the scrollbar
			*"uprightedge") exit 0 ;;
			*"downrightedge") exit 0 ;;
		esac
		;;
esac

# no branch taken
exit 1



diff --git a/configs/inputhandler.d/vte.actions b/configs/inputhandler.d/vte.actions
new file mode 100755
index 0000000..278bbd3
--- /dev/null
+++ b/configs/inputhandler.d/vte.actions
@@ -0,0 +1,59 @@
#!/bin/sh

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

run_actiondir () {
	WMCLASS="$1"
	WMNAME="$2"
	ACTION="$3"
	WMID="$4"		# either WMCLASS or WMNAME
	ADIR="$5"		# directory where are actions scripts
	
	for APATH in "$ADIR"/*.actions; do
		AFILE=${APATH##*/}
		if [ -z "${WMID##*"${AFILE%.actions}"*}" ] ; then
			$APATH "$WMCLASS" "$WMNAME" "$ACTION" 
			ret=$? 
			[ $ret -eq 0 ] && exit 0
		fi
	done
}

for DIR in $HOME_INPUTHANDLER_D/interminal $SXMO_INPUTHANDLER_D/interminal 
do
	if [ -n "$WMNAME" ] && [ -d "$DIR" ]; then 
		run_actiondir "$WMCLASS" "$WMNAME" "$ACTION" "$WMNAME" "$DIR"
	fi
done

# Now we try generic actions for terminal
case "$WMCLASS" in # Handle general scrolling without touch support
	*"st"*)
		case "$ACTION" in
			*"onedown")
				sxmo_type.sh -M Ctrl -M Shift -k b
				exit 0
				;;
			*"oneup")
				sxmo_type.sh -M Ctrl -M Shift -k f
				exit 0
				;;
		esac
		;;
	"org.gnome.vte.application"|"terminal")
		case "$ACTION" in
			# For VTE, fallback to doing nothing,
			# you're probably dragging the scrollbar
			*"uprightedge") exit 0 ;;
			*"downrightedge") exit 0 ;;
		esac
		;;
esac

# no branch taken
exit 1



-- 
2.43.0
sxmo-utils/patches/test.yml: SUCCESS in 22s

[Tentative to modularize inputhandler][0] from [Florent de Lamotte][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/51634
[1]: mailto:florent@frizoncorrea.fr

✓ #1213930 SUCCESS sxmo-utils/patches/test.yml https://builds.sr.ht/~mil/job/1213930
I agree with Aren here. The idea is interesting and I am willing to help
on this, but only if (1) there is no performance impact, (2)
sxmo_migrate.sh manage them, and (3) it is still easy for user to
add/expand them.

I mark this as needing_revision anyway.

Additionnaly to Aren review, here some comments: