您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

36 行
1.1 KiB

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