Requirements:
- WSL2上的发行版
- 下面是以Ubuntu 23.10 (Mantic Minotaur)为例的
- VcXsrv
1. 给发行版添加systemd支持
理论上WSL2可以加两行配置就能顺利使用systemd的,但是我在网上找到的相关教程都是用的下面的脚本,我试了,能用,所以我也直接复制粘贴了
注意:根据原repo反馈这个脚本有概率让你的WSL2无法启动,请备份好数据
sudo apt install git
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished
然后在Windows中运行wsl --shutdown
,再进入wsl2,如果顺利的话就可以通过systemctl
看到Units了
2. 安装配置KDE
先装好KDE
sudo apt install kde-plasma-desktop
然后在你的.bashrc
(如果你用的是bash)中导入两个环境变量
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
export LIBGL_ALWAYS_INDIRECT=0
3. 配置Windows防火墙
如果你遇到任何WSL2无法访问host的问题,那绝对是这个防火墙干的
打开Control Panel\All Control Panel Items\Windows Defender Firewall
(Explorer可粘贴直达),查看Advanced Settings
(在最左边小标题里),再选择Windows Defender Firewall Properties
,会打开一个小页面,选择Public Profile
,点击Customize
,取消选中vEthernet(WSL)
,最后保存即可
4. 开始使用
打开VcXsrv(XLaunch),选择One Large Window->Start no client->选择Disable access control->Finish
最后在WSL2中输入startplasma-x11
即可看到KDE出现
Comments | NOTHING