Skip to content

Instantly share code, notes, and snippets.

@realStandal
Last active January 28, 2021 21:08
Show Gist options
  • Save realStandal/bf9a24dae27b2f83fd57934232dd1673 to your computer and use it in GitHub Desktop.
Save realStandal/bf9a24dae27b2f83fd57934232dd1673 to your computer and use it in GitHub Desktop.
Kiosked Electron running on Ubuntu Core powered by a Raspberry Pi 3 Model B for
# Taken from https://forum.snapcraft.io/t/greatly-simplified-electron-kiosk-snaps/21303
# Modified to work with https://launchpad.net and to explicitly build for `arm64` architectures (Pi-3-B)
name: electron-hello-world-kiosk
version: '0.1'
summary: Hello World Electron app for a Kiosk
description: |
Simple Hello World Electron app as an example of a HTML5 Kiosk
base: core18
confinement: strict
grade: devel
compression: lzo
architectures:
- build-on: arm64
run-on: arm64
apps:
electron-hello-world-kiosk:
daemon: simple
extensions: [ gnome-3-28 ]
restart-condition: always
command: snap/command-chain/desktop-launch xwayland-kiosk-launch $SNAP/electron-helloworld/electron-quick-start --no-sandbox
plugs:
- browser-support
- network
- network-bind
- opengl
- pulseaudio
- wayland
layout:
/usr/share/fonts:
bind: $SNAP/usr/share/fonts
environment:
XWAYLAND_FULLSCREEN_WINDOW_HINT: window_role="browser-window"
parts:
electron-helloworld:
plugin: nil
source: https://github.com/electron/electron-quick-start.git
override-build: |
# Configuration to let `snapcraft remote-build` process work using Launchpad.net
if [ -n "$http_proxy" ]; then
export ELECTRON_GET_USE_PROXY=1
export GLOBAL_AGENT_HTTP_PROXY="${http_proxy}"
export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy}"
fi &&
# Configuration for non-elevated build permissions
npm config set scripts-prepend-node-path true
npm config set unsafe-perm true
npm install electron-packager
./node_modules/.bin/electron-packager . --overwrite \
--platform=linux --output=release-build --prune=true
cp -v -R ./electron-quick-start-linux-* $SNAPCRAFT_PART_INSTALL/electron-helloworld
stage-packages:
- libnspr4
- libnss3
build-snaps:
- node/14/stable
xwayland-kiosk-helper:
plugin: cmake
source: https://github.com/MirServer/xwayland-kiosk-helper.git
build-packages: [ build-essential ]
stage-packages: [ xwayland, i3, libegl1-mesa, libgl1-mesa-glx ]
@realStandal
Copy link
Author

realStandal commented Jan 28, 2021

This has been tested on a Raspberry Pi 3 Model B. I'm sure other boards, assuming they run a arm64 chip, will work with no modification.

To-Use:

Assuming you've installed Ubuntu Core on your Raspberry Pi. The Raspberry Pi Imager provides it for easy-setup.

Your device will be the Raspberry Pi running Ubuntu Core. Your machine will be what is used to build the Snap.

  1. On your device, you'll need to install mir-kiosk by running snap install mir-kiosk.
  2. Build the Snap, either on your machine or using Launchpad.
    • You'll want to build on a machine which uses the same chip (arm64) as your device. I'm sure this can be accomplished using the Snapcraft's --destructive-mode option, I have yet to try it using this method.
  3. The successfully built Snap can be uploaded to your device, an ambiguous process. The following would upload to a device's default home-directory scp ./path/to/electron-*.snap device-user@device-ip:~.
  4. Once uploaded, use ssh to access your device remotely.
  5. Installing the Snap is as easy as snap install --dangerous ./path/to/electron-*.snap

(Assuming you used the default electron-quick-start repository to build from) When connected to a display, you should see the "Hello World!" greeting of your Electron app. Quitting the application, by any means (forcefully, closing the window, restarting the device) will cause the device to reboot directly to this application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment