-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeshtty.sh
More file actions
executable file
·59 lines (51 loc) · 1.85 KB
/
Copy pathmeshtty.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# meshtty.sh — launch MeshTTY
# Works on Raspberry Pi OS, Ubuntu, and macOS.
# Generated by install.sh — safe to re-run install.sh to regenerate.
VENV="$HOME/.venv/meshtty"
APP_DIR="$(cd "$(dirname "$0")" && pwd)"
# Require an interactive terminal — Textual cannot run without one
if ! [[ -t 0 && -t 1 ]]; then
echo "ERROR: MeshTTY requires an interactive terminal (stdin/stdout must be a TTY)." >&2
exit 1
fi
# Ensure a capable TERM for Textual rendering
if [[ "$TERM" == "dumb" || -z "$TERM" ]]; then
export TERM=xterm-256color
fi
if [[ ! -f "$VENV/bin/activate" ]]; then
echo "ERROR: virtualenv not found at $VENV"
echo "Please re-run install.sh"
exit 1
fi
source "$VENV/bin/activate"
cd "$APP_DIR"
# At boot, wait up to 10 s for a USB serial device to enumerate if serial
# is the configured transport. Harmless no-op once the device is present.
# Device paths differ: Linux uses /dev/ttyUSB* and /dev/ttyACM*;
# macOS uses /dev/cu.usbserial-*, /dev/cu.SLAB_*, /dev/cu.wchusbserial*, etc.
CONFIG="$HOME/.config/meshtty/config.json"
if grep -q '"default_transport".*"serial"' "$CONFIG" 2>/dev/null; then
_serial_ready() {
if [[ "$(uname -s)" == "Darwin" ]]; then
ls /dev/cu.usbserial* /dev/cu.SLAB_* /dev/cu.wchusbserial* /dev/cu.usbmodem* >/dev/null 2>&1
else
ls /dev/ttyUSB* /dev/ttyACM* >/dev/null 2>&1
fi
}
if ! _serial_ready; then
echo "Waiting for USB serial device..."
for _i in $(seq 1 10); do
_serial_ready && break
sleep 1
done
fi
fi
# Replay saved startup flags if none were passed explicitly
FLAGS_FILE="$HOME/.config/meshtty/last_flags"
SAVED_FLAGS=""
if [[ $# -eq 0 && -f "$FLAGS_FILE" ]]; then
SAVED_FLAGS=$(cat "$FLAGS_FILE")
fi
# shellcheck disable=SC2086
exec python -m meshtty.main $SAVED_FLAGS "$@"