[Bash on Windows] Getting dbus and X server working

[Origin]: https://www.reddit.com/r/Windows10/comments/4rsmzp/bash_on_windows_getting_dbus_and_x_server_working/

submitted 1 year ago * by ShaRose

So, most people who are using bash subsystem in the windows 10 insider builds seem to be aware that it’s possible to use X servers for windows such as vcxsrv or Xming, but most applications require the dbus service, which doesn’t work. This results in applications like Firefox or virt-manager (when ran in the linux subsystem) to crash either on launch or after a short time, and so it’s seen as fairly buggy.

However, the main application I wanted to run for this was virt-manager, because I wanted to be able to administrate qemu servers on windows without having to use a VM to run that. virt-manager needs a dbus server to even launch, so I started trying to get it running: And I succeeded. And surprisingly, it was fairly easy.

All that needed to be done (From a clean install of windows 10 with Bash installed, of course) was do three steps:

1) install an X server. vcxsrv and Xming are confirmed to both work just fine.

2) add DISPLAY=:0.0 to your bashrc: you can do this by executing the following command

echo "export DISPLAY=:0.0" >> ~/.bashrc

Now X programs will show the window correctly.

3) Now we need to fix dbus: The issue with this was that by default, dbus uses unix sockets to communication, which windows bash at the moment doesn’t support. So we just need to tell it to use tcp. In /etc/dbus-1/session.conf, you need to replace <listen>unix:tmpdir=/tmp</listen> with <listen>tcp:host=localhost,port=0</listen> and then you are done. Note this file needs root to edit. An easy way to do this is to execute the following:

sudo sed -i ‘s$&lt;listen&gt;.*&lt;/listen&gt;$&lt;listen&gt;tcp:host=localhost,port=0&lt;/listen&gt;$’ /etc/dbus-1/session.conf

And now close bash, and open it again. Feel free now to run whatever: Firefox and virt-manager work. Chrome sadly doesn’t for another reason of note.

Hope that helps someone.

Advertisements