HOWTO: Run your kiosk snap on your desktop

When developing things it is nice to have all your familiar development tools to hand. And the same is true when snapping applications to run on mir-kiosk.

Instead of running everything on an Ubuntu Core device and having to use ssh only to miss some key development tool; Or having to switch to another VT on your development machine and have processes you’re trying to use suspend; Or trying to find another laptop to ssh into your own machine… wouldn’t it be nice to simply have mir-kiosk running on a window on your desktop?

The method to do this depends upon the desktop you are using.

Method 1: On an X11 based desktop

First you need to install mir-kiosk in devmode:

snap install --devmode mir-kiosk

And then run mir-kiosk as root (but letting it see your $DISPLAY):

sudo mir-kiosk

That gets you a “Mir-on-X” window with the kiosk server running inside it.

(You can skip the next section.)

Method 2: On a Wayland desktop

On GNOME Wayland (and maybe others) processes running as other users (including root) cannot connect to the desktop. In general, that is a good idea, but sometimes, like now, it is a problem. We can work around this feature by running a miral-system-compositor on the desktop and using that to host the mir-kiosk compositor.

First install miral-system-compositor and mir-kiosk (in devmode):

sudo apt install mir-demos
snap install --devmode mir-kiosk

Now start miral-system-compositor and provide a Wayland socket for mir-kiosk to use:

WAYLAND_DISPLAY=wayland-1 miral-system-compositor&
sudo mkdir -p /run/user/0 && sudo ln -sf /run/user/1000/wayland-1 /run/user/0

You can now run mir-kiosk as root, telling it to use the socket provided by miral-system-compositor above:

env -u WAYLAND_DISPLAY sudo mir-kiosk --wayland-host wayland-1

That gets you a “Mir-on-X” window with the kiosk server running inside it.

Running your snap

Once you have a “Mir-on-X” window with the kiosk server running inside it you can install your snap, connect it to the “wayland” interface and restart it. I use mir-kiosk-apps here as an example, but you can just use the snap you’re working on once you’ve built it locally:

snap install --edge mir-kiosk-apps
snap connect mir-kiosk-apps:wayland
sudo snap set mir-kiosk-apps daemon=true
sudo snap restart mir-kiosk-apps

Note: Not all snaps need the sudo snap set mir-kiosk-apps daemon=true command, but snaps packaged using mir-kiosk-snap-launch (and run-daemon) default to not running the daemon when not on Ubuntu Core.

4 Likes

If you’re running a Wayland desktop, then the default configuration of Xwayland prevents root from connecting.

It is possible workaround to some extent with:

Xwayland -ac :1&
sudo DISPLAY=:1 mir-kiosk

But the Xwayland root window is somewhat annoying.

1 Like

There is an alternative to using --devmode: Edit the apparmor profile directly to add a couple of permissions:

sudoedit /var/lib/snapd/apparmor/profiles/snap.mir-kiosk.mir-kiosk

Just before the closing “}”, add the following lines:

# hacks to allow running as root on desktop
capability dac_read_search,
/run/user/[0-9]*/gdm/Xauthority r,

Then reload:

sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.mir-kiosk.mir-kiosk
1 Like

With the release of Mir 1.6 there’s another workaround for the inability for root to connect to the desktop: run a miral-system-compositor using X11 and use that to host the mir-kiosk compositor:

sudo apt install mir-demos
WAYLAND_DISPLAY=wayland-1 miral-system-compositor&
sudo mkdir -p /run/user/0 && sudo ln -sf /run/user/1000/wayland-1 /run/user/0
env -u WAYLAND_DISPLAY sudo mir-kiosk --wayland-host wayland-1

This has the advantage that the mir-kiosk window behaves normally on the desktop.

Note: Don’t think too hard about what this is doing, it sounds mad: a Mir compositor (mir-kiosk) runs on a second Mir compositor (mir-system-compositor) using Wayland; the latter runs on Xwayland using X11; and, Xwayland runs on GNOME using Wayland.

2 posts were split to a new topic: Making a kiosk question

Hi, Alan

I use the method 1 to test my electron desktop application. All step is ok and thank you your this post. I just want to know how to make mir window full screen?

“Mir-on-X” is meant for testing within a desktop environment. So far, nobody has thought it important to spend time making “fullscreen” work. You can size the window, or request multiple windows:

mir-kiosk --x11-output 600x400:1200x500

2 posts were split to a new topic: Running a kiosk on Ubuntu Classic

5 posts were merged into an existing topic: Running a kiosk on Ubuntu Classic

I’m running into trouble with this…
I’ve got a computer running Ubuntu Desktop 18.04.3 LTS. I am using Method 1 because I assume 18.04.3 is X11, because they switched back to Xorg from Wayland… right?

