X11-based Kiosk Snap without WAYLAND_SOCKET_DIR in snapcraft.yaml


#1

Hello,

I am trying to make a X11-based Kiosk Snap for evince, following the
procedure provided in the tutorial:

Below is a portion of my snapcraft.yaml file:

name: evince
version: 'gnome-3.28'
summary: a free, open source, and cross-platform document viewer.
description: |
  Evince is a document viewer for multiple document formats.
  It is specifically designed to support the following file formats:
  PDF, Postscript, djvu, tiff, dvi, XPS, SyncTex support with gedit,
  comics books (cbr,cbz,cb7 and cbt).

grade: devel
confinement: devmode
base: core18

apps:
  evince:
    command: xwayland-kiosk-launch $SNAP/usr/bin/evince
    environment:
      XWAYLAND_FULLSCREEN_WINDOW_HINT: title="evince"
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
      XDG_RUNTIME_DIR: $SNAP_DATA/wayland
      LIBGL_DRIVERS_PATH: $SNAP_DATA/usr/lib/arm-linux-gnueabihf/dri
      WAYLAND_SOCKET_DIR: $SNAP_DATA/wayland

    plugs: [opengl, home, wayland, x11-plug]
    slots:
      - x11

parts:
  evince:
    source: https://gitlab.gnome.org/GNOME/evince.git
    source-tag: gnome-3-28
    plugin: autotools
    configflags:
      - --disable-nautilus
    after: [ xwayland-kiosk-helper ]
:
:
:

I made the snap on Ubuntu 18.04 and installed it on an Ubuntu Core VM:

mravindrarao@localhost:~$ snap install ./evince_gnome-3.28_amd64.snap --dangerous --devmode
evince gnome-3.28 installed
mravindrarao@localhost:~$ evince ./Sample.pdf
mkdir: cannot create directory ‘/var/snap/evince/x1/wayland’: Permission denied
mravindrarao@localhost:~$ sudo chmod a+wx /var/snap/evince/x1/
mravindrarao@localhost:~$ evince ./Sample.pdf
#################################################################################
NOTICE: the ‘wayland-socket-dir’ interface has been removed!
Remove reference to it and WAYLAND_SOCKET_DIR from your snapcraft.yaml.

Consult the instructions in


#################################################################################
mravindrarao@localhost:~$ snap remove evince
evince removed
mravindrarao@localhost:~$ rm ./evince_gnome-3.28_amd64.snap
mravindrarao@localhost:~$ echo $WAYLAND_DISPLAY

mravindrarao@localhost:~$

I removed the following line from snapcraft.yaml:
WAYLAND_SOCKET_DIR: $SNAP_DATA/wayland
and then re-made the snap.

mravindrarao@localhost:~$ snap remove evince
evince removed
mravindrarao@localhost:~$ rm ./evince_gnome-3.28_amd64.snap
mravindrarao@localhost:~$ echo $WAYLAND_DISPLAY

mravindrarao@localhost:~$ snap install ./evince_gnome-3.28_amd64.snap --dangerous --devmode
evince gnome-3.28 installed
mravindrarao@localhost:~$ evince ./Sample.pdf
mkdir: cannot create directory ‘/var/snap/evince/x1/wayland’: Permission denied
mravindrarao@localhost:~$ sudo chmod a+wx /var/snap/evince/x1/
mravindrarao@localhost:~$ evince ./Sample.pdf
Error: Unable to find a valid Wayland socket in /var/snap/evince/x1
Is a Wayland server running?
You could try running as root
mravindrarao@localhost:~$ sudo su
root@localhost:/home/mravindrarao# evince /home/mravindrarao/Sample.pdf
Error: Unable to find a valid Wayland socket in /var/snap/evince/x1
Is a Wayland server running?
root@localhost:/home/mravindrarao# snap list
Name Version Rev Tracking Publisher Notes
classic 18.04-0.1 37 18/edge canonical✓ devmode
core 16-2.38.1 6818 stable canonical✓ core
core18 20190409 941 stable canonical✓ base
evince gnome-3.28 x1 - - devmode
gnome-3-28-1804 3.28.0-10-gaa70833.aa70833 40 stable canonical✓ -
gtk-common-themes 0.1-16-g2287c87 1198 stable canonical✓ -
mir-kiosk 1.1.2-snap83 1383 stable canonical✓ -
pc 18-1 31 18 canonical✓ gadget
pc-kernel 4.15.0-48.51 202 18 canonical✓ kernel
snapd 2.38.1 3028 stable canonical✓ snapd
root@localhost:/home/mravindrarao# exit
exit
mravindrarao@localhost:~$ ls -l /var/snap/evince/x1/
total 4
drwx------ 2 mravindrarao mravindrarao 4096 May 2 09:46 wayland
mravindrarao@localhost:~$ ls -l /var/snap/evince/x1/wayland/
total 0
mravindrarao@localhost:~$ snap run --shell evince
mravindrarao@localhost:/home/mravindrarao$ ls -hl $XDG_RUNTIME_DIR
total 0
mravindrarao@localhost:/home/mravindrarao$ exit
exit
mravindrarao@localhost:~$

