1#compdef rdesktop xfreerdp
2
3local curcontext="$curcontext" state line expl args redir ret=1
4typeset -A opt_args
5
6case $service in
7  rdesktop)
8    args=(
9      '(-5)-4[use RDP version 4]'
10      '(-4)-5[use RDP version 5]'
11      '-b[force server to use bitmaps for screen updates]'
12      '-B[use X server backing store]'
13      '-E[disable encryption]'
14      "-m[don't send mouse motion events]"
15      '-C[use private colormap]'
16      '-S[single application mode]'
17      '-N[enable numlock synchronisation]'
18      '-P[enable bitmap caching]'
19      '*-r[device redirection]: :->redirection'
20    )
21  ;;
22  xfreerdp)
23    args=(
24      '(-)'{-h,--help}'[display help information]'
25      "-o[don't redirect audio to client]"
26      '-s[set startup-shell]:shell'
27      '-t[connect to specified port]:port:_ports'
28      '--app[RemoteApp connection]'
29      '--ext[load an extension]:extension'
30      '--no-auth[disable authentication]'
31      '--authonly[authentication only, no UI]'
32      '--from-stdin[prompt for username, password, domain and hostname]'
33      '--no-fastpath[disable fast-path]'
34      '--gdi[graphics rendering]:backend:(hw sw)'
35      "--no-motion[don't send mouse motion events]"
36      '--no-osb[disable offscreen bitmaps]'
37      '--no-bmp-cache[disable bitmap cache]'
38      '--plugin[load a virtual channel plugin]:(cliprdr drdynvc rdpsnd rail rdpdbg rdpdr)'
39      '--rfx[enable RemoteFX]'
40      '--rfx-mode[RemoteFX operational flags]:mode:((v\:video i\:image))'
41      '--nsc[enable NSCodec]'
42      '--disable-wallpaper'
43      '--composition[enable desktop composition]'
44      '--disable-full-window-drag'
45      '--disable-menu-animations'
46      '--disable-theming'
47      '--kbd-list[list all keyboard layout ids used by -k]'
48      '--no-rdp[disable Standard RDP encryption]'
49      '--no-tls[disable TLS encryption]'
50      '--no-nla[disable network level authentication]'
51      '--ntlm[force NTLM authentication protocol version]:version:(1 2)'
52      '--certificate-name[specify logon certificate]:certificate'
53      '--ignore-certificate[ignore verification of logon certificate]'
54      '--sec[force protocol security]:security:(rdp tls nla)'
55      '--secure-checksum[use salted checksums with Standard RDP encryption]'
56      '--version[print version information]'
57    )
58  ;;
59esac
60
61_arguments -C -s $args \
62  '-u[username]:username:_users' \
63  '-d[domain]:domain' \
64  '-s[shell]:startup shell' \
65  '-c[working directory]:directory:_directories' \
66  '-p[password]:password' \
67  '-n[set reported client hostname]:client hostname:_hosts' \
68  '-k[keyboard map]:keyboard map' \
69  '(-f)-g[geometry]:geometry (WxH)' \
70  '(-g)-f[fullscreen mode]' \
71  '-D[hide window decorations]' \
72  '-K[do not override window manager key bindings]' \
73  '-T[set window title]:title' \
74  '-X[embed in another window]:window:_x_window' \
75  '-a[colour depth]:depth:(8 15 16 24 32)' \
76  '-z[enable compression]' \
77  '-x[bandwidth performance behaviour]:experience:((b\:broadband l\:lan m\:modem))' \
78  '-0[attach to server console]' \
79  ':server:->hostsport' && ret=0
80
81case $state in
82  hostsport)
83    if compset -P '*:'; then
84      _ports && ret=0
85    else
86      compset -S ':*'
87      _hosts && ret=0
88    fi
89  ;;
90  redirection)
91    redir="${PREFIX%%:*}"
92    if compset -P 1 '*='; then
93      curcontext="${curcontext%:*}:$redir"
94      case $redir in
95	comport|lptport) _wanted devices expl device _files -g '*(-%)' && ret=0 ;;
96	disk) _directories && ret=0 ;;
97	printer) _printers && ret=0 ;;
98	scard) _message -e aliases 'alias name' ;;
99      esac
100    else
101      compset -S '=*'
102      _values -S : 'redirection' \
103	'comport:port' \
104	'disk:sharename' \
105	'lptport:lptport' \
106	'printer:printername:_printers -S=' \
107	'sound:sound:(local off remote)' \
108	'lspci' \
109	'scard:sound card name' && ret=0
110    fi
111  ;;
112esac
113
114return ret
115