@wxy
https://linux.cn/article-16171-1.html
This commit is contained in:
Xingyu Wang 2023-09-08 09:05:33 +08:00
parent 2d3257926a
commit 6f2538dd4c
2 changed files with 251 additions and 244 deletions

View File

@ -0,0 +1,251 @@
[#]: subject: "Guide to Set up Full Wayland with Arch Linux"
[#]: via: "https://www.debugpoint.com/wayland-arch-linux/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: "ChatGPT"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-16171-1.html"
Arch Linux 下全面使用 Wayland 的配置指南
======
![][0]
> 我们能否在 Arch Linux 中通过主流的桌面环境或窗口管理器来全面运行 Wayland一起来探索答案。
Wayland 是一种针对 Linux 运行图形应用的高效、现代化的协议。相较之下,它在安全、稳定和图形性能方面相较老旧的 X.Org 显示服务器表现更出色。
尽管 X.Org 多年来一直是默认的显示服务器,但其年代漫长且复杂度高,导致了许多问题,包括安全漏洞和对新型硬件的兼容性问题。而 Wayland 提供了一个更简洁和安全的显示协议,用以解决这些问题。
虽然向 Wayland 转型已经有近十年的时间,但这是可以理解的。大型 Linux 发行版,例如 Ubuntu 和 Fedora自 2021 年起就默认使用 Wayland因为该协议现已逐渐稳定。
然而,对 Arch Linux 用户来说,使用 Wayland 进行自定义安装可能会比较复杂。在所有主流桌面环境中,只有 KDE Plasma 和 GNOME 有最新的 Wayland 支持。Xfce、LXQt 及其他桌面环境正在开发支持 Wayland 的功能,但现在还没有做好准备。
在窗口管理器方面Sway 在 Arch Linux 中已经全面支持 Wayland。尽管如此我还是希望能测试 Wayland 在 Arch 中的表现,并给你提供一个截至今日的状态报告。
让我们来尝试在 Arch Linux 中配置 KDE Plasma 和 GNOME 以全面支持 Wayland。
### Arch Linux 中的 Wayland 设置
在理想的情况下,你应已经安装了 [基础的 wayland 包][1]。打开一个终端,并通过运行下列命令进行核实:
```
pacman -Qi wayland
```
如果你尚未安装,则可以使用以下命令进行安装:
```
sudo pacman -S --needed wayland
```
#### KDE Plasma 桌面环境
接下来的步骤设定的前提条件是你拥有一个没有安装任何桌面环境或窗口管理器的裸机 Arch Linux 环境。你可以通过使用 [高效的 archinstall 脚本][2] 进行 Arch Linux 的裸机安装。
在 Arch Linux 中,为了设置标准的 KDE Plasma我们需要对 Wayland 进行一些调整。因此,该过程中需要从 AUR 安装一些包进来,这就要求你已经 [设置了 Yay][3] 或者其他的 AUR 辅助工具。
首先,利用以下命令从 AUR 安装一个定制的 sddm 显示管理器 Wayland 软件包。请注意,这个 `sddm` 包与 Arch Extra 仓库中的 `sddm` 包并不相同。根据 [ArchWiki][4] 的指南,只有 GDM 和 `sddm-git` 在 Arch Linux 中提供了完善的 Wayland 支持。
```
yay -S sddm-git
```
安装完成后,执行下述命令来安装更多 Wayland 包。
- `xorg-xwayland`:使得 xclients 能在 Wayland 下运行
- `xorg-xlsclients`:列出正在一个显示端口上运行的客户端应用(可选)
- `qt5-wayland`:为 Wayland 提供的 Qt API
- `glfw-wayland`:供 Wayland 使用的 GUI 应用开发包
```
pacman -S --needed xorg-xwayland xorg-xlsclients qt5-wayland glfw-wayland
```
然后,执行以下命令以安装 Plasma 和与 Wayland 会话关联的应用。请保持以下的安装顺序。
```
pacman -S --needed plasma kde-applications
```
```
pacman -S --needed plasma-wayland-session
```
**注意**:如果你是英伟达用户,你可能需要考虑安装 `egl-wayland` 包,但需要说明的是,我没有尝试过此操作。
我们现在来安装 Firefox 和 Chromium这样能够帮助我们测试 Wayland 是否正常运行。
```
pacman -S --needed firefox chromium
```
安装完成后,启动 sddm 显示管理器和 NetworkManager 服务。
```
sudo systemctl enable sddm
sudo systemctl enable NetworkManager
```
另外sddm 显示管理器需要做一些额外设置。使用你喜欢的文本编辑器,打开 sddm 的配置文件,然后在 `[Theme]` 下面添加 `Current=breeze`
```
sudo nano /usr/lib/sddm/sddm.conf.d/default.conf
```
```
[Theme]
# current theme name
Current=breeze
```
设置完成后,保存并关闭文件,然后进行重启。
```
reboot
```
重启后,在登录屏幕上,你应该可以看到 Wayland 的选项。选择并登录 KDE Plasma 的 Wayland 会话。
![Plasma Wayland 会话登录界面][5]
你还能通过查看 `$XDG_SESSION_TYPE` 变量来 [核实你是否在运行 Wayland][6]。
![Arch Linux 中运行的 KDE Plasma 与 Wayland][7]
如果你希望强制让 Firefox 以 Wayland 运行,那么就在 `/etc/environment` 中添加以下行。
```
MOZ_ENABLE_WAYLAND=1
```
然后重新启动或执行下方的命令使其生效。
```
source /etc/environment
```
打开 Firefox进入 `about:support` 页面来校验 “Window protocol” 的值。你也可以通过在终端中运行 `xlsclients` 来查看哪些外部应用正在运行在 Wayland 下。
![在 Arch 和 KDE Plasma 下 Firefox 使用的是 xwayland][8]
至此,你已经完成了在 Arch Linux 中使用 Wayland 安装配置 KDE Plasma 的全部步骤。
#### Wayland KDE Plasma 在 Arch 中的性能表现
总体而言Arch Linux 下的 KDE Plasma 配合 Wayland 运行得相当顺畅,未出现任何中断使用或重大问题的情形。截图和屏幕录制应用 Spectacle 功能一切正常。尽管如此,我在测试过程中还是注意到了几个小问题。
首先,在开启如 Dolphin 这类应用程序时,底部面板时不时会出现闪烁,这主要是在 VirtualBox 会话中观察到的。
其次,鼠标指针的变化行为有点奇怪。它无法适時地从指针状态切换到操作手柄状态(详见下图)。
![][8A]
最后,当从待机/屏幕关闭状态恢复在线时(在没有安装客户机插件的 VirtualBox 中KWin 会崩溃。虽然这可能只是虚拟机特有的现象,但仍然需要进行硬重启才能返回到桌面。
在 Arch Linux 的 Wayland 会话闲置状态下,内存消耗大约为 2GB。
### GNOME
在 Arch Linux 中GDM 显示管理器已经完全支持 Wayland。首先我们通过下列命令安装 GDM
```
pacman -S --needed gdm
```
安装完毕后,使用以下命令安装几个 Wayland 需要的包。
- `xorg-xwayland`:使得 xclients 能在 Wayland 下运行
- `xorg-xlsclients`:用于列出在显示器上运行的应用程序(可选)
- `glfw-wayland`Wayland 的图形用户界面应用开发包
```
pacman -S --needed xorg-xwayland xorg-xlsclients glfw-wayland
```
接下来,你可以用下面的一系列命令来安装 GNOME 和一些与 Wayland 会话相关的应用。请确保按照下列给出的顺序来执行这些命令。
```
sudo pacman -S --needed gnome gnome-tweaks nautilus-sendto gnome-nettool gnome-usage gnome-multi-writer adwaita-icon-theme xdg-user-dirs-gtk fwupd arc-gtk-theme
```
**注意**:如果你正在使用英伟达,你可能需要安装 `egl-wayland` 软件包,但我并未亲自试过此方法。
接下来,我们还要安装 Firefox 和 Chromium这样你就能测试 Wayland 是否在 GNOME 中正常运行。
```
pacman -S --needed firefox chromium
```
一旦这项任务完成,就启动 GDM 显示管理器和 NetworkManager 服务。
```
sudo systemctl enable gdm
sudo systemctl enable NetworkManager
```
保存并关闭文件之后,进行重启。
```
reboot
```
在登录界面,你能看到 “GNOME (Wayland)” 选项。选择并登录到 GNOME 的 Wayland 会话中,以进入 Arch Linux。
![在 Arch Linux 中运行的带有 Wayland 的 GNOME][9]
#### GNOME 的性能
如果将 GNOME 和 KDE Plasma 进行对比,你会发现 GNOME 在 Arch Linux 的 Wayland 下的表现更胜一筹。没有遇到重大问题或应用屏幕闪烁。这可能源于 GNOME 44 针对 Wayland 的最新改进已普及至 Arch Linux。
此外Firefox 是在 GNOME 上直接在 Wayland 上运行,而不是使用 xwayland 包装器。
![在 GNOME 中的 Firefox 使用 Wayland][10]
### 解决常见 Wayland 问题
虽然 Wayland 提供了众多优点,但在使用过程中你可能会遇到一些挑战。以下列出了几个常见的问题以及可能的解决方案:
- **处理不兼容的应用程序**:部分较旧或不常用的应用可能还未完全支持 Wayland。你可以考虑寻找专为 Wayland 设计的替代应用,或利用 XWayland 作为兼容性层。
- **解决性能相关问题**:如果你在特定的应用程序中遇到性能问题,确保你已经安装了最新的图形驱动。另外,也可以查看是否有特定的合成器设置或适用于特定应用程序的优化措施。
- 在 [这个页面][11] 中,也有**更多**疑难解答的建议。
### 结论
在 Arch Linux 中将 Wayland 设置为默认的显示服务器可以大大提升安全性、稳定性和图形性能。遵循本指南的安装和配置步骤,你能够从 Xorg 平稳过渡到 Wayland享受一个更为现代高效的显示体验。
然而,对于 Arch Linux 加 Wayland 的组合来说,整个过程可能会显得稍微复杂一些,因为许多问题崩溃时都需要额外的注意。
这个指南并没包括在 Arch 使用 Wayland 游戏的测试,所以你可能需要在配置完成后自行试验。我希望这篇教程能帮助你在 Arch Linux 中配置 Wayland。
如果你有任何进展,欢迎在下面的评论框中告诉我。
*题图MJ/188e0c86-ed52-4185-b583-23814fb72ce7*
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/wayland-arch-linux/
作者:[Arindam][a]
选题:[lkxed][b]
译者ChatGPT
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed/
[1]: https://archlinux.org/packages/extra/x86_64/wayland/
[2]: https://www.debugpoint.com/archinstall-guide/
[3]: https://www.debugpoint.com/install-yay-arch/
[4]: https://wiki.archlinux.org/title/wayland#Display_managers
[5]: https://www.debugpoint.com/wp-content/uploads/2023/05/Plasma-Wayland-session-during-login.jpg
[6]: https://www.debugpoint.com/check-wayland-or-xorg/
[7]: https://www.debugpoint.com/wp-content/uploads/2023/05/KDE-Plasma-with-Wayland-in-Arch-Linux.jpg
[8]: https://www.debugpoint.com/wp-content/uploads/2023/05/Firefox-is-using-xwayland-in-KDE-Plasma-with-Arch.jpg
[8A]: https://www.debugpoint.com/wp-content/uploads/2023/05/Screencast-from-2023-05-15-17-30-51.webm
[9]: https://www.debugpoint.com/wp-content/uploads/2023/05/GNOME-with-Wayland-running-in-Arch-Linux.jpg
[10]: https://www.debugpoint.com/wp-content/uploads/2023/05/Firefox-with-Wayland-in-GNOME.jpg
[11]: https://wiki.archlinux.org/title/wayland#Troubleshooting
[0]: https://img.linux.net.cn/data/attachment/album/202309/08/090159qe0jkbtj5z55bbeq.jpg

View File

@ -1,244 +0,0 @@
[#]: subject: "Guide to Set up Full Wayland with Arch Linux"
[#]: via: "https://www.debugpoint.com/wayland-arch-linux/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Guide to Set up Full Wayland with Arch Linux
======
**Is it possible to go full Wayland in Arch Linux using mainstream desktop environments or window managers? Lets find out.**
Wayland is a modern and efficient protocol for displaying graphical applications on Linux. It offers several advantages over the older X.Org display server, such as improved security, stability, and graphical performance.
While X.Org has been the go-to display server for many years, its age and complexity have led to various issues, including security vulnerabilities and compatibility problems with newer hardware. Wayland addresses these concerns by offering a more streamlined and secure display protocol.
However, its been almost a decade since the Wayland transition is going on, and it is understandable. Major Linux distributions, such as Ubuntu and Fedora already defaulted to Wayland sessions since 2021. The primary reason is the protocol is now stable enough.
However, Arch Linux users may find setting up a custom install with Wayland complex. Only KDE Plasma and GNOME have up-to-date Wayland support among all the mainstream desktop environments. Xfce, LXQt and other desktops are developing Wayland support, but they are not ready yet.
On the window manager front, Sway has full Wayland support in Arch Linux. That being said, I wanted to test how Wayland is performing in Arch and want to give you a status check as of today.
Lets try to set up KDE Plasma & GNOME in Arch Linux with full Wayland support.
### Set up Wayland in Arch Linux
Ideally, you should have the [base `wayland` package][1] installed already. Open a terminal and verify running the below command.
```
pacman -Qi wayland
```
If it is not installed, install it using:
```
sudo pacman -S --needed wayland
```
#### KDE Plasma Desktop
The following steps assume you have a bare metal Arch Linux installation without any desktop environment or window manager. You can install Arch Linux bare metal using the [great archinstall script][2].
Standard KDE Plasma setup in Arch Linux requires a few changes for Wayland. A few packages are needed from AUR, hence make sure to [set up Yay][3] or any other AUR helper.
Firstly, install a custom `sddm` display manager Wayland package from AUR using the following command. This is a different `sddm` package than the one available in the Arch “Extra” repo. As [per ArchWiki][4], only GDM and sddm-git have the proper Wayland support in Arch Linux at the moment.
```
yay -S sddm-git
```
Once installed, use the below command to install a few Wayland packages.
- xorg-xwayland: For running xclients under Wayland
- xorg-xlsclients: List client applications running on a display (optional)
- qt5-wayland: Qt APIs for Wayland
- glfw-wayland: GUI app dev packages for Wayland
```
pacman -S --needed xorg-xwayland xorg-xlsclients qt5-wayland glfw-wayland
```
Second, install the plasma and associated apps with Wayland sessions using the below set of commands. Execute them in the order mentioned below.
```
pacman -S --needed plasma kde-applications
```
```
pacman -S --needed plasma-wayland-session
```
**Note**: If you are using NVIDIA, you may want to install `egl-wayland`package. However, I have not tried it.
Lets install Firefox and Chromium as well, so that you can test Wayland is working properly.
```
pacman -S --needed firefox chromium
```
Once done, enable the display manager and NetworkManager service.
```
sudo systemctl enable sddmsudo systemctl enable NetworkManager
```
The sddm display manager needs a little more tweaks. Using any text editor, open the sddm configuration file and add `Current=breeze` under `[Theme]`.
```
sudo nano /usr/lib/sddm/sddm.conf.d/default.conf
```
```
[Theme]
# current theme name
Current=breeze
```
Once done, save and close the file. And reboot.
```
reboot
```
And in the login screen, you should see the Wayland option. Select and log in to the Wayland session of KDE Plasma in Arch Linux.
![Plasma Wayland session during login][5]
You can also verify [whether you are running Wayland][6] using $XDG_SESSION_TYPE variable.
![KDE Plasma with Wayland in Arch Linux][7]
If you want to force Firefox to use Wayland, then open `/etc/environment` and add the following line.
```
MOZ_ENABLE_WAYLAND=1
```
Then, reboot or run below to take effect.
```
source /etc/environment
```
Open Firefox and go to `about:support` to verify the value against “Window protocol”. You can also run `xlsclients` from the terminal to see which external apps are running under Wayland.
![Firefox is using xwayland in KDE Plasma with Arch][8]
So, that completes the KDE Plasma setup with Wayland in Arch Linux.
#### Performance of Wayland KDE Plasma session in Arch
Overall, the KDE Plasma in Wayland with Arch Linux works well. Nothing show-stopper or any major problems. The spectacle app is able to take screenshots and screencasts. That being said, a few things I noticed while testing the session.
Firstly there is an intermittent flicker in the bottom panel while launching applications such as Dolphin. Its inside the VirtualBox session.
Secondly, the mouse cursor behaviour is a little strange. The cursor is not changing its state from pointer to handle properly (see below).
Third, KWin crashed when returning online from a standby/screen off (in VirtualBox without guest additions). This might be specific to the virtual machine, but it required a hard reboot to go back to the desktop.
The memory consumption is around 2GB in idle Wayland sessions with Arch Linux.
#### GNOME
The following steps assume you have a bare metal Arch Linux installation without any desktop environment or window manager. You can install Arch Linux bare metal using the [great archinstall script][2].
The GDM display manager has full Wayland support in Arch Linux. First, install it using the below command:
```
pacman -S --needed gdm
```
Once installed, use the below command to install a few Wayland packages.
- xorg-xwayland: For running xclients under Wayland
- xorg-xlsclients: List client applications running on a display (optional)
- glfw-wayland: GUI app dev packages for Wayland
```
pacman -S --needed xorg-xwayland xorg-xlsclients glfw-wayland
```
Second, install the plasma and associated apps with Wayland sessions using the below set of commands. Execute them in the order mentioned below.
```
sudo pacman -S --needed gnome gnome-tweaks nautilus-sendto gnome-nettool gnome-usage gnome-multi-writer adwaita-icon-theme xdg-user-dirs-gtk fwupd arc-gtk-theme
```
**Note**: If you are using NVIDIA, you may want to install `egl-wayland`package. However, I have not tried it.
Lets install Firefox and Chromium as well, so that you can test Wayland is working properly with GNOME.
```
pacman -S --needed firefox chromium
```
Once done, enable the display manager and NetworkManager service.
```
sudo systemctl enable gdm
sudo systemctl enable NetworkManager
```
Once done, save and close the file. And reboot.
```
reboot
```
And in the login screen, you should see the _GNOME (Wayland)_ option. Select and log in to the Wayland session of GNOME in Arch Linux.
![GNOME with Wayland running in Arch Linux][9]
#### Performance of GNOME
If I compare GNOME and KDE Plasma, GNOME performed better with Wayland in Arch Linux. No significant problems or screen flickering in apps. This may be because of the recent changes done on GNOME 44 for Wayland, which landed in Arch Linux.
Also, Firefox runs natively in Wayland in GNOME, not using xwayland wrapper.
![Firefox with Wayland in GNOME][10]
### Troubleshooting common Wayland issues
While Wayland provides numerous benefits, you may encounter some challenges. Here are a few common issues and potential solutions:
- **Dealing with incompatible applications**: Some older or less commonly used applications may not yet have full Wayland support. Consider looking for alternative applications explicitly designed for Wayland or using XWayland as a compatibility layer.
- **Addressing performance-related concerns**: If you experience performance issues with specific applications, ensure you have installed the latest graphics drivers. Additionally, check if any specific compositor settings or application-specific tweaks can optimize performance.
- You can find **more tips** for troubleshooting [on this page][11].
### Conclusion
Setting up Wayland as your default display server in Arch Linux can significantly improve security, stability, and graphical performance. Following this guides installation and configuration steps, you can seamlessly transition from Xorg to Wayland and enjoy a more modern and efficient display experience.
However, you may find it a little complex for Arch Linux with Wayland since many items require special attention when things break.
I have not tested gaming on Arch with Wayland as part of this guide. Hence you may need to try that out after setting up. I hope this tutorial helps you to set up Wayland in Arch Linux.
Let me know how it goes for you in the comment box below.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/wayland-arch-linux/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed/
[1]: https://archlinux.org/packages/extra/x86_64/wayland/
[2]: https://www.debugpoint.com/archinstall-guide/
[3]: https://www.debugpoint.com/install-yay-arch/
[4]: https://wiki.archlinux.org/title/wayland#Display_managers
[5]: https://www.debugpoint.com/wp-content/uploads/2023/05/Plasma-Wayland-session-during-login.jpg
[6]: https://www.debugpoint.com/check-wayland-or-xorg/
[7]: https://www.debugpoint.com/wp-content/uploads/2023/05/KDE-Plasma-with-Wayland-in-Arch-Linux.jpg
[8]: https://www.debugpoint.com/wp-content/uploads/2023/05/Firefox-is-using-xwayland-in-KDE-Plasma-with-Arch.jpg
[9]: https://www.debugpoint.com/wp-content/uploads/2023/05/GNOME-with-Wayland-running-in-Arch-Linux.jpg
[10]: https://www.debugpoint.com/wp-content/uploads/2023/05/Firefox-with-Wayland-in-GNOME.jpg
[11]: https://wiki.archlinux.org/title/wayland#Troubleshooting