前言
由于本人很多东西都是在Windows上,如果使用传统的双系统的话,随着系统的切换会带来挺多不方便,所以我也开始尝试使用WSL。
WSL的配置
系统换源
我安装的是Ubuntu18.04,我使用这些系统开始使用的第一步都是系统换源,毕竟用国外的源下载还是太慢了。
首先修改/etc/apt/sources.list这个文件
sudo vim /etc/apt/sources.list
然后在文件末将下面这些源拷贝进去,这里使用的是阿里的源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
然后将上面原始的源全部注释掉,最后在更新一下
sudo apt-get update
这样就完成了换源
安装xfce4
sudo apt-get install xfce4 xfce4-terminal #安装xfce4桌面
然后在环境变量中添加桌面显示的IP
echo "export WINDOWS_NAMESERVER=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'`" >> ~/.bashrc #添加获取本机IP
echo "export DISPLAY_PORT=0" >> ~/.bashrc #添加显示端口
echo "export DISPLAY=$WINDOWS_NAMESERVER:$DISPLAY_PORT" >> ~/.bashrc //显示IP
然后更新
Windows的配置
安装VcXsrv
下载地址:https://sourceforge.net/projects/vcxsrv/
下载后双击安装。
Xlaunch配置
打开Xlaunch
选择Multiple windows,这会使得每个app都是单独展示出来。Dispaly number填1。
点击下一页
选择第一个后点击下一页
将Native opengl上的勾去掉(这一步是后续使用ROS的rivz和gazebo如果没有去掉这个勾就无法显示出来)同时勾选Disable access control(如果没有勾选桌面则无法显示)后点击下一页
最后点击完成即可。
运行
这里为了测试效果我们先下载一个小小的程序,用来查看配置是否生效
sudo apt install x11-apps
运行
xeyes
查看是否有一双眼睛出现