如何在 Arch 系统上安装 Wayland 支持的 Visual Studio Code
最编程
2024-02-24 08:24:36
...
文章目录
- 安装vscode
- 在Wayland下模糊的解决方法
- 在Wayland下无法使用输入法的解决方法
安装vscode
虽然官网下载一般是首先,但是比较复杂,所以推荐使用AUR:
yay -S visual-studio-code-bin
然后就可以用了:
在图中可能看不出来,其实这个图在我的高分辨率的屏是非常模糊的。
在Wayland下模糊的解决方法
(这才是本文的重点)
在网上查找,对这个问题的中文说明非常少,但是在ArchWiki上有解释:Visual Studio Code - ArchWiki。其实就是Electron在Wayland下的通用问题(vscode是基于Electron开发的)。
在ArchWiki上也有解决方案:Wayland - ArchWiki
简单地说就是要加两个参数:
--enable-features=WaylandWindowDecorations --ozone-platform-hint=auto
为了实现开始菜单和右键菜单打开的vscode显示正确,需要修改/usr/share/applications/code.desktop
,在每个Exec=
中加上这两个参数:
Exec=/usr/bin/code --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --unity-launch %F
Exec=/usr/bin/code --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --new-window %F
然后就正常了。
还有另一种更直接更有效的方法,直接在文件中配置,可以对任何方式启动的code生效(包括从命令行启动):
在~/.config/code-flags.conf中加上两行:
--enable-features=WaylandWindowDecorations
--ozone-platform-hint=auto
就可以全局生效了。
在Wayland下无法使用输入法的解决方法
和上一节“在Wayland下模糊的解决方法”类似,需要再加一个参数:
--enable-wayland-ime
直接在命令行使用(配置.desktop文件同理):
code --enable-wayland-ime
# 如果加上对模糊的处理
code --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto --enable-wayland-ime
配置~/.config/code-flags.conf文件:
--enable-wayland-ime
# 如果加上对模糊的处理
--enable-features=WaylandWindowDecorations
--ozone-platform-hint=auto
注:如果看过本博客的之前的版本,用的是~/.config/electron-flags.conf,但是目前测试无效,未知原因,但是在~/.config/code-flags.conf中添加参数实测有效(即所有的参数都加在~/.config/code-flags.conf中)
上一篇: 开发环境配置