Advertisement
Semper_Idem

WSL VcXsrv setup

Jan 18th, 2021
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.76 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. cd ~
  4.  
  5. if [ -z "$(grep custom-hosts-added /etc/hosts)" ]; then
  6.     sudo sh -c 'echo "# custom-hosts-added " >> /etc/hosts'
  7.     # add your hosts here
  8. else
  9.     echo "/etc/hosts is up to date"
  10. fi
  11.  
  12. export WSLHOST=$(ip address show dev eth0 | awk -F '[ /]+' '/inet / { print $3 }')
  13. export WINHOST=$(grep -oP "(?<=nameserver ).+" /etc/resolv.conf)
  14. export DISPLAY=127.0.0.1:0.0
  15. WSLENV="$WSLENV:DISPLAY"
  16. powershell.exe -Command 'taskkill /f /im vcxsrv.exe'
  17. powershell.exe -Command '& "C:\Program Files\VcXsrv\vcxsrv.exe" -multiwindow -clipboard -nowgl'
  18. powershell.exe -Command '& "C:\Program Files\VcxSrv\xhost.exe" '+$WSLHOST
  19. sleep 1
  20. export DISPLAY=$WINHOST:0.0
  21. sudo service dbus start
  22.  
  23. nohup unity-settings-daemon >/dev/null 2>&1 &
  24. gnome-terminal
  25.  
  26. exit 0
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement