#!/bin/sh set -x # VPN NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727" # RDP DEF_RESOLUTION="1920x1080" DRIVE="work,${HOME}/Documents/Work" DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')" USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')" REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')" rdp() { # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage REMOTE=$(dig ${REMOTE} A +short) # alternative to "dynamic-resolution" is "smart-sizing" xfreerdp /network:lan /gdi:hw +glyph-cache +fonts +aero \ /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \ /audio-mode:0 /sound:sys:pulse /microphone:sys:pulse \ /kbd:German /drive:${DRIVE} \ +auto-reconnect /auto-reconnect-max-retries:5 \ /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:$(zenity --entry \ --title="Password" --text="Enter your _password:" --hide-text) zenity --question --title="Disconnect?" \ --text="RDP connection closed. Do you want to close the VPN connection too?" && \ nmcli con down ${NMCONN} } if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then rdp else nmcli --ask con up ${NMCONN} & rdp fi