diff --git a/bin/ssh-fwd b/bin/ssh-fwd index 0f5c81b..86f5158 100755 --- a/bin/ssh-fwd +++ b/bin/ssh-fwd @@ -38,6 +38,7 @@ requested_port_bridge_pid() { while [ -n "$1" ]; do case "$1" in --) + shift break ;; *) @@ -55,11 +56,11 @@ fi pid="$(requested_port_bridge_pid "${args[1]}")" if [ -z "$pid" ]; then exec "${ssh[@]}" \ - "$@" \ -f \ -N \ -L "${args[1]}:${args[3]:-localhost}:${args[2]}" \ - "${args[0]}" + "${args[0]}" \ + "$@" else echo "Suppression de la redirection..." kill "$pid" diff --git a/bin/vncsconnect b/bin/vncsconnect index a2469e3..a7dcbe4 100755 --- a/bin/vncsconnect +++ b/bin/vncsconnect @@ -1,37 +1,39 @@ #!/bin/bash # Variables -declare -a make_ssh_bridge open_vnc_session -ssh_fwd=ssh-fwd -vncviewer=wlvncc -localhost=localhost +declare -a ssh_args + +# Sélectionner le viewer adapté à la session +if [ -n "$WAYLAND_DISPLAY" ]; then + vncviewer=wlvncc +else + vncviewer=vncviewer + separator=: +fi # Arguments -ssh_host="$1" ; shift -local_port="${1:-9900}" ; shift -distant_port="${1:-5900}"; shift -target="$1" ; shift +while [ -n "$1" ]; do + case "$1" in + --) + shift + break + ;; + *) + ssh_args+=("$1") + shift + ;; + esac +done -# Commands building -# Make SSH bridge -make_ssh_bridge+=( - "$ssh_fwd" - "$ssh_host" - "$local_port" - "$distant_port" - "$target" -) +# Initialiser les arguments du viewer +args=(localhost "${ssh_args[1]}") +if [ -n "$separator" ]; then + args=("${args[*]// /${separator}/}") +fi -# Open VNC session -open_vnc_session+=( - "$vncviewer" - "$@" - "${localhost}" - "${local_port}" -) - -# Execution -set -xe -"${make_ssh_bridge[@]}" -"${open_vnc_session[@]}" +# Exécution +set -e +ssh-fwd "${ssh_args[@]}" -- "$@" +exec "$vncviewer" \ + "${args[@]}"