johnslattery
8/25/2016 - 7:00 PM

Connect directly to a Windows internal RDP server using freerdp, modifying to suit display and network speed. Example of building up command

Connect directly to a Windows internal RDP server using freerdp, modifying to suit display and network speed. Example of building up command line arguments in arrays and the properly expanding them on the command line of the program.

declare -a xfreerdp_opts=(/u:john@jslattery.org /cert-ignore \
  +clipboard)
declare -a xfreerdp_non_opts=("/v:$host")

case "$display_scheme" in
  '1920x1080_display' )
    xfreerdp_opts+=(/size:1900x1000)
    ;;
  '1600x1200_display' )
    xfreerdp_opts+=(/size:1550x1100)
    ;;
  * )
    printf "Unrecognized display scheme '%b'.\n" "$display_scheme" >&2
    exit 1
    ;;
esac

case "$network" in
  'lan' )
    ;;
  'wan' )
    xfreerdp_opts+=(/bpp:16 /network:modem /compression)
    ;;
  * )
    printf "Unrecognized network '%b'.\n" "$display_scheme" >&2
    exit 1
    ;;
esac

xfreerdp ${xfreerdp_opts[*]} ${xfreerdp_non_opts[*]}