简介
WSLg 是 Windows Subsystem for Linux GUI 的缩写,这个项目的目的是在一个完全集成的桌面体验中支持在 Windows 上运行 Linux GUI 应用程序(X11 和 Wayland)。
WSLg 为喜欢或需要在 PC 上运行 Windows 的开发人员、科学家或爱好者提供了一种集成的体验,他们还需要能够运行在 Linux 环境中工作得最好或唯一的工具或应用程序。虽然用户现在可以使用多个系统设置来实现这一点,使用专用于 Windows 和 Linux 的个人 PC、虚拟机托管 Windows 或 Linux,或者运行在 Windows 上并投射到 WSL 中的 XServer,但 WSLg 提供了一个更集成、用户友好和高效的替代方案。
WSLg 努力使 Linux GUI 应用程序在 Windows 上使用时感觉像本机一样自然。从集成到启动的开始菜单到出现在任务栏,alt-tab 体验到支持跨 Windows 和 Linux 应用程序的剪切/粘贴,WSLg 支持无缝桌面体验和利用 Windows 和 Linux 应用程序的工作流。
安装
前提:Windows 10 Insider Preview build 21362+
WSLg 将与即将发布的 Windows 一起发布。要获得 WSLg 的预览版,你需要加入 Windows Insider Program,并从 beta 或 dev 渠道运行 Windows 10 Insider 预览版。
建议在启用了 WSL 的虚拟 GPU(vGPU)的系统上运行 WSLg,这样你就可以从硬件加速的 OpenGL 渲染中受益。您可以从下面的每个合作伙伴那里找到支持 WSL 的预览驱动程序。
从零开始安装
从具有管理员权限的命令提示符中运行命令 wsl --install -d Ubuntu
,然后在出现提示时重新启动(如果下载很慢,可以考虑使用应用商店先安装 Ubuntu,然后再运行命令 wsl --install -d Ubuntu
)。
重新启动后,安装将继续进行。您将被要求输入用户名和密码。这些将是你的 Linux 证书,它们可以是你想要的任何东西,而不必与你的 Windows 证书相匹配。
这样 WSL 和 WSLg 已经安装,可以使用了!
从已存在 WSL 的上安装
如果您有一个没有 WSLg 的现有 WSL 安装,并且想要更新到包含 WSLg 的最新版本的 WSL,那么从一个提升的命令提示符运行命令 WSL --update
。
通过在一个提升的命令提示符中运行此命令重新启动WSL,确保首先保存所有挂起的工作:
wsl --shutdown
安装 GUI 应用
## Update list of available packages
sudo apt update
## Gedit
sudo apt install gedit -y
## GIMP
sudo apt install gimp -y
## Nautilus
sudo apt install nautilus -y
## VLC
sudo apt install vlc -y
## X11 apps
sudo apt install x11-apps -y
## Google Chrome
cd /tmp
sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt install --fix-broken -y
sudo dpkg -i google-chrome-stable_current_amd64.deb
## Microsoft Teams
cd /tmp
sudo curl -L -o "./teams.deb" "https://teams.microsoft.com/downloads/desktopurl?env=production&plat=linux&arch=x64&download=true&linuxArchiveType=deb"
sudo apt install ./teams.deb -y
## Microsoft Edge Browser
sudo curl https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-dev/microsoft-edge-dev_93.0.946.1-1_amd64.deb -o /tmp/edge.deb
sudo apt install /tmp/edge.deb -y
一旦安装了这些应用程序,就可以在开始菜单的发行版名称下找到它们。例如Ubuntu -> Microsoft Edge。
你也可以使用命令从终端窗口启动它们:
- xcalc, xclock, xeyes
- gimp
- gedit ~/.bashrc
- nautilus
- vlc
- google-chrome
- teams
- microsoft-edge
汉化
参考:wsl2-kali基础配置(换源、切换中文、安装完整版、包含无法打开Windows商店的情况下安装wsl等)_寻觅的博客-CSDN博客_wsl2换源
将 Windows 主系统中的字体先移动到子系统中,再汉化:
# 创建一个文件夹用于存放字体
sudo mkdir -p /usr/share/fonts/windows
# 将Windows系统中的字体导入到kali中
sudo cp -r /mnt/c/Windows/Fonts/*.ttf /usr/share/fonts/windows/
# 下载字体管理器
sudo apt install -y fontconfig
临时汉化
临时汉化只是本次生效,不需要重启,控制台后再打开即会失效,变回英文模式:
# 设置临时汉化
export LC_ALL=zh_CN.UTF8 and LANG=zh_CN.UTF8 and LANGUAGE=zh_CN.UTF8
# 清除字体缓存
fc-cache
永久汉化
永久汉化需要我们修改一个配置文件,永久汉化后,就算重启,还是会保持汉化:
# 打开配置文件
code /etc/profile
在上述文件中添加
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8