Last active
February 19, 2020 18:49
-
-
Save kevinmilner/b33475efc6afaaab533186ea4b84bc27 to your computer and use it in GitHub Desktop.
Windows batch script to reliably launch gnome-terminal (or another terminal) in WSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasklist /FI "IMAGENAME eq vcxsrv.exe" 2>NUL | find /I /N "vcxsrv.exe">NUL | |
if "%ERRORLEVEL%"=="0" echo X server is running | |
if not "%ERRORLEVEL%"=="0" start "" "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -dpi auto | |
chcp utf8 | |
ubuntu run "sh -ic 'if [ -z \"$(pidof dbus-launch)\" ]; then export DISPLAY=127.0.0.1:0.0; dbus-launch --exit-with-x11; fi;'" | |
ubuntu run "DISPLAY=:0 gnome-terminal --working-directory=/home/kevin; sleep 1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script will reliable start VcXsrv (if not running). then start DBus if not running, then finally launch a terminal. The second step avoids a problem where it would only otherwise work by first launching a regular ubuntu instance. Replace 'ubuntu' and the home directory as necessary.