From 55e39c7f0173c61669a62f5ef0a76e6b7316d72c Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Wed, 20 May 2026 02:44:43 +0100 Subject: [PATCH] fix(action): stream getevent for vol on Magisk Users reported vol+ confirmation not registering on Magisk. The prior backgrounded `getevent -qlc 1` + `kill -0` poll captured the first kernel event of any type, then restarted on miss. With six events per keypress (EV_MSC scan, EV_KEY DOWN, EV_SYN, then release variants) and a 1s poll cadence, the 10s budget exhausts before a DOWN sample lands. The chainfire note that piped getevent breaks BusyBox grep applies under Magisk's ash standalone mode. Replace with a single streaming `getevent -lq` matched inline against `KEY_VOLUMEUP DOWN` / `KEY_VOLUMEDOWN DOWN`, wrapped in `/system/bin/timeout 10`. Full paths bypass BusyBox aliasing. --- module/action.sh | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/module/action.sh b/module/action.sh index d453845..e4973ec 100644 --- a/module/action.sh +++ b/module/action.sh @@ -17,36 +17,22 @@ echo " " confirm() { vol_tmp="${TMPDIR:-/data/local/tmp}/teesim_vol_key" - seconds=10 - : > "$vol_tmp" - getevent -qlc 1 > "$vol_tmp" 2>/dev/null & - ge_pid=$! - while [ "$seconds" -gt 0 ]; do - sleep 1 - if ! kill -0 "$ge_pid" 2>/dev/null; then - key=$(awk '/KEY_/{print $3}' "$vol_tmp" 2>/dev/null) - case "$key" in - KEY_VOLUMEUP) - rm -f "$vol_tmp" - return 0 - ;; - KEY_VOLUMEDOWN) - rm -f "$vol_tmp" - return 1 - ;; + # Stream getevent and match VOLUME DOWN inline. Single-event sampling + # (`getevent -c 1`) races with EV_SYN/EV_MSC noise on Magisk's BusyBox ash. + /system/bin/timeout 10 /system/bin/sh -c ' + /system/bin/getevent -lq 2>/dev/null | while IFS= read -r line; do + case "$line" in + *KEY_VOLUMEUP*DOWN*) echo UP > "$1"; exit 0 ;; + *KEY_VOLUMEDOWN*DOWN*) echo DOWN > "$1"; exit 0 ;; esac - : > "$vol_tmp" - getevent -qlc 1 > "$vol_tmp" 2>/dev/null & - ge_pid=$! - fi - seconds=$((seconds - 1)) - done + done + ' _ "$vol_tmp" - kill "$ge_pid" 2>/dev/null - wait "$ge_pid" 2>/dev/null + key=$(cat "$vol_tmp" 2>/dev/null) rm -f "$vol_tmp" + [ "$key" = "UP" ] && return 0 return 1 }