Skip to content

Commit c9e857f

Browse files
authored
Merge pull request #8 from bleaaach/main
feat: enhance VNC setup by adding XFCE support and improving display …
2 parents addec55 + 5ea725d commit c9e857f

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

seeed_jetson_develop/modules/apps/data/jetson_examples.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,20 @@
162162
"bash -lc 'set -e; echo [2/2] start demo container with reComputer; export PATH=$HOME/.local/bin:$PATH; reComputer run depth-anything-v3'"
163163
],
164164
"run_cmds": [
165-
"bash -lc 'set -e; echo [1/5] display auth precheck; DISP=${DISPLAY:-}; if [ -z \"$DISP\" ]; then if [ -S /tmp/.X11-unix/X1 ]; then DISP=:1; else DISP=:0; fi; fi; echo \"[info] use DISPLAY=$DISP\"; if test -f $HOME/.Xauthority; then echo \"[ok] ~/.Xauthority found\"; else echo \"[warn] ~/.Xauthority not found; RViz may fail in GUI mode\"; fi'",
165+
"bash -lc 'set -e; echo [1/5] display auth precheck; XAUTH_SRC=/run/user/1000/gdm/Xauthority; if [ -f \"$XAUTH_SRC\" ]; then xauth -f $HOME/.Xauthority merge \"$XAUTH_SRC\" 2>/dev/null && echo \"[ok] merged gdm Xauthority into ~/.Xauthority\"; DISPLAY=:0 XAUTHORITY=\"$XAUTH_SRC\" xhost +local: 2>/dev/null && echo \"[ok] xhost +local: done\" || echo \"[warn] xhost +local: failed (non-fatal)\"; else echo \"[warn] gdm Xauthority not found, RViz may fail\"; fi; echo \"[info] DISPLAY will be forced to :0\"'",
166166
"bash -lc 'echo; echo \"[2/5] optional swap (run manually only if engine build fails due to OOM)\"; echo \"sudo mkdir -p /mnt/nvme\"; echo \"sudo fallocate -l 16G /mnt/nvme/swapfile\"; echo \"sudo chmod 600 /mnt/nvme/swapfile\"; echo \"sudo mkswap /mnt/nvme/swapfile\"; echo \"sudo swapon /mnt/nvme/swapfile\"; echo'",
167-
"bash -lc 'set -e; echo \"[3/5] start tutorial container + run GUI preview in background xauth mode\"; DISP=${DISPLAY:-}; if [ -z \"$DISP\" ]; then if [ -S /tmp/.X11-unix/X1 ]; then DISP=:1; else DISP=:0; fi; fi; echo \"[info] start container with DISPLAY=$DISP\"; sudo docker rm -f depth_anything_v3 >/dev/null 2>&1 || true; sudo docker run -d --name depth_anything_v3 --restart unless-stopped --runtime=nvidia --network host --ipc host --privileged -e DISPLAY=$DISP -e XAUTHORITY=/home/seeed/.Xauthority -e QT_X11_NO_MITSHM=1 -e LIBGL_ALWAYS_SOFTWARE=1 -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/seeed/.Xauthority:/home/seeed/.Xauthority:ro -v /dev:/dev chenduola6/depth_anything_v3:jp6.2 bash -lc \"set -e; cd /workspace/ros2-depth-anything-v3-trt; source install/setup.bash; if ls onnx/*.engine >/dev/null 2>&1; then echo '[skip] engine already exists'; else echo '[info] first run will build TensorRT engine; this can take several minutes'; ros2 run depth_anything_v3 generate_engines onnx; fi; exec ./run_camera_depth.sh\"; sudo docker ps -a --filter name=depth_anything_v3'",
167+
"bash -lc 'set -e; echo \"[3/5] start tutorial container + run GUI preview in background xauth mode\"; DISP=:0; XAUTH_SRC=/run/user/1000/gdm/Xauthority; [ -f \"$XAUTH_SRC\" ] || XAUTH_SRC=$HOME/.Xauthority; echo \"[info] start container with DISPLAY=$DISP XAUTHORITY=$XAUTH_SRC\"; sudo docker rm -f depth_anything_v3 >/dev/null 2>&1 || true; sudo docker run -d --name depth_anything_v3 --restart unless-stopped --runtime=nvidia --network host --ipc host --privileged -e DISPLAY=$DISP -e XAUTHORITY=/tmp/.docker.xauth -e QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix -v \"$XAUTH_SRC\":/tmp/.docker.xauth:ro -v /dev:/dev chenduola6/depth_anything_v3:jp6.2 bash -lc \"set -e; export DISPLAY=:0; export XAUTHORITY=/tmp/.docker.xauth; cd /workspace/ros2-depth-anything-v3-trt; source install/setup.bash; if ls onnx/*.engine >/dev/null 2>&1; then echo \\\"[skip] engine already exists\\\"; else echo \\\"[info] first run will build TensorRT engine; this can take several minutes\\\"; ros2 run depth_anything_v3 generate_engines onnx; fi; exec ./run_camera_depth.sh\"; sudo docker ps -a --filter name=depth_anything_v3'",
168168
"bash -lc 'echo \"[4/5] show depth_anything_v3 status (if started by reComputer path)\"; sudo docker ps -a --filter name=depth_anything_v3'",
169169
"bash -lc 'echo \"[5/5] follow logs for 120s\"; timeout 120s sudo docker logs -f depth_anything_v3 2>&1 || true; echo \"[hint] if still building engine, rerun Run and keep logs open\"'"
170170
],
171171
"clean_cmds": [
172172
"bash -lc 'set -e; export PATH=$HOME/.local/bin:$PATH; if reComputer clean depth-anything-v3; then echo \"[ok] reComputer clean depth-anything-v3\"; else echo \"[warn] reComputer clean failed, fallback to docker rm only\"; sudo docker rm -f depth_anything_v3 >/dev/null 2>&1 || true; fi; echo depth_anything_v3 cleaned'"
173173
],
174-
"uninstall_cmds": [],
174+
"uninstall_cmds": [
175+
"bash -lc 'sudo docker stop depth_anything_v3 2>/dev/null; sudo docker rm -f depth_anything_v3 2>/dev/null; echo \"[ok] container removed\"'",
176+
"bash -lc 'sudo docker rmi chenduola6/depth_anything_v3:jp6.2 2>/dev/null && echo \"[ok] image removed\" || echo \"[warn] image not found or already removed\"'",
177+
"bash -lc 'export PATH=$HOME/.local/bin:$PATH; reComputer clean depth-anything-v3 2>/dev/null && echo \"[ok] reComputer clean done\" || echo \"[warn] reComputer clean skipped\"'"
178+
],
175179
"requirements": {
176180
"jetpack_versions": [
177181
"36.4.x"

seeed_jetson_develop/modules/apps/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
)
1717

1818
_DA3_RUN_CMDS = [
19-
"bash -lc 'set -e; echo [1/5] display auth precheck; DISP=${DISPLAY:-}; if [ -z \"$DISP\" ]; then if [ -S /tmp/.X11-unix/X99 ]; then DISP=:99; elif [ -S /tmp/.X11-unix/X1 ]; then DISP=:1; else DISP=:0; fi; fi; echo \"[info] use DISPLAY=$DISP\"; if [ \"$DISP\" = \":99\" ]; then echo \"[info] headless VNC display :99 detected\"; elif test -f $HOME/.Xauthority; then echo \"[ok] ~/.Xauthority found\"; else echo \"[warn] ~/.Xauthority not found; RViz may fail in GUI mode\"; fi'",
19+
"bash -lc 'set -e; echo [1/5] display auth precheck; DISP=:99; if xdpyinfo -display :99 >/dev/null 2>&1; then DISPLAY=:99 xhost +local: 2>/dev/null && echo \"[ok] xhost +local: on :99\" || echo \"[warn] xhost failed (non-fatal)\"; echo \"[info] DISPLAY will be :99 (noVNC display)\"; else echo \"[warn] :99 not available, falling back to :0\"; DISP=:0; XAUTH_SRC=/run/user/1000/gdm/Xauthority; [ -f \"$XAUTH_SRC\" ] && xauth -f $HOME/.Xauthority merge \"$XAUTH_SRC\" 2>/dev/null; DISPLAY=:0 xhost +local: 2>/dev/null || true; fi'",
2020
"bash -lc 'echo; echo \"[2/5] optional swap (run manually only if engine build fails due to OOM)\"; echo \"sudo mkdir -p /mnt/nvme\"; echo \"sudo fallocate -l 16G /mnt/nvme/swapfile\"; echo \"sudo chmod 600 /mnt/nvme/swapfile\"; echo \"sudo mkswap /mnt/nvme/swapfile\"; echo \"sudo swapon /mnt/nvme/swapfile\"; echo'",
21-
"bash -lc 'set -e; echo \"[3/5] start tutorial container + run GUI preview in background xauth mode\"; DISP=${DISPLAY:-}; if [ -z \"$DISP\" ]; then if [ -S /tmp/.X11-unix/X99 ]; then DISP=:99; elif [ -S /tmp/.X11-unix/X1 ]; then DISP=:1; else DISP=:0; fi; fi; XAUTH=\"\"; XAUTH_ENV=\"\"; XAUTH_MOUNT=\"\"; if [ \"$DISP\" != \":99\" ]; then XAUTH=/run/user/1000/gdm/Xauthority; if [ ! -f \"$XAUTH\" ]; then XAUTH=/home/seeed/.Xauthority; fi; if [ -f \"$XAUTH\" ]; then XAUTH_ENV=\"-e XAUTHORITY=$XAUTH\"; XAUTH_MOUNT=\"-v $XAUTH:$XAUTH:ro\"; fi; fi; pick_cam(){ for d in /dev/video0 /dev/video3 /dev/video1 /dev/video2; do [ -e \"$d\" ] || continue; if timeout 3s v4l2-ctl -d \"$d\" --stream-mmap --stream-count=1 --stream-to=/tmp/cam_probe.raw >/dev/null 2>&1; then echo ${d#/dev/video}; return 0; fi; done; echo 0; }; CAM=$(pick_cam); echo \"[info] start container with DISPLAY=$DISP XAUTH=${XAUTH:-none} CAMERA_ID=$CAM\"; sudo docker rm -f depth_anything_v3 >/dev/null 2>&1 || true; sudo docker run -d --name depth_anything_v3 --restart unless-stopped --runtime=nvidia --network host --ipc host --privileged -e DISPLAY=$DISP $XAUTH_ENV -e CAMERA_ID=$CAM -e QT_X11_NO_MITSHM=1 -e LIBGL_ALWAYS_SOFTWARE=1 -v /tmp/.X11-unix:/tmp/.X11-unix $XAUTH_MOUNT -v /dev:/dev chenduola6/depth_anything_v3:jp6.2 bash -lc \"set -e; cd /workspace/ros2-depth-anything-v3-trt; source install/setup.bash; if ls onnx/*.engine >/dev/null 2>&1; then printf \\\"[skip] engine already exists\\\\n\\\"; else printf \\\"[info] first run building TensorRT engine, this can take several minutes\\\\n\\\"; ros2 run depth_anything_v3 generate_engines onnx; fi; exec ./run_camera_depth.sh\"; sudo docker ps -a --filter name=depth_anything_v3'",
21+
"bash -lc 'set -e; echo \"[3/5] start tutorial container + run GUI preview\"; DISP=:99; xdpyinfo -display :99 >/dev/null 2>&1 || DISP=:0; pick_cam(){ for d in /dev/video0 /dev/video3 /dev/video1 /dev/video2; do [ -e \"$d\" ] || continue; if timeout 3s v4l2-ctl -d \"$d\" --stream-mmap --stream-count=1 --stream-to=/tmp/cam_probe.raw >/dev/null 2>&1; then echo ${d#/dev/video}; return 0; fi; done; echo 0; }; CAM=$(pick_cam); echo \"[info] start container with DISPLAY=$DISP CAMERA_ID=$CAM\"; sudo docker rm -f depth_anything_v3 >/dev/null 2>&1 || true; sudo docker run -d --name depth_anything_v3 --restart unless-stopped --runtime=nvidia --network host --ipc host --privileged -e DISPLAY=$DISP -e CAMERA_ID=$CAM -e QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev chenduola6/depth_anything_v3:jp6.2 bash -lc \"set -e; export DISPLAY=$DISP; cd /workspace/ros2-depth-anything-v3-trt; source install/setup.bash; if ls onnx/*.engine >/dev/null 2>&1; then printf \\\"[skip] engine already exists\\\\n\\\"; else printf \\\"[info] first run building TensorRT engine, this can take several minutes\\\\n\\\"; ros2 run depth_anything_v3 generate_engines onnx; fi; exec ./run_camera_depth.sh\"; sudo docker ps -a --filter name=depth_anything_v3'",
2222
"bash -lc 'echo \"[4/5] show depth_anything_v3 status (if started by reComputer path)\"; sudo docker ps -a --filter name=depth_anything_v3'",
2323
"bash -lc 'echo \"[5/5] follow logs for 120s\"; timeout 120s sudo docker logs -f depth_anything_v3 2>&1 || true; echo \"[hint] if still building engine, rerun Run and keep logs open\"'",
2424
]

seeed_jetson_develop/modules/remote/desktop_remote.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def build_install_vnc_cmd(sudo_password: str) -> str:
7070
return (
7171
f"echo '{escaped}' | sudo -S apt-get update && "
7272
f"echo '{escaped}' | sudo -S apt-get install -y "
73-
"x11vnc xvfb xauth dbus-x11 x11-xserver-utils novnc websockify python3-websockify openbox xterm"
73+
"x11vnc xvfb xauth dbus-x11 x11-xserver-utils novnc websockify python3-websockify openbox xterm xfce4 xfce4-terminal"
7474
)
7575

7676

@@ -143,7 +143,7 @@ def build_start_vnc_cmd(password: str = "", display: str = "", sudo_password: st
143143
"User=$USER_NAME\n"
144144
"Environment=HOME=$HOME_DIR\n"
145145
f"Environment=DISPLAY_HINT={display_hint}\n"
146-
"ExecStart=/bin/bash -lc 'set -e; DISP=\"$DISPLAY_HINT\"; if [ -n \"$DISP\" ] && ! xdpyinfo -display \"$DISP\" >/dev/null 2>&1; then DISP=\"\"; fi; if [ -z \"$DISP\" ]; then for d in :0 :1 :2 :99; do if xdpyinfo -display \"$d\" >/dev/null 2>&1; then DISP=$d; break; fi; done; fi; [ -n \"$DISP\" ] || DISP=:99; XAUTH=\"\"; for p in /run/user/1000/gdm/Xauthority \"$HOME/.Xauthority\"; do [ -f \"$p\" ] && XAUTH=$p && break; done; if [ -n \"$XAUTH\" ]; then AUTH_ARG=\"-auth $XAUTH\"; else AUTH_ARG=\"-auth guess\"; fi; exec /usr/bin/x11vnc $AUTH_ARG -display \"$DISP\" -forever -shared -rfbport 5900 -rfbauth \"$HOME/.vnc/passwd\" -noxdamage -noxfixes -nowf -nowcr -noscr -o /tmp/x11vnc.log'\n"
146+
"ExecStart=/bin/bash -lc 'set -e; DISP=\"$DISPLAY_HINT\"; if [ -n \"$DISP\" ] && ! xdpyinfo -display \"$DISP\" >/dev/null 2>&1; then DISP=\"\"; fi; if [ -z \"$DISP\" ]; then for d in :99 :1 :2 :0; do if xdpyinfo -display \"$d\" >/dev/null 2>&1; then DISP=$d; break; fi; done; fi; [ -n \"$DISP\" ] || DISP=:99; XAUTH=\"\"; for p in /run/user/1000/gdm/Xauthority \"$HOME/.Xauthority\"; do [ -f \"$p\" ] && XAUTH=$p && break; done; if [ -n \"$XAUTH\" ]; then AUTH_ARG=\"-auth $XAUTH\"; else AUTH_ARG=\"-auth guess\"; fi; exec /usr/bin/x11vnc $AUTH_ARG -display \"$DISP\" -forever -shared -rfbport 5900 -rfbauth \"$HOME/.vnc/passwd\" -noxdamage -noxfixes -nowf -nowcr -noscr -o /tmp/x11vnc.log'\n"
147147
"Restart=always\n"
148148
"RestartSec=2\n\n"
149149
"[Install]\n"
@@ -159,7 +159,7 @@ def build_start_vnc_cmd(password: str = "", display: str = "", sudo_password: st
159159
"User=$USER_NAME\n"
160160
"Environment=HOME=$HOME_DIR\n"
161161
"Environment=DISPLAY=:99\n"
162-
"ExecStart=/bin/bash -lc 'set -e; export DISPLAY=:99; export XDG_RUNTIME_DIR=/run/user/1000; if command -v openbox >/dev/null 2>&1; then dbus-launch --exit-with-session openbox; else xterm -geometry 120x40+20+20; fi'\n"
162+
"ExecStart=/bin/bash -lc 'set -e; export DISPLAY=:99; export XDG_RUNTIME_DIR=/run/user/1000; if command -v startxfce4 >/dev/null 2>&1; then dbus-launch --exit-with-session startxfce4; elif command -v openbox >/dev/null 2>&1; then dbus-launch --exit-with-session openbox; else xterm -geometry 120x40+20+20; fi'\n"
163163
"Restart=always\n"
164164
"RestartSec=2\n\n"
165165
"[Install]\n"
@@ -269,7 +269,7 @@ def build_write_headless_session_unit_cmd(username: str) -> str:
269269
f"User={user}\n"
270270
f"Environment=HOME=/home/{user}\n"
271271
"Environment=DISPLAY=:99\n"
272-
"ExecStart=/bin/bash -lc 'set -e; export DISPLAY=:99; export XDG_RUNTIME_DIR=/run/user/1000; if command -v openbox >/dev/null 2>&1; then dbus-launch --exit-with-session openbox; else xterm -geometry 120x40+20+20; fi'\n"
272+
"ExecStart=/bin/bash -lc 'set -e; export DISPLAY=:99; export XDG_RUNTIME_DIR=/run/user/1000; if command -v startxfce4 >/dev/null 2>&1; then dbus-launch --exit-with-session startxfce4; elif command -v openbox >/dev/null 2>&1; then dbus-launch --exit-with-session openbox; else xterm -geometry 120x40+20+20; fi'\n"
273273
"Restart=always\n"
274274
"RestartSec=2\n\n"
275275
"[Install]\n"
@@ -292,7 +292,7 @@ def build_write_x11vnc_unit_cmd(username: str, display: str = "") -> str:
292292
f"User={user}\n"
293293
f"Environment=HOME=/home/{user}\n"
294294
f"Environment=DISPLAY_HINT={display_hint}\n"
295-
"ExecStart=/bin/bash -lc 'set -e; DISP=\"$DISPLAY_HINT\"; if [ -n \"$DISP\" ] && ! xdpyinfo -display \"$DISP\" >/dev/null 2>&1; then DISP=\"\"; fi; if [ -z \"$DISP\" ]; then for d in :0 :1 :2 :99; do if xdpyinfo -display \"$d\" >/dev/null 2>&1; then DISP=$d; break; fi; done; fi; [ -n \"$DISP\" ] || DISP=:99; XAUTH=\"\"; for p in /run/user/1000/gdm/Xauthority \"$HOME/.Xauthority\"; do [ -f \"$p\" ] && XAUTH=$p && break; done; if [ -n \"$XAUTH\" ]; then AUTH_ARG=\"-auth $XAUTH\"; else AUTH_ARG=\"-auth guess\"; fi; exec /usr/bin/x11vnc $AUTH_ARG -display \"$DISP\" -forever -shared -rfbport 5900 -rfbauth \"$HOME/.vnc/passwd\" -noxdamage -noxfixes -nowf -nowcr -noscr -o /tmp/x11vnc.log'\n"
295+
"ExecStart=/bin/bash -lc 'set -e; DISP=\"$DISPLAY_HINT\"; if [ -n \"$DISP\" ] && ! xdpyinfo -display \"$DISP\" >/dev/null 2>&1; then DISP=\"\"; fi; if [ -z \"$DISP\" ]; then for d in :99 :1 :2 :0; do if xdpyinfo -display \"$d\" >/dev/null 2>&1; then DISP=$d; break; fi; done; fi; [ -n \"$DISP\" ] || DISP=:99; XAUTH=\"\"; for p in /run/user/1000/gdm/Xauthority \"$HOME/.Xauthority\"; do [ -f \"$p\" ] && XAUTH=$p && break; done; if [ -n \"$XAUTH\" ]; then AUTH_ARG=\"-auth $XAUTH\"; else AUTH_ARG=\"-auth guess\"; fi; exec /usr/bin/x11vnc $AUTH_ARG -display \"$DISP\" -forever -shared -rfbport 5900 -rfbauth \"$HOME/.vnc/passwd\" -noxdamage -noxfixes -nowf -nowcr -noscr -o /tmp/x11vnc.log'\n"
296296
"Restart=always\n"
297297
"RestartSec=2\n\n"
298298
"[Install]\n"

0 commit comments

Comments
 (0)