【Bash On Windows】在 Windows Subsystem for Linux(WSL) 上運行任何桌面環境(已達可用階段)

就想搞個大新聞,在 Github 中微軟的Bash On Windows 項目里,有一篇 Run any Desktop Environment in WSL 的內容。作者在 WSL 上已經成功運行了 Ubuntu 的 Unity 桌面環境,不過還有一些問題需要解決(現已解決)。在 dbus 問題解決後,已經做到了從運行到可用的階段。

之前遇到的問題(現已解決):

  • 現在只能從左側面板運行應用,無法進入 Unity 桌面的終端界面(如果要進入需要在 Windows 上打開另外一個 Bash,導出顯示屏運行 gnome-terminal

  • 作者還在測試 xfce4 桌面環境時發現有 dbus 的問題需要解決

dbus 的問題已經在 Reddit上有解決方案了。步驟如下:

  • 在 Bash On Windows 中安裝 X Server (vcxsrv 和 Xming 運行表現良好)
  • 執行:echo "export DISPLAY=:0.0" >> ~/.bashrc
  • 最後修復 dbus 的問題,因為 dbus 需要使用 unix sockets 來通信,但目前 Windows Bash 還不支持,所以只能使用 TCP 來解決這一問題,首先在 /etc/dbus-1/session.conf 中(需要 Root 許可權),將<listen>unix:tmpdir=/tmp</listen> 替換成 < listen>tcp:host=localhost,port=0</listen> ,可以使用下面一段命令來實現:sudo sed -i s$<listen>.*</listen>$<listen>tcp:host=localhost,port=0</listen>$ /etc/dbus-1/session.conf

好了,好好玩耍吧!

信仰還是要充值一下的!

推薦閱讀:

20.4 Shell 字元串 (從新手到菜鳥的Linux教程)
有哪些 Bash 的替代語言?
linux運維學不懂,很絕望, 求正確方法?
如何評價 Windows 版「bash」(及其相關 *nix 子系統)?

TAG:Windows10 | WindowsSubsystemforLinux | Unity桌面环境 | Bash |