Anyways, I run the following:

snap install --devmode mir-kiosk
sudo mir-kiosk

And get the orange splash in a “Mir on X” labeled window… I then run:

snap install --edge mir-kiosk-apps
snap connect mir-kiosk-apps:wayland   #this doesn't say anything, but doesn't give errors either.
sudo snap restart mir-kiosk-apps

No errors, but the “Mir on X” window is still black. I can see my cursor move around (same as before), but that’s it.

sudo snap logs -n 50 mir-kiosk
systemd[1]: Started Service for snap application mir-kiosk.daemon

I will post error logs for mir-kiosk-apps next…

2020-01-14T18:27:31Z mir-kiosk-apps.daemon[19920]: + grep -q snap_core= /proc/cmdline
2020-01-14T18:27:31Z mir-kiosk-apps.daemon[19920]: + snapctl get daemon
2020-01-14T18:27:31Z mir-kiosk-apps.daemon[19920]: + [ false = true ]
2020-01-14T18:27:31Z mir-kiosk-apps.daemon[19920]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T18:27:31Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T18:27:31Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T18:52:30Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T18:52:30Z mir-kiosk-apps.daemon[22358]: + grep -q snap_core= /proc/cmdline
2020-01-14T18:52:30Z mir-kiosk-apps.daemon[22358]: + snapctl get daemon
2020-01-14T18:52:30Z mir-kiosk-apps.daemon[22358]: + [ false = true ]
2020-01-14T18:52:30Z mir-kiosk-apps.daemon[22358]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T18:52:30Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T18:52:30Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T18:58:43Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T18:58:43Z mir-kiosk-apps.daemon[23282]: + grep -q snap_core= /proc/cmdline
2020-01-14T18:58:43Z mir-kiosk-apps.daemon[23282]: + snapctl get daemon
2020-01-14T18:58:43Z mir-kiosk-apps.daemon[23282]: + [ false = true ]
2020-01-14T18:58:43Z mir-kiosk-apps.daemon[23282]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T18:58:43Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T18:58:43Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:06Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30003]: + grep -q snap_core= /proc/cmdline
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30003]: + snapctl get daemon
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30003]: + [ false = true ]
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30003]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30003]: error: error running snapctl: snap "mir-kiosk-apps" has "install-snap" change in progress
2020-01-14T19:52:06Z systemd[1]: snap.mir-kiosk-apps.daemon.service: Main process exited, code=exited, status=1/FAILURE
2020-01-14T19:52:06Z systemd[1]: snap.mir-kiosk-apps.daemon.service: Failed with result 'exit-code'.
2020-01-14T19:52:06Z systemd[1]: snap.mir-kiosk-apps.daemon.service: Service hold-off time over, scheduling restart.
2020-01-14T19:52:06Z systemd[1]: snap.mir-kiosk-apps.daemon.service: Scheduled restart job, restart counter is at 1.
2020-01-14T19:52:06Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:06Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30124]: + grep -q snap_core= /proc/cmdline
2020-01-14T19:52:06Z mir-kiosk-apps.daemon[30124]: + snapctl get daemon
2020-01-14T19:52:06Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T19:52:06Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:06Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:52:07Z mir-kiosk-apps.daemon[30183]: + grep -q snap_core= /proc/cmdline
2020-01-14T19:52:07Z mir-kiosk-apps.daemon[30183]: + snapctl get daemon
2020-01-14T19:52:07Z mir-kiosk-apps.daemon[30183]: + [ false = true ]
2020-01-14T19:52:07Z mir-kiosk-apps.daemon[30183]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T19:52:07Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T19:52:07Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:53:01Z systemd[1]: Started Service for snap application mir-kiosk-apps.daemon.
2020-01-14T19:53:01Z mir-kiosk-apps.daemon[30409]: + grep -q snap_core= /proc/cmdline
2020-01-14T19:53:01Z mir-kiosk-apps.daemon[30409]: + snapctl get daemon
2020-01-14T19:53:01Z mir-kiosk-apps.daemon[30409]: + [ false = true ]
2020-01-14T19:53:01Z mir-kiosk-apps.daemon[30409]: + snapctl stop mir-kiosk-apps.daemon
2020-01-14T19:53:01Z systemd[1]: Stopping Service for snap application mir-kiosk-apps.daemon...
2020-01-14T19:53:01Z systemd[1]: Stopped Service for snap application mir-kiosk-apps.daemon.

Any ideas? Thanks for the help.

Thanks for reminding me. Recent changes mean that you need:

sudo snap set mir-kiosk-apps daemon=true

I’ll update the main article.