From da7dd699297ad5eacc3af1322afc4735e652542e Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 27 Feb 2026 16:49:53 +0100 Subject: [PATCH 1/8] Add `termux-accessibility` --- scripts/termux-accessibility.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/termux-accessibility.in diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in new file mode 100644 index 0000000..c601707 --- /dev/null +++ b/scripts/termux-accessibility.in @@ -0,0 +1,24 @@ +#!@TERMUX_PREFIX@/bin/bash +set -e -u + +SCRIPTNAME=termux-accessibility +show_usage() { + echo "Usage: $SCRIPTNAME options" + echo 'Options:' + echo 'dump: returns UI XML as `adb` `uiautomator dump`' + echo 'click x y: clicks at the given location' + exit 0 +} + +USAGE_REGEX='^dump|click [0-9]+ [0-9]+$' +if ! [[ $@ =~ $USAGE_REGEX ]]; then + show_usage +fi + +if [ "$1" == dump ]; then + ARGS="--ez dump true" +else + ARGS="--ez click true --ei x $2 --ei y $3" +fi + +@TERMUX_PREFIX@/libexec/termux-api Accessibility $ARGS From 068ae62435176191e251b6d99449c0f515a5d4a2 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 27 Feb 2026 21:20:04 +0100 Subject: [PATCH 2/8] Add `type` ability --- scripts/termux-accessibility.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index c601707..ae3bed7 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -7,18 +7,21 @@ show_usage() { echo 'Options:' echo 'dump: returns UI XML as `adb` `uiautomator dump`' echo 'click x y: clicks at the given location' + echo 'type toType: types the given string' exit 0 } -USAGE_REGEX='^dump|click [0-9]+ [0-9]+$' +USAGE_REGEX='^dump|click [0-9]+ [0-9]+$|type .+' if ! [[ $@ =~ $USAGE_REGEX ]]; then show_usage fi if [ "$1" == dump ]; then ARGS="--ez dump true" -else +elif [ "$1" == click ]; then ARGS="--ez click true --ei x $2 --ei y $3" +elif [ "$1" == type ]; then + ARGS="--es type $2" fi @TERMUX_PREFIX@/libexec/termux-api Accessibility $ARGS From 85ad0eb3138e838de8bf2436098bd080eea91f79 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 27 Feb 2026 22:28:55 +0100 Subject: [PATCH 3/8] Add `global-action` --- scripts/termux-accessibility.in | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index ae3bed7..471e4f3 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -8,20 +8,23 @@ show_usage() { echo 'dump: returns UI XML as `adb` `uiautomator dump`' echo 'click x y: clicks at the given location' echo 'type toType: types the given string' + echo 'global-action globalAction: performs the given global action' exit 0 } -USAGE_REGEX='^dump|click [0-9]+ [0-9]+$|type .+' +USAGE_REGEX='^dump|click [0-9]+ [0-9]+$|type .+|global-action .+' if ! [[ $@ =~ $USAGE_REGEX ]]; then show_usage fi if [ "$1" == dump ]; then - ARGS="--ez dump true" + ARGS="--ez dump true" elif [ "$1" == click ]; then - ARGS="--ez click true --ei x $2 --ei y $3" + ARGS="--ez click true --ei x $2 --ei y $3" elif [ "$1" == type ]; then - ARGS="--es type $2" + ARGS="--es type $2" +elif [ "$1" == global-action ]; then + ARGS="--es global-action $2" fi @TERMUX_PREFIX@/libexec/termux-api Accessibility $ARGS From 36716d76c6357cde5918888690677b6df068e4a6 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sat, 28 Feb 2026 01:01:28 +0100 Subject: [PATCH 4/8] Use `--esn` argument-less instead of `--ez` boolean --- scripts/termux-accessibility.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index 471e4f3..651deea 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -18,9 +18,9 @@ if ! [[ $@ =~ $USAGE_REGEX ]]; then fi if [ "$1" == dump ]; then - ARGS="--ez dump true" + ARGS="--esn dump" elif [ "$1" == click ]; then - ARGS="--ez click true --ei x $2 --ei y $3" + ARGS="--esn click --ei x $2 --ei y $3" elif [ "$1" == type ]; then ARGS="--es type $2" elif [ "$1" == global-action ]; then From 8686df19e91305f5fc6b548a8ea4fc2f46c5391a Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sat, 28 Feb 2026 17:18:54 +0100 Subject: [PATCH 5/8] Support `type` with spaces --- scripts/termux-accessibility.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index 651deea..67713e0 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -18,13 +18,13 @@ if ! [[ $@ =~ $USAGE_REGEX ]]; then fi if [ "$1" == dump ]; then - ARGS="--esn dump" + ARGS=(--esn dump) elif [ "$1" == click ]; then - ARGS="--esn click --ei x $2 --ei y $3" + ARGS=(--esn click --ei x $2 --ei y $3) elif [ "$1" == type ]; then - ARGS="--es type $2" + ARGS=(--es type "$2") elif [ "$1" == global-action ]; then - ARGS="--es global-action $2" + ARGS=(--es global-action $2) fi -@TERMUX_PREFIX@/libexec/termux-api Accessibility $ARGS +@TERMUX_PREFIX@/libexec/termux-api Accessibility "${ARGS[@]}" From dc53104ad1bc61c0580636370570924a1e16588a Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sun, 1 Mar 2026 03:55:07 +0100 Subject: [PATCH 6/8] Add click duration --- scripts/termux-accessibility.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index 67713e0..165f3d4 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -6,13 +6,13 @@ show_usage() { echo "Usage: $SCRIPTNAME options" echo 'Options:' echo 'dump: returns UI XML as `adb` `uiautomator dump`' - echo 'click x y: clicks at the given location' + echo 'click x y (duration): clicks at the given location for the given duration in milliseconds (default is 1)' echo 'type toType: types the given string' echo 'global-action globalAction: performs the given global action' exit 0 } -USAGE_REGEX='^dump|click [0-9]+ [0-9]+$|type .+|global-action .+' +USAGE_REGEX='^dump|click [0-9]+ [0-9]+( [0-9]+)?$|type .+|global-action .+' if ! [[ $@ =~ $USAGE_REGEX ]]; then show_usage fi @@ -20,7 +20,7 @@ fi if [ "$1" == dump ]; then ARGS=(--esn dump) elif [ "$1" == click ]; then - ARGS=(--esn click --ei x $2 --ei y $3) + ARGS=(--esn click --ei x $2 --ei y $3 --ei duration ${4-1}) elif [ "$1" == type ]; then ARGS=(--es type "$2") elif [ "$1" == global-action ]; then From ee1b5519082b1c7e77bd1e0c635063687da354f9 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sun, 8 Mar 2026 01:01:55 +0100 Subject: [PATCH 7/8] Add accessibility screenshot --- scripts/termux-accessibility.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index 165f3d4..f25b2fa 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -9,10 +9,11 @@ show_usage() { echo 'click x y (duration): clicks at the given location for the given duration in milliseconds (default is 1)' echo 'type toType: types the given string' echo 'global-action globalAction: performs the given global action' + echo 'screenshot: returns the taken screenshot as PNG' exit 0 } -USAGE_REGEX='^dump|click [0-9]+ [0-9]+( [0-9]+)?$|type .+|global-action .+' +USAGE_REGEX='^dump|click [0-9]+ [0-9]+( [0-9]+)?$|type .+|global-action .+|screenshot' if ! [[ $@ =~ $USAGE_REGEX ]]; then show_usage fi @@ -25,6 +26,8 @@ elif [ "$1" == type ]; then ARGS=(--es type "$2") elif [ "$1" == global-action ]; then ARGS=(--es global-action $2) +elif [ "$1" == screenshot ]; then + ARGS=(--esn screenshot) fi @TERMUX_PREFIX@/libexec/termux-api Accessibility "${ARGS[@]}" From c8c005fdd4bd46e96fec7f791b24468ea85d9ed7 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Mon, 9 Mar 2026 20:50:31 +0100 Subject: [PATCH 8/8] Correct `termux-accessibility` regex --- scripts/termux-accessibility.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in index f25b2fa..816fb19 100644 --- a/scripts/termux-accessibility.in +++ b/scripts/termux-accessibility.in @@ -13,7 +13,7 @@ show_usage() { exit 0 } -USAGE_REGEX='^dump|click [0-9]+ [0-9]+( [0-9]+)?$|type .+|global-action .+|screenshot' +USAGE_REGEX='^(dump|click [0-9]+ [0-9]+( [0-9]+)?|type .+|global-action .+|screenshot)$' if ! [[ $@ =~ $USAGE_REGEX ]]; then show_usage fi