You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

remoteoffice.sh 1.1 KiB

3 vuotta sitten
3 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435
  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