Wayland入门学习
一,Wayland使用情况
Xorg(或X11)是传统的显示服务器,而Wayland相对较新。
2017年,Ubuntu将Wayland作为17.10版的默认显示服务器,但实验进展不顺利,于是在Ubuntu 18.04里恢复了Xorg。
现在,Wayland在21.04版本中再次成为默认版本。
我最新使用的Ubuntu 22.04.1 LTS,使用的是Wayland。
$ echo $XDG_SESSION_TYPE
参考:
https://itsfoss.com/switch-xorg-wayland/
https://itsfoss.com/display-server/
二,Wayland下如何截屏
1,目前,Wayland不支持普通应用程序截屏。
Wayland的一个特点是其安全设计,有助于保护用户免受恶意应用程序的攻击。普通应用程序无法通过截屏来监视你。
普通应用程序只能看到自己的窗口,而看不到其他窗口(否则可能会立即崩溃)。
参考:
https://support.hubstaff.com/screenshot-capture-support-wayland-linux/
https://fedoraproject.org/wiki/How_to_debug_Wayland_problems#Screen_capture_is_not_available_with_usual_apps
但是,特定的compositor(window manager/shell)下,还是有办法进行截屏,不过这就依赖各自compositor的特定API了。
GNOME内置录屏软件,不过没有图像界面。
GNOME’s built-in screen recorder:https://itsfoss.com/gnome-screen-recorder/
Kooha工具,但它一直在屏幕上显示计时器。https://itsfoss.com/kooha-screen-recorder/
OBS Studio v27开始支持Wayland录屏。这个可以!
https://obsproject.com/
Ubuntu 22.04.1 LTS上安装使用obs:
$ sudo apt install obs-studio
$ obs
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not find the Qt platform plugin “wayland” in “”
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
已放弃 (核心已转储)
需要安装如下包:
$ sudo apt-get install qtwayland5
再执行obs就不报错了。
然而,使用Pipewire屏幕采集,挂了。。。不可用?
参考:
https://itsfoss.com/screen-record-obs-wayland/
这个kooha可能可以用,但我没试:
https://ubuntuhandbook.org/index.php/2021/10/record-screen-ubuntu-wayland-kooha/
https://github.com/SeaDve/Kooha
三,X11,Wayland,Gnome概念
X11:
1,客户端/服务器网络协议,允许远程访问显示器,键盘和鼠标。
2,协议包括程序的显示方式,包括单击复选框、移动窗口、单击按钮等。
3,实现用于开发图形应用程序的X11协议的低级API,提供基本的绘图能力,比如点、线、圆等。
4,实现此低级API的库(libX11、Xcb)
Wayland:
1,和X11类似,是另外一套显示服务器(称为Wayland合成器)与其客户端之间的通信协议。
2,相比X11,Wayland的安全性更高,性能应该更好,但缺点是相对不够稳定。
Gnome:
1,Linux桌面环境,在操作系统上运行的程序包,它们共享一个通用的GUI。
2,基于GTK+工具包的程序包,它本身可以基于X11 API,也可以基于Wayland API。
3,程序包里的应用程序形成一个图形环境,包括大量的应用程序,窗口管理器,配件等。
4,还有许多其他Linux桌面环境,比如基于Qt工具包的KDE是众所周知的竞争对手之一。
结论:
Gnome是基于X11或Wayland之上的,既可以是Gnome+X11,也可以是Gnome+Wayland。
参考:
https://unix.stackexchange.com/questions/345344/difference-between-xorg-and-gnome-kde-xfce
https://en.wikipedia.org/wiki/X_Window_System
https://www.secjuice.com/wayland-vs-xorg/
https://zhuanlan.zhihu.com/p/411213507
四,基于Gnome+Wayland的Ubuntu 22.04.1 LTS,如何使用远程桌面?
大多数传统vnc在Wayland的Ubuntu下无法使用:
RealVNC server: doesn’t work with Wayland and requires an account
TigerVNC: I wasn’t able to view the desktop, perhaps incompatible with Wayland?
TightVNC: doesn’t even start
Xrdp with X11 enabled: crashes because of some strange permission problem
Vino: deprecated, no Wayland support
GNOME’s built-in remote desktop server: works, but requires being enabled on a per-network basis, which makes it impractical when connecting the computer to a new network (I would need a physical monitor to enable that network). Moreover, it doesn’t work when no monitor is connected
参考:https://askubuntu.com/questions/1383435/vnc-doesnt-work-in-ubuntu-21-10
Wayland+Gnome, the only available software is gnome-remote-desktop.
所以,只能用gnome-remote-desktop?
源码:https://gitlab.gnome.org/GNOME/gnome-remote-desktop
从这里看:https://www.ctrl.blog/entry/wayland-gnome-remote-desktop.html
关键接口:org.gnome.Mutter.RemoteDesktop和org.gnome.Mutter.ScreenCast。
具体怎么干,参考这个:
https://help.ubuntu.com/stable/ubuntu-help/sharing-desktop.html
其他:基于wlroots-based Wayland compositors的VNC server。
https://github.com/any1/wayvnc
参考:
https://askubuntu.com/questions/1308623/vnc-for-remote-login-with-wayland-20-04
https://askubuntu.com/questions/1239475/which-vnc-servers-work-with-ubuntu-20-04-and-wayland
https://unix.stackexchange.com/questions/314946/wayland-and-remote-desktop
五,如何将Ubuntu 22.04.1 LTS切换回X11?
$ sudo vi /etc/gdm3/custom.conf
[daemon]
# Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false
将WaylandEnable=false前的注释符号去掉,也就是不启用Wayland。
然后重启机器或重启GDM3:
sudo systemctl restart gdm3
进入桌面后,查看就是x11了:
$ echo $XDG_SESSION_TYPE
x11
参考:
https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-20-04-desktop
六,Wayland vs X11
https://wayland.freedesktop.org/architecture.html
https://askubuntu.com/questions/11537/why-is-wayland-better
https://unix.stackexchange.com/questions/345344/difference-between-xorg-and-gnome-kde-xfce
https://unix.stackexchange.com/questions/578744/am-i-using-xorg-or-wayland
https://unix.stackexchange.com/questions/202891/how-to-know-whether-wayland-or-x11-is-being-used
https://www.51cto.com/article/650435.html?pc
https://blog.csdn.net/a8039974/article/details/122867167
关键点:
1,There are lots of differences between X and Wayland. Probably the biggest one from the graphics side is that Wayland doesn’t do any drawing.
转载请保留地址:http://www.lenky.info/archives/2022/11/3247 或 http://lenky.info/?p=3247
备注:如无特殊说明,文章内容均出自Lenky个人的真实理解而并非存心妄自揣测来故意愚人耳目。由于个人水平有限,虽力求内容正确无误,但仍然难免出错,请勿见怪,如果可以则请留言告之,并欢迎来信讨论。另外值得说明的是,Lenky的部分文章以及部分内容参考借鉴了网络上各位网友的热心分享,特别是一些带有完全参考的文章,其后附带的链接内容也许更直接、更丰富,而我只是做了一下归纳&转述,在此也一并表示感谢。关于本站的所有技术文章,欢迎转载,但请遵从CC创作共享协议,而一些私人性质较强的心情随笔,建议不要转载。
法律:根据最新颁布的《信息网络传播权保护条例》,如果您认为本文章的任何内容侵犯了您的权利,请以Email或书面等方式告知,本站将及时删除相关内容或链接。