Initial commit: swipe-to-zoom touchscreen navigation for socktop

Tiled socktop dashboard where a right-to-left swipe zooms into each host
full-screen and left-to-right walks back out.

The carousel is tmux pane zoom rather than separate socktop instances, so
there is one process per host: half the processes, no reconnect delay when
swiping back, and constant polling load on the monitored hosts.

Gestures come from lisgd because libinput emits gesture events only for
touchpads, never touchscreens, which rules out libinput-gestures entirely.

Documents the four gotchas found while building this: panels reporting 2-3
contacts for a one-finger swipe, X needing to ignore the panel so the
terminal and socktop stop competing for the same touches, tmux mouse mode
being incompatible with swipes, and lisgd not grabbing the device
exclusively so two instances double-fire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
jasonwitty
2026-08-09 01:22:23 -07:00
commit 18ddd39184
11 changed files with 735 additions and 0 deletions
Executable
+56
View File
@@ -0,0 +1,56 @@
#!/bin/sh
# Gesture diagnostic. Two stages, each answering exactly one question.
#
# Stage 1: is the panel delivering events to us at all?
# Stage 2: which direction and how many contacts does lisgd see?
#
# Stage 2 is the important one. Each line reads:
# [swipe]: Cfg(f=1/s=3/e=0/d=0) <=> Evt(f=2/s=3/e=1/d=2)
# ^ what you configured ^ what actually happened
# f=fingers, s=direction, e=edge, d=distance. Direction enum:
# 0=DU (down-to-up) 1=UD 2=LR (left-to-right) 3=RL (right-to-left)
#
# If Cfg and Evt agree on s= but differ on f=, your panel reports more contacts
# than you configured -- add them to FINGER_COUNTS in the config.
set -eu
for c in /usr/local/etc/socktop-swipe.env "$(dirname "$0")/../config.env"; do
[ -r "$c" ] && . "$c" && break
done
: "${TOUCH_DEV:?no TOUCH_DEV configured}"
: "${SCREEN_W:=1024}"
: "${SCREEN_H:=600}"
: "${SWIPE_THRESHOLD:=80}"
: "${SWIPE_LENIENCY:=30}"
echo "=============================================================="
echo "STAGE 1 -- is the panel delivering events at all?"
echo "Touch and drag on the TOUCHSCREEN for the next 6 seconds..."
echo "=============================================================="
bytes=$(timeout 6 cat "$TOUCH_DEV" 2>/dev/null | wc -c)
echo
echo " read $bytes bytes from $TOUCH_DEV"
if [ "$bytes" -eq 0 ]; then
cat <<-EOF
-> NOTHING. Stage 2 cannot work. Check, in order:
* are you in the 'input' group? (id -nG | grep input; needs a relogin)
* is TOUCH_DEV the right device? (tools/find-device.sh)
EOF
exit 1
fi
echo " -> device is live."
echo
echo "=============================================================="
echo "STAGE 2 -- what does lisgd actually see?"
echo "All four directions are bound, for 1, 2 and 3 contacts."
echo "Swipe LEFT, RIGHT, UP, DOWN. Ctrl-C when done."
echo "=============================================================="
set --
for f in 1 2 3; do
for g in RL LR DU UD; do
set -- "$@" -g "$f,$g,*,*,R,echo \" >>> FIRED: ${f}-contact $g\""
done
done
exec lisgd -v -d "$TOUCH_DEV" -w "$SCREEN_W" -h "$SCREEN_H" \
-t "$SWIPE_THRESHOLD" -r "$SWIPE_LENIENCY" "$@"
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
# Identify the touchscreen and print the stable by-id path for config.env.
set -eu
echo "=== input devices reporting a touch-ish name ==="
found=
for ev in /dev/input/event*; do
name=$(cat "/sys/class/input/$(basename "$ev")/device/name" 2>/dev/null || true)
case "$name" in
*[Tt]ouch* | *TOUCH*)
found=yes
echo
echo " device: $ev"
echo " name: $name"
for l in /dev/input/by-id/* /dev/input/by-path/*; do
[ -e "$l" ] || continue
if [ "$(readlink -f "$l")" = "$(readlink -f "$ev")" ]; then
echo " stable: $l"
fi
done
;;
esac
done
if [ -z "$found" ]; then
echo " (none matched by name)"
echo
echo "Fall back to listing everything:"
for ev in /dev/input/event*; do
printf ' %-22s %s\n' "$ev" "$(cat "/sys/class/input/$(basename "$ev")/device/name" 2>/dev/null)"
done
fi
echo
echo "Put the 'stable:' path (prefer /dev/input/by-id/) into TOUCH_DEV."
echo "Event numbers change across reboots; by-id symlinks do not."
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# Run the real gesture daemon in the foreground, with logging, so you can watch
# the display while you swipe. Ctrl-C to stop.
#
# Expect: swipe right-to-left -> zooms in one host at a time
# swipe left-to-right -> walks back out to the overview
# "Execute ..." in the output means a gesture matched and fired.
#
# Make sure no other instance is running first -- two copies fire every swipe
# twice, which looks like the carousel skipping.
set -eu
if pgrep -x lisgd >/dev/null 2>&1; then
echo "!! lisgd is already running (pid: $(pgrep -x lisgd | tr '\n' ' '))." >&2
echo "!! Two instances make every swipe fire twice. Stop it first:" >&2
echo " pkill -x lisgd" >&2
exit 1
fi
exec "$(dirname "$0")/../socktop-gestures" -v