linux Wayland 显示多用户

linux Wayland display multiple-user

我使用 sway 合成器。

当我在控制台中更改用户时,我无法显示 wayland 图形界面(它适用于 X 应用程序)

$ su - otherUser
$ ./myApplicationWayland
error: XDG_RUNTIME_DIR not set in the environment

我设置的:(从其他用户那里获取)

$ export XDG_RUNTIME_DIR=/run/user/1000
$ export WAYLAND_DISPLAY=wayland-0
$ ./myApplicationWayland
Assert ... It cannot create the "display"

在主用户中:

$ ls -l /run/user/1000
total 0
srw-rw-rw- 1 edupin edupin   0 Jan 23 08:14 bus
drwx------ 2 edupin edupin  60 Jan 26 13:25 dconf
dr-x------ 2 edupin edupin   0 Jan 23 08:15 gvfs
drwx------ 2 edupin edupin  80 Jan 26 14:31 pulse
srwxr-xr-x 1 edupin edupin   0 Jan 23 08:14 sway-ipc.1000.645.sock
drwxr-xr-x 3 edupin edupin 100 Jan 23 08:14 systemd
srwxr-xr-x 1 edupin edupin   0 Jan 23 08:14 wayland-0
-rw-r----- 1 edupin edupin   0 Jan 23 08:14 wayland-0.lock

我愿意:

chmod -R g+rwx /run/user/1000

当我调用时,wayland 连接失败:

wl_display_connect(nullptr);

谢谢

这简直就是一道对题。路径/run/user/XXX其他用户无法访问,则其他用户无法访问并获取"other"权限的wayland socker事件上的点。

解决方案(不好但很快)(用用户 ID 替换 XXX):

在 运行 影响的用户上:

chmod -R 777 /run/user/XXXX

关于第二个用户:

export XDG_RUNTIME_DIR=/run/user/XXXX

另一种方式(更好,但也不是很好)

设置组内所有用户"users"

在提供 wayland 合成器的用户中编辑“.bashrc”:

# specify a path to create the wayland IO and force it to be readable for each user in group "users"
export XDG_RUNTIME_DIR=/tmp/wayland
export WAYLAND_DISPLAY=wayland-0
# create default directory
mkdir -p $XDG_RUNTIME_DIR
chgrp users $XDG_RUNTIME_DIR
chmod g+rwx $XDG_RUNTIME_DIR
# at the first run of the terminal ==> the other user have acces on it (many time use terminal to change user)
chgrp users $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY
chmod g+rwx $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY

在所有其他用户中编辑“.bashrc”:

export XDG_RUNTIME_DIR=/tmp/wayland
export WAYLAND_DISPLAY=wayland-0

如果您希望所有应用程序默认启动所有后端在 wayland 中:

# force all generic backend to use wayland backend
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland-egl
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
export EWOL_BACKEND=wayland