- Launch Emacs in graphical mode from WSL2 (Ubuntu) without using built-in WSLg X11 server
- Avoid the black terminal window when starting Emacs from a Windows icon
- Have a clickable icon in the Windows Taskbar
- Install an external open-source X11 server recommended VcXsrv
- Create a
.vbsfile to hide the Windows terminal window that normally appears when launching Emacs from a.batfile - Create a
.batfile that the.vbsfile calls to start Emacs cleanly - Windows does not allow pinning
.vbsfiles directly to the Taskbar or Start menu- Create a shortcut to
wscript.exethat runs your.vbsfile:- Right-click on desktop => New => Shortcut
- Use this as the target:
wscript.exe "C:\Scripts\start-emacs-x11.vbs"
- Create a shortcut to
-
In Emacs:
M-:and evaluate:(getenv "DISPLAY")If it returns an IP address (e.g.,192.168.x.x:0), it's likely using VcXsrv -
Also check:
(getenv "WAYLAND_DISPLAY")If it returnsnil, Emacs is not using WSLg's built-in Wayland/X server -
To ensure WSLg is disabled, add this to your
.bashrc:unset WAYLAND_DISPLAY