diff options
| -rwxr-xr-x | deck-it | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -186,13 +186,15 @@ setup-display) ;; watch-usb) # A user-space watcher, so it can reach the session: udev RUN= cannot. - # Start on plug-in, tear down on unplug. - known="" + # Start on plug-in, tear down on unplug. After a resume the serial is the + # same but adb lost the reverses: start again once the last start is done. + known="" pid="" while sleep 5; do now=$(timeout 4 adb -d get-serialno 2>/dev/null) - if [[ -n "$now" && "$now" != "$known" ]]; then - "$SELF" start >/dev/null 2>&1 & - known=$now + if [[ -n "$now" && ( "$now" != "$known" || ! -e /proc/${pid:-0} ) ]] && + ! { [[ "$now" == "$known" ]] && timeout 6 adb -s "$now" reverse --list 2>/dev/null | grep -q "tcp:$PORT "; }; then + "$SELF" >/dev/null 2>&1 & + known=$now pid=$! elif [[ -z "$now" && -n "$known" ]]; then teardown known="" |
