Other Eureka running Wayland applications from inside a Jail

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

wayland.png


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
 
Downloading Davinci Resolve 19 beta 1 which can run as a Wayland application

im going to install it in an Ubuntu Mantic jail

as i mentioned in a previous post the Freebsd 14 p6 quarterly Nvidia driver 550.54.14
matches the exact version on Ubuntu 23.10

which can be installed on Ubuntu with

Code:
sudo apt install nvidia-driver-550-server

That means you can use the Nvidia driver from the Ubuntu repo in a jail
and it will match the version on the Freebsd host

rather than having to download and manually install the Nvidia driver

I should also mention you dont need Wayland installed in the jail
because the application is displayed using the Wayland socket from the mounted XDG_RUNTIME_DIR in the jails fstab

jailed applications run using wayland open instantly and run silky smooth

i keep opening alacritty run as a wayland application in the jail and minimizing and maximizing it
and moving it between monitors

its bonkers fast and smoother than Barry White
 
Back
Top