Windows上WSL2桌面显示

前言

由于本人很多东西都是在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

查看是否有一双眼睛出现
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值