diff --git a/bin/vncsconnect b/bin/vncsconnect index a7dcbe4..e6f2a33 100755 --- a/bin/vncsconnect +++ b/bin/vncsconnect @@ -3,6 +3,11 @@ # Variables declare -a ssh_args +# Fonction +ssh_bridge_already_exists() { + [ -n "$(lsof -nP -i TCP -s TCP:LISTEN | awk '($1 == "ssh" && $9 ~ /.*:'"${1}"'/) { print }')" ] +} + # Sélectionner le viewer adapté à la session if [ -n "$WAYLAND_DISPLAY" ]; then vncviewer=wlvncc @@ -32,8 +37,11 @@ if [ -n "$separator" ]; then fi # Exécution -set -e -ssh-fwd "${ssh_args[@]}" -- "$@" +if ! ssh_bridge_already_exists; then + ssh-fwd "${ssh_args[@]}" -- "$@" || exit +else + echo "Le pont SSH existe déjà !" +fi exec "$vncviewer" \ "${args[@]}"