Why do I need to change the permissions for /var/snap/evince/x1/ directory?
How do I specify/get a Wayland socket so that the snap can run?

Thanks,
Ravindra


#2

Hi @Ravindra,

Can you tell why you’re looking to make a X11-based snap? Current GNOME apps should happily run under Wayland natively?

Did you connect your evince snap to mir-kiosk:wayland?

See this portion of the above tutorial.

Hope this helps!


#3

Hi @Saviq,

Thanks for your reply.

I have modified my yaml file to directly run under Wayland instead of trying to make it a X11-based snap, as below:

name: evince
version: ‘gnome-3.28’
summary: a free, open source, and cross-platform document viewer.
description: |
Evince is a document viewer for multiple document formats.

grade: devel
confinement: devmode
base: core18

apps:
evince:
command: |
bash -c “mkdir -p $XDG_RUNTIME_DIR
if [ ! -L $XDG_RUNTIME_DIR/wayland-0 ]; then
ln -s $XDG_RUNTIME_DIR/…/wayland-0 $XDG_RUNTIME_DIR/
fi
$SNAP/bin/evince --fullscreen”
environment:
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
LIBGL_DRIVERS_PATH: $SNAP_DATA/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri

plugs: [opengl, home, wayland]

parts:
evince:
source: https://gitlab.gnome.org/GNOME/evince.git
source-tag: gnome-3-28
plugin: autotools
:
:

I created the snap and installed it on ubuntu core:

$ snap list
Name               Version                     Rev   Tracking  Publisher   Notes
alsa-utils         1.1.2-5                     68    stable    canonical✓  -
bluez              5.47-3                      166   stable    canonical✓  -
classic            16.04                       26    beta      canonical✓  devmode
core               16-2.38.1                   6818  stable    canonical✓  core
core18             20190409                    941   stable    canonical✓  base
evince             gnome-3.28                  x1    -         -           devmode
gnome-3-28-1804    3.28.0-10-gaa70833.aa70833  40    stable    canonical✓  -
gtk-common-themes  0.1-16-g2287c87             1198  stable    canonical✓  -
mir-kiosk          1.1.2-snap83                1383  stable    canonical✓  -
pc                 18-1                        31    18        canonical✓  gadget
pc-kernel          4.15.0-48.51                202   18        canonical✓  kernel
pulseaudio         8.0-3                       9     stable    canonical✓  -
snapd              2.38.1                      3028  stable    canonical✓  snapd
sysconfs-nuc7      1                           x1    -         -           -
$

When I run it, I get the following error:

$ evince Sample.pdf 
Unable to init server: Could not connect: Connection refused
Cannot parse arguments: Cannot open display: 
$

Please let me know if I need to do something different in the snapcraft.yaml file.

Regards,
Ravindra


#4

Hi @Ravindra did you connect the interfaces of the app?

What does snap interfaces evince say?


#5

Hi @Saviq,

Below is the output of the snap interfaces evince command:

$ snap interfaces evince
Slot               Plug
mir-kiosk:wayland  evince
:home              evince
:opengl            evince
$ 

Regards,
Ravindra