It sounds like you:
Already have your DISPLAY
variable set up properly and can run Firefox from the commandline in VcXsrv. That's a great start.
Don't yet have the DISPLAY
variable exported in ~/.bashrc
, since you mention having to export it manually.
If that's the case, then you'll first need to export the variable in your startup config. If you have already done this part, skip to the "Shortcut commandline" section below.
Export DISPLAY in startup
Add the following to your ~/.bashrc
:
export DISPLAY="$(hostname).local:0"
That uses mDNS to pick up the proper IP address based on my answer here on the topic. If you have another DISPLAY
setting that works for you, you can use it instead, but I find the hostname
based approach the easiest in most cases.
Then:
source ~/.bashrc
to have it re-read the configuration. You could also restart the shell to make sure. Then make sure Firefox runs.
Shortcut commandline
The above works when you are in an interactive shell, since the rc file is sourced for interactive shells. However, when you are launching Firefox via a shortcut, you'll need to use the wsl.exe
command, and by default that isn't an interactive (or login) shell.
Going from memory here, try setting your Windows shortcut to:
wsl -e bash -lic "firefox"
That will run Bash:
- As a login shell (
-l
) which will source your ~/.bash_profile
- As an interactive shell (
-i
) which will source your ~/.bashrc
- And run the command (
-c
) firefox