#!/usr/bin/env bash # # gtk3 based popup dialog to launch a RDP session with FreeRDP/xfreerdp # # Requires: yad, xfreerdp, awk # # SPDX-License-Identifier: MIT # generic xfreerdp defaults to pre-fill in the dialog _XFDEFS="/cert-ignore /cert-tofu /bpp:16 +clipboard /size:1280x960" # yad gtk3 dialog _DATA=$(yad --title "FreeRDP Connection" --form --width=480 \ --field="Server\:" "" \ --field="Username\:" "" \ --field="Password\::H" "" \ --field="Domain\:" "" \ --field="Gateway\:" "" \ --field="Gateway User\:" "" \ --field="Gateway Password\::H" "" \ --field="Gateway Domain\:" "" \ --field=$"xfreerdp Options\:" "$_XFDEFS") _RES=$? # yad exits 0 = OK, 1 = Cancel if [[ $_RES -eq 0 ]]; then # pull the input out of the yad payload _SRV=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $1 }') _USER=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $2 }') _PASS=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $3 }') _DOMAIN=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $4 }') _GATEWAY=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $5 }') _GWUSER=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $6 }') _GWPASS=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $7 }') _GWDOM=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $8 }') _XFOPTS=$(echo "$_DATA" | awk 'BEGIN {FS="|" } { print $9 }') # launch the command with the inputs # shellcheck disable=SC2086 xfreerdp $_XFOPTS /t:"$_SRV" \ /g:"$_GATEWAY" /gu:"$_GWUSER" /gp:"$_GWPASS" /gd:"$_GWDOM" \ /d:"$_DOMAIN" /u:"$_USER" /p:"$_PASS" /v:"$_SRV" fi