linux Wayland display multiple-user

不问归期 提交于 2020-05-15 05:01:51

问题


I use sway compositor.

When I change user in console, I can NOT display a wayland graphic interface (It work with a X application)

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

I set it: (get from the other user)

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

In the main user:

$ 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

I do:

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

The wayland connection fail when I call:

wl_display_connect(nullptr);

Thank you


回答1:


This is simply a right problem. The path /run/user/XXX is not accessible for other user, then the other user can not access and get point on the wayland socker event of the "other" right is availlable.

The solution (bad way but fast) (replace XXX with the user ID):

On user that run sway:

chmod -R 777 /run/user/XXXX

On the second user:

export XDG_RUNTIME_DIR=/run/user/XXXX

An other way (better, but not very good too)

Set all the user in the group "users"

In the user that provided the wayland compositor edit ".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

In all other user edit ".bashrc":

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

If you want all your application start by default all backend in 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


来源:https://stackoverflow.com/questions/41736528/linux-wayland-display-multiple-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!