I just figured out how to run Wayland applications from inside a Jail without using Xwayland
The reason i started looking into this is because Davinci Resolve 19 beta 1 supports running as a native wayland application
instead of running as an X11 app
Also there is a nasty bug with wlroots that cause X11 applications to crash the compositor when you open an X11 application from a jail
after you login back in and relaunch the X11 application from the jail it works, but its a pain
Running Wayland applications from inside the Jail doesnt crash the compositor and works perfectly
and the application launched from the Jail behaves as a native application on the host and even picks up the system theme
here a screenshot of the alacritty terminal on the right of the screenshot launched from an Ubuntu Jail
from the alacritty terminal on the left, notice how the jailed alacritty title bar is using the theme from the host
im using labwc as my wayland compositor
Here's how to run Wayland applications from a Jail
we mount the XDG_RUNTIME_DIR directory from the host to the Jail
this is needed because thats the location of the wayland display
the location of the XDG_RUNTIME_DIR on my system is /var/run/user/1001
in the jails fstab we mount the hosts XDG_RUNTIME_DIR to /run/user/1001
because /var/run is actually a symlink to /run
jail fstab
in the ~/.zshenv shell config in the Jail we dont set the DISPLAY=:0
because thats for X11
instead we set the XDG_RUNTIME_DIR, WAYLAND_DISPLAY, QT_QPA_PLATFORM and GDK_BACKEND
as shown below
heres the XDG_RUNTIME_DIR on the Freebsd host
heres the XDG_RUNTIME_DIR on the Ubuntu Jail
notice wayland-0 which is the wayland display socket
The reason i started looking into this is because Davinci Resolve 19 beta 1 supports running as a native wayland application
instead of running as an X11 app
Also there is a nasty bug with wlroots that cause X11 applications to crash the compositor when you open an X11 application from a jail
after you login back in and relaunch the X11 application from the jail it works, but its a pain
Running Wayland applications from inside the Jail doesnt crash the compositor and works perfectly
and the application launched from the Jail behaves as a native application on the host and even picks up the system theme
here a screenshot of the alacritty terminal on the right of the screenshot launched from an Ubuntu Jail
from the alacritty terminal on the left, notice how the jailed alacritty title bar is using the theme from the host
im using labwc as my wayland compositor
Here's how to run Wayland applications from a Jail
we mount the XDG_RUNTIME_DIR directory from the host to the Jail
this is needed because thats the location of the wayland display
the location of the XDG_RUNTIME_DIR on my system is /var/run/user/1001
in the jails fstab we mount the hosts XDG_RUNTIME_DIR to /run/user/1001
because /var/run is actually a symlink to /run
jail fstab
Code:
devfs /usr/local/jails/linux/ubuntu/dev devfs rw 0 0
tmpfs /usr/local/jails/linux/ubuntu/dev/shm tmpfs rw,size=1g,mode=1777 0 0
fdescfs /usr/local/jails/linux/ubuntu/dev/fd fdescfs rw,linrdlnk 0 0
linprocfs /usr/local/jails/linux/ubuntu/proc linprocfs rw 0 0
linsysfs /usr/local/jails/linux/ubuntu/sys linsysfs rw 0 0
/tmp /usr/local/jails/linux/ubuntu/tmp nullfs rw 0 0
/home /usr/local/jails/linux/ubuntu/home nullfs rw 0 0
/var/run/user/1001 /usr/local/jails/linux/ubuntu/run/user/1001 nullfs rw 0 0
in the ~/.zshenv shell config in the Jail we dont set the DISPLAY=:0
because thats for X11
instead we set the XDG_RUNTIME_DIR, WAYLAND_DISPLAY, QT_QPA_PLATFORM and GDK_BACKEND
as shown below
Code:
export XDG_RUNTIME_DIR="/var/run/user/`id -u`"
export WAYLAND_DISPLAY=wayland-0
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_QPA_PLATFORM="wayland"
export GDK_BACKEND="wayland"
heres the XDG_RUNTIME_DIR on the Freebsd host
Code:
Yes Master ? ls -l /var/run/user/1001
total 7
srwxr-xr-x 1 djwilcox wheel 0 17 Apr 16:20 Alacritty-wayland-0-84647.sock
drwx------ 2 djwilcox wheel 3 17 Apr 16:21 at-spi
drwx------ 3 djwilcox wheel 3 1 Dec 15:04 dbus-1
drwx------ 2 djwilcox wheel 3 17 Apr 14:36 dconf
drwx------ 2 djwilcox wheel 2 14 Mar 13:23 doc
drwx------ 2 djwilcox wheel 2 16 Apr 20:09 dwlb
drwx------ 2 djwilcox wheel 3 17 Apr 16:21 emacs
drwx------ 3 djwilcox wheel 3 27 Dec 00:17 gnupg
drwx------ 2 djwilcox djwilcox 2 16 Apr 20:06 pulse
drwx------ 4 djwilcox wheel 4 16 Apr 12:33 speech-dispatcher
-rw------- 1 djwilcox wheel 0 17 Apr 14:37 tofi.lock
srwxr-xr-x 1 djwilcox wheel 0 17 Apr 16:20 wayland-0
-rw-r----- 1 djwilcox wheel 0 17 Apr 14:36 wayland-0.lock
heres the XDG_RUNTIME_DIR on the Ubuntu Jail
Code:
srwxr-xr-x 1 djwilcox root 0 Apr 17 16:20 Alacritty-wayland-0-84647.sock
drwx------ 2 djwilcox root 3 Apr 17 16:21 at-spi
drwx------ 3 djwilcox root 3 Dec 1 15:04 dbus-1
drwx------ 2 djwilcox root 3 Apr 17 14:36 dconf
drwx------ 2 djwilcox root 2 Mar 14 13:23 doc
drwx------ 2 djwilcox root 2 Apr 16 20:09 dwlb
drwx------ 2 djwilcox root 3 Apr 17 16:21 emacs
drwx------ 3 djwilcox root 3 Dec 27 00:17 gnupg
drwx------ 2 djwilcox djwilcox 2 Apr 16 20:06 pulse
drwx------ 4 djwilcox root 4 Apr 16 12:33 speech-dispatcher
-rw------- 1 djwilcox root 0 Apr 17 14:37 tofi.lock
srwxr-xr-x 1 djwilcox root 0 Apr 17 16:20 wayland-0
-rw-r----- 1 djwilcox root 0 Apr 17 14:36 wayland-0.lock
notice wayland-0 which is the wayland display socket