#!/usr/bin/env bash # Orisys 通止规工位桌面程序(窗口,不是网页)。 # # bash ~/ros2/scripts/run_console.sh set -eo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # shellcheck disable=SC1091 source "${ROOT}/scripts/env.sh" export PYTHONPATH="${ROOT}/src/arm_application${PYTHONPATH:+:${PYTHONPATH}}" # 屏幕跟当前登录会话走。这台工控机是 :1,别的 Linux 桌面常常是 :0。 if [[ -n "${DISPLAY:-}" ]]; then _disp="${DISPLAY#:}" _disp="${_disp%%.*}" if [[ ! -S "/tmp/.X11-unix/X${_disp}" ]]; then unset DISPLAY fi unset _disp fi if [[ -z "${DISPLAY:-}" ]]; then _seat="$(who | awk -v u="$(id -un)" '$1==u && $2 ~ /^:/ {print $2; exit}')" _seat="${_seat%%.*}" _n="${_seat#:}" if [[ -n "${_n}" && -S "/tmp/.X11-unix/X${_n}" ]]; then export DISPLAY="${_seat}" else for _sock in /tmp/.X11-unix/X*; do if [[ -S "${_sock}" ]]; then export DISPLAY=":${_sock##*/X}" break fi done fi unset _seat _n _sock fi # 有真实屏幕时不要留在 offscreen,否则 OpenGL 窗口起不来,模型也不会画到显卡上。 if [[ "${QT_QPA_PLATFORM:-}" == "offscreen" && -n "${DISPLAY:-}" ]]; then _disp="${DISPLAY#:}" _disp="${_disp%%.*}" if [[ -S "/tmp/.X11-unix/X${_disp}" ]]; then unset QT_QPA_PLATFORM fi unset _disp fi if [[ -z "${XAUTHORITY:-}" ]]; then if [[ -r "${HOME}/.Xauthority" ]]; then export XAUTHORITY="${HOME}/.Xauthority" elif [[ -r "/run/user/$(id -u)/gdm/Xauthority" ]]; then export XAUTHORITY="/run/user/$(id -u)/gdm/Xauthority" fi fi exec python3 -m arm_application.operator_app