balena-electronjs
balena-electronjs copied to clipboard
electronJS-based resin application template
This project is deprecated and replaced by balena-electron-env
Balena Electronjs
a boilerplate for developing kiosks, digital signage or other human-machine interaction projects based on ElectronJS and balena
Warning regarding armv6
This project does not currently support the armv6 architecture (ie Raspberry Pi 0 and 1) due to electron limitations. If the issue is fixed on the electron side, we will include it in this project. More on this here
Getting started
- Sign up on balena
- go through the getting started guide and create a new application
- install the balena-cli on your computer
- clone or download this repository to your local workspace
balena push <applicationName>- see the magic happening, your device is getting updated Over-The-Air!
Configure via environment variables
| Variable Name | Value | Description | Device-specific |
|---|---|---|---|
RESIN_HOST_CONFIG_gpu_mem |
a value from 64 to 396 |
the amount of RAM dedicated to the GPU | Raspberry Pi (all revs) |
Apply the above settings in the "Fleet Configuration" panel (if applying it for the all devices withing your application), or "Device Configuration" panel (if applying it for a single device).
WHY THIS TEMPLATE
Achieving kinda-smooth desktop application display on devices like the raspberrypi is hard. This project aims to provide a quickstart template.
URL LAUNCHER config via ENV VARS
!!! Please note that since 0.1.0 the bool-based env vars dropped true / false strings in favour of 0 / 1 ones. !!!
simply set these environment varables in your app via "Environment Variables" panel in the balena dashboard to configure the behaviour of your devices.
Please note that the bool type definition in the table is meant to accept to either 0 or 1 values.
URL_LAUNCHER_URLstring - the URL to be loaded. usefile:////usr/src/app/data/index.htmlto load a local electronJS (or any website) app - defaults tofile:////usr/src/app/data/index.htmlURL_LAUNCHER_NODEbool (converted from string) - whether or not enable nodejs - defaults to0URL_LAUNCHER_KIOSKbool (converted from string) - whether or not enter KIOSK mode - defaults to1URL_LAUNCHER_TITLEstring - the title of the window. Seen only withURL_LAUNCHER_FRAME=true- defaults toRESIN.IOURL_LAUNCHER_FRAMEbool (converted from string) - set to "true" to display the window frame. Seen only withURL_LAUNCHER_KIOSK=false- defaults to0URL_LAUNCHER_CONSOLEbool (converted from string) - set to "true" to display the debug console - defaults to0URL_LAUNCHER_WIDTHint (converted from string) - - defaults to1920URL_LAUNCHER_HEIGHTint (converted from string) - - defaults to1080URL_LAUNCHER_TOUCHbool (converted from string) - enables touch events if your device supports them - defaults to0URL_LAUNCHER_TOUCH_SIMULATEbool (converted from string) - simulates touch events - might be useful for touchscreen with partial driver support - be aware this could be a performance hog - defaults to0URL_LAUNCHER_ZOOMfloat (converted from string) - The default zoom factor of the page, 3.0 represents 300% - defaults to1.0URL_LAUNCHER_OVERLAY_SCROLLBARSbool (converted from string) - enables overlay scrollbars - defaults to0TFTbool (converted from string) - sets the target display to TFT screen like the piTFT but still requires you to set the proper device tree overlay configuration for it - defaults to0TFT_ROTATEint (converted from string) - accepted values: 0,90,180,270 - defaults to0ELECTRON_ENABLE_HW_ACCELERATIONbool (converted from string) - enable hardware acceleration - defaults to0ELECTRON_BALENA_UPDATE_LOCKbool (converted from string) - Enable supervisor update locking (see Update Locking)ELECTRON_APP_DATA_DIRstring - Override theappDatadirectory (see Electron API Documentation: app)ELECTRON_USER_DATA_DIRstring - Override theuserDatadirectory (see Electron API Documentation: app)
Update Locking
NOTE: Take care to only listen for a response once, and avoid sending multiple requests before the response arrived.
const {ipcRenderer} = require('electron')
Acquiring the Lock
// Listen for a response
ipcRenderer.once('balena-update-lock', (event, error) => {
if (error) { ... }
})
// Send the 'lock' command to acquire the lock
ipcRenderer.send('balena-update-lock', 'lock')
Releasing the Lock
// Listen for a response
ipcRenderer.once('balena-update-lock', (event, error) => {
if (error) { ... }
})
// Send the 'unlock' command to release the lock
ipcRenderer.send('balena-update-lock', 'unlock')
Checking the Lock
// Listen for a response
ipcRenderer.once('balena-update-lock', (event, error, isLocked) => {
console.log('Locked:', error || isLocked)
})
// Send the 'check' command to check on the state of the lock
ipcRenderer.send('balena-update-lock', 'check')