# balena-electronjs

> Kiosk mode for electron apps

Latest version **1.2.2** (published 2021-02-03) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install balena-electronjs
pnpm add balena-electronjs
yarn add balena-electronjs
bun add balena-electronjs
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2021-02-03 |
| First published | 2020-06-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 683.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Alexis Svinartchouk |
| Maintainers | balena.io |

## Links

- npm: https://www.npmjs.com/package/balena-electronjs
- Repository: https://github.com/balena-io-modules/balena-electronjs
- Homepage: https://github.com/balena-io-modules/balena-electronjs#readme
- Issues: https://github.com/balena-io-modules/balena-electronjs/issues
- npm.io page: https://npm.io/package/balena-electronjs

## Recent versions

- 1.2.2 (latest) — 2021-02-03
- 1.2.3-electron-11-3051371fcaa9159244e14aa51012dc080340d2eb (electron-11-3051371fcaa9159244e14aa51012dc080340d2eb) — 2021-03-04
- 1.0.2-screensaver-on-off-b32530ad497bf06b250278b1141c4bdd82dc94d0 (screensaver-on-off-b32530ad497bf06b250278b1141c4bdd82dc94d0) — 2020-10-16
- 0.0.6-dependabot-npm-and-yarn-elliptic-6-5-3-45fdbc06d13886b3963a0ac854c04149f0a56e3d (dependabot-npm-and-yarn-elliptic-6-5-3-45fdbc06d13886b3963a0ac854c04149f0a56e3d) — 2020-08-19
- 0.0.6-dependabot-npm-and-yarn-sample-app-lodash-4-17-20-ed9fcd5b13e4186a999b3040bff463b7212b2f81 (dependabot-npm-and-yarn-sample-app-lodash-4-17-20-ed9fcd5b13e4186a999b3040bff463b7212b2f81) — 2020-08-19
- 0.0.6-dependabot-npm-and-yarn-sample-app-electron-7-2-4-60d6f16f5ada5b8448e25ef52ebddd086b129d31 (dependabot-npm-and-yarn-sample-app-electron-7-2-4-60d6f16f5ada5b8448e25ef52ebddd086b129d31) — 2020-08-19
- 0.0.6-create-mounts-root-4b9f329666509a2bbb95aace3275ffecae597d17 (create-mounts-root-4b9f329666509a2bbb95aace3275ffecae597d17) — 2020-08-19
- 1.2.2-add-versionist-changelog-c361de0bb211076aa11fc0eed1a898e1e87ee1f5 — 2021-02-03
- 1.2.2-add-versionist-changelog-3f58475460678c4a9dbf799a88edc4e68c92687d — 2021-02-03
- 1.2.1 — 2021-02-01
- 1.2.1-always-show-ok-button-in-wifi-modal-ab85a54d88f35fac4e7440ca90191cbd65b57290 — 2021-02-01
- 1.2.0 — 2021-02-01
- 1.2.0-add-brightness-filter-227f061ee2bace25063f928f8cbcec4374781f8f — 2021-02-01
- 1.1.5-add-brightness-filter-7a251178b96b709ab3bf4f7dad11c90f0c62722c — 2021-01-29
- 1.1.4 — 2020-12-30
- … 59 more at https://npm.io/package/balena-electronjs/versions

## README

# balena-electron-env

This is work in progress

## What

Provides stuff that may be missing when running electron apps in kiosk mode
(with no desktop environment):
 * a wifi configuration dialog
 * a file picker
 * an on-screen keyboard (onboard)
 * a dialog for mounting / umounting removable drives

## Building

 Build and upload this project's docker images `./image-builder.sh`;

## Using

 * In your electron app project create a Dockerfile that uses this
 project: `FROM balenablocks/aarch64-balena-electron-env`,
 replace `aarch64` with the architecture you need (`aarch64`, `armv7hf` or `amd64`);
 * Put your electron app in `/usr/src/app` in this Dockerfile.

This works by running a window manager (`metacity` for now), `dbus`, an
on-screen keyboard (`onboard`) and requiring some js code before your
application.

The required js code replaces the file picker, adds buttons for opening the
additional dialogs and injects some javascript in each window to summon the
on-screen keyboard when an input is focused.

## Components

### Wifi configuration

Works by communicating with NetworkManager via DBus.

### File picker

Replaces the default electron gtk file picker, can be constrained with
`BALENAELECTRONJS_CONSTRAINT_PATH`.

### On-screen keyboard

`onboard` is summoned via the session dbus each time an input is focused.

### Mounting / umounting of removable drives

Watches and allows to mount / umount removable drives in
`BALENAELECTRONJS_MOUNTS_ROOT`.

## Environment variables:

| Name | Description | Default Value |
| ---- | ----------- | ------------- |
| `BALENAELECTRONJS_MOUNTS_ROOT` | Where the removable drives should be mounted| `/tmp/media` |
| `BALENAELECTRONJS_CONSTRAINT_PATH` | Only files in this path will be accessible through the file picker |  |
| `BALENAELECTRONJS_OVERLAY_DELAY` | Delay before showing the overlay icons | `200` |
| `BALENAELECTRONJS_REMOTE_DEBUGGING_PORT` | Enable electron remote debugging on this port |  |
| `BALENAELECTRONJS_SLEEP_BUTTON_POSITION` | Sleep button position: x,y |  |
| `BALENAELECTRONJS_WIFI_BUTTON_POSITION` | Wifi button position: x,y |  |
| `BALENAELECTRONJS_SETTINGS_BUTTON_POSITION` | Settings button position: x,y |  |
| `BALENAELECTRONJS_MOUNTS_BUTTON_POSITION` | Mounts button position: x,y |  |
| `BALENAELECTRONJS_SCREENSAVER_ON_COMMAND` | Shell command to run when the screensaver is turned on |  |
| `BALENAELECTRONJS_SCREENSAVER_OFF_COMMAND` | Shell command to run when the screensaver is turned off |  |
| `BALENAELECTRONJS_UPDATES_ONLY_DURING_SCREENSAVER` | Only allows application updates to happen while the screensaver is on if set |  |
| `BALENAELECTRONJS_SCREENSAVER_DELAY_OVERRIDE` | Overrides the screensaver delay from the settings: number in minutes or 'never' |  |
| `BALENAELECTRONJS_ZOOM_FACTOR` | Zoom factor for overlay windows size and position | `1` |
| `DBUS_SYSTEM_BUS_ADDRESS` | DBus address for communicating with NetworkManager | `unix:path=/host/run/dbus/system_bus_socket` |
| `XRANDR_ARGS` | Rotate the screen with `xrandr $XRANDR_ARGS`, example: "-o inverted -x" |  |

## Remote methods:

Call them with `electron.ipcRenderer.invoke(methodName, ...parameters)` from any renderer process.

| Name | Parameters | Description |
| ---- | ---------- | ----------- |
| `mount-drive` | `drivePath: string` | Mounts all partitions of the drive, `drivePath` is the name of the drive in `/dev/disk/by-path/` |
| `disable-screensaver` | | Disables the screensaver, does not change the `sleepDelay` setting |
| `enable-screensaver` | | Enables the screensaver, does not change the `sleepDelay` setting |


## Utilities

 * [clickclock](https://github.com/zpfvo/clicklock) is available in `/usr/bin/clicklock` and will be run when the screensaver goes on

---
_Source: https://npm.io/package/balena-electronjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
