0

I tried to run echo $DISPLAY but it doesn't return anything, just a blank line.

I read that it's supposed to return something like :0. Why is this happening and how do I fix it?

qwertpoi
  • 1
  • 1
  • 1
  • 2
    Hello and Welcome to Ask Ubuntu! You have this tagged [tag:windows-subsystem-for-linux], but you don't say which Windows version. I'm assuming Windows 10 if you don't have a DISPLAY variable, since Windows 10 WSL doesn't support Linux graphical apps by default. See this question for ways to do that on Windows 10 or Windows 11 - What's the easiest way to run GUI apps on Windows Subsystem for Linux?. Thanks! – NotTheDr01ds Apr 19 '22 at 10:54
  • @NotTheDr01ds I see, thank you! I've edited my question with the Windows version. I've tried to run export DISPLAY=:0 and at least now I get :0 when running echo $DISPLAY. Plus I get a different error in the code I'm trying to run, so I guess that's progress! – qwertpoi Apr 19 '22 at 11:02
  • Setting the variable to :0 will only work under WSL1. As noted in my answer on the question I linked, on WSL2 (with Windows 10, as I assume you are using), you'll need export DISPLAY="$(hostname).local:0". You'll also need a third-party X11 server such as VcXsrv. – NotTheDr01ds Apr 19 '22 at 11:05
  • Hi, thank you for your reply. How do I find out the hostname? And how shall I get the third-party X11 server? – qwertpoi Apr 30 '22 at 15:45
  • The command that I provided above should actually set the DISPLAY variable with the correct hostname for you without anything additional. If not, what happens if you echo "$(hostname).local:0"? As for the X server, there are quite a few links to VcXsrv in the question linked above. I think some others are mentioned and linked as well in there. – NotTheDr01ds Apr 30 '22 at 21:18

0 Answers0