Skip to content

Instantly share code, notes, and snippets.

@NobodyXu
Created January 23, 2020 03:30
Show Gist options
  • Save NobodyXu/09a548c2e5e3cef10c6150579fdabc7d to your computer and use it in GitHub Desktop.
Save NobodyXu/09a548c2e5e3cef10c6150579fdabc7d to your computer and use it in GitHub Desktop.
Run vmware with unity using cygwin/x

Install cygwin/x

See here

Putty

Install putty, and then enter your virtual machine's IP, then go to Connection->ssh->X11, click Enable X11 forwarding and give the Xauthority file C:\Cygwin64\C:\cygwin64\home\${YOUR_USERNAME_HERE}\.Xauthority. Save the session with your favorite name to reuse the session.

Testing

Now, start the session and enter your passwd. Try launching any GUI program.

Using another terminal

You can now open a ssh connection to the vm machine via another ssh session or another ssh tool, like terminus, which is much more beautiful than putty. First, in that putty session, type echo $DISPLAY and enter. COPY THE OUTPUT. Then, in the new ssh session, type export $DISPLAY=${WHAT_YOU_JUST_COPIED} and enter. Try to launch a GUI program in that session, you will find that as long as you keep that putty session open, you can launch any GUI program in the new session, too, as long as you repeat the process above every time.

Automation of the section above

Add the following line to ~/.bashrc so that you can always open GUI program in another ssh session as long as the putty session is open:

# Automatically save and load DISPLAY
# NOTE: This script will record the last session that has environment variable `DISPLAY` set.
if [ -z "$DISPLAY" ]; then
    export DISPLAY=`cat ~/.XDISPLAY.var`
else
    echo $DISPLAY > .XDISPLAY.var
fi

Disable x-server auto start in the vm

Since x-server on the vm is not required for this unity mode to work, it is safe to disable it at from auto starting. See here.

Tips

If you are using vmware pro 15, then you can close the vmware window without also closing the virtual machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment