From 49a9706158335360d62479524afd4fedf543eec5 Mon Sep 17 00:00:00 2001 From: curcuz Date: Fri, 2 Sep 2016 23:32:31 +0200 Subject: [PATCH 01/12] move target files to a dedicated folder --- app/bower.json | 25 +++++++++++++++ app/{ => data}/index.html | 0 app/main.js | 66 +++++++++++++++++++++++++++++++++++++++ app/package.json | 34 ++++++++++++++++++++ app/start.sh | 11 +++++++ 5 files changed, 136 insertions(+) create mode 100644 app/bower.json rename app/{ => data}/index.html (100%) create mode 100644 app/main.js create mode 100644 app/package.json create mode 100644 app/start.sh diff --git a/app/bower.json b/app/bower.json new file mode 100644 index 0000000..9734157 --- /dev/null +++ b/app/bower.json @@ -0,0 +1,25 @@ +{ + "name": "resin-electronjs", + "description": "electronJS-based rpi2 resin application", + "main": "main.js", + "authors": [ + "Carlo Maria Curinga" + ], + "license": "Apache-2.0", + "keywords": [ + "resin", + "io", + "electron", + "js" + ], + "homepage": "https://github.com/resin-io/resin-electronjs", + "moduleType": [], + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/app/index.html b/app/data/index.html similarity index 100% rename from app/index.html rename to app/data/index.html diff --git a/app/main.js b/app/main.js new file mode 100644 index 0000000..7921f29 --- /dev/null +++ b/app/main.js @@ -0,0 +1,66 @@ +{ + 'use strict'; + + const electron = require('electron'); + const app = electron.app; + const BrowserWindow = electron.BrowserWindow; + + // simple parameters initialization + let electronConfig = { + "URL_LAUNCHER_TOUCH": (process.env.URL_LAUNCHER_TOUCH == null) ? 0 : process.env.URL_LAUNCHER_TOUCH, + "URL_LAUNCHER_TOUCH_SIMULATE": (process.env.URL_LAUNCHER_TOUCH_SIMULATE == null) ? 0 : process.env.URL_LAUNCHER_TOUCH_SIMULATE, + "URL_LAUNCHER_FRAME": (process.env.URL_LAUNCHER_FRAME == null) ? 0 : process.env.URL_LAUNCHER_FRAME, + "URL_LAUNCHER_KIOSK": (process.env.URL_LAUNCHER_KIOSK == null) ? 1 : process.env.URL_LAUNCHER_KIOSK, + "URL_LAUNCHER_NODE": (process.env.URL_LAUNCHER_NODE == null) ? 0 : process.env.URL_LAUNCHER_NODE, + "URL_LAUNCHER_WIDTH": (process.env.URL_LAUNCHER_WIDTH == null) ? 1920 : process.env.URL_LAUNCHER_WIDTH, + "URL_LAUNCHER_HEIGHT": (process.env.URL_LAUNCHER_HEIGHT == null) ? 1080 : process.env.URL_LAUNCHER_HEIGHT, + "URL_LAUNCHER_TITLE": (process.env.URL_LAUNCHER_TITLE == null) ? "RESIN.IO" : process.env.URL_LAUNCHER_TITLE, + "URL_LAUNCHER_CONSOLE": (process.env.URL_LAUNCHER_CONSOLE == null) ? 0 : process.env.URL_LAUNCHER_CONSOLE, + "URL_LAUNCHER_URL": (process.env.URL_LAUNCHER_URL == null) ? "file:////usr/src/app/data/index.html" : process.env.URL_LAUNCHER_URL + }; + + let window = null; + + + // enable touch events if your device supports them + if (electronConfig.URL_LAUNCHER_TOUCH) { + app.commandLine.appendSwitch("--touch-devices"); + } + // simulate touch events - might be useful for touchscreen with partial driver support + if (electronConfig.URL_LAUNCHER_TOUCH_SIMULATE) { + app.commandLine.appendSwitch("--simulate-touch-screen-with-mouse"); + } + + /* + we initialize our application display as a callback of the electronJS "ready" event + */ + app.on('ready', () => { + + // here we actually configure the behavour of electronJS + window = new BrowserWindow({ + width: parseInt(electronConfig.URL_LAUNCHER_WIDTH), + height: parseInt(electronConfig.URL_LAUNCHER_HEIGHT), + frame: electronConfig.URL_LAUNCHER_FRAME, + title: electronConfig.URL_LAUNCHER_TITLE, + kiosk: electronConfig.URL_LAUNCHER_KIOSK, + webPreferences: { + nodeIntegration: electronConfig.URL_LAUNCHER_NODE + } + }); + + window.webContents.on('did-finish-load', () => { + setTimeout(() => { + window.show(); + }, 300); + + }); + + // if the env-var is set to true, a portion of the screen will be dedicated to the chrome-dev-tools + if (electronConfig.URL_LAUNCHER_CONSOLE) { + window.openDevTools(); + } + + // the big red button, here we go + window.loadURL(electronConfig.URL_LAUNCHER_URL); + }); +} diff --git a/app/package.json b/app/package.json new file mode 100644 index 0000000..386b876 --- /dev/null +++ b/app/package.json @@ -0,0 +1,34 @@ +{ + "name": "resin-electronjs", + "version": "0.1.0", + "description": "electronJS-based rpi resin application", + "main": "main.js", + "scripts": { + "start": "NODE_ENV=production startx ./node_modules/electron-prebuilt/dist/electron .", + "test": "NODE_ENV=development startx ./node_modules/electron-prebuilt/dist/electron ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/resin-io/resin-electronjs.git" + }, + "keywords": [ + "resin", + "io", + "electron", + "js" + ], + "dependencies": { + "electron-prebuilt": "^1.3.4", + "electron-rebuild" :"^1.2.1" + }, + "author": "Carlo Maria Curinga", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/resin-io/resin-electronjs/issues" + }, + "homepage": "https://github.com/resin-io/resin-electronjs#readme", + "jshintConfig": { + "esnext": true, + "strict": true + } +} diff --git a/app/start.sh b/app/start.sh new file mode 100644 index 0000000..28e84b9 --- /dev/null +++ b/app/start.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# using electron-prebuilt module instead of the global electron let's you +# easily control specific version dependency between your app and electron itself. +# the syntax below starts an X istance with ONLY our electronJS fired up, +# it saves you a LOT of resources avoiding full-desktops envs + +while true; do + rm /tmp/.X0-lock >/dev/null 2>&1 || true + startx /usr/src/app/node_modules/electron-prebuilt/dist/electron /usr/src/app --enable-logging +done From a70c62cbbb8e9b5ab3ecc829f9dda6f6f21d148e Mon Sep 17 00:00:00 2001 From: curcuz Date: Fri, 2 Sep 2016 23:32:50 +0200 Subject: [PATCH 02/12] make gitignore cross host OS --- .gitignore | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index bc8caf7..d1e8e33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,17 @@ + +# Created by https://www.gitignore.io/api/node,windows,osx,linux + +### Node ### # Logs logs *.log +npm-debug.log* # Runtime data pids *.pid *.seed +*.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov @@ -13,6 +19,9 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# nyc test coverage +.nyc_output + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt @@ -22,10 +31,78 @@ coverage # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release -# Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +# Dependency directories node_modules -bower_components +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory -# OSX specific ignores -.DS_Store +# Linux trash folder which might appear on any partition or disk +.Trash-* From 2c35b57792fc0dd4bb1cb1e1de289a9bb75d260b Mon Sep 17 00:00:00 2001 From: curcuz Date: Fri, 2 Sep 2016 23:33:17 +0200 Subject: [PATCH 03/12] get rid of moved target files --- bower.json | 25 ------------------- main.js | 69 ---------------------------------------------------- package.json | 34 -------------------------- start.sh | 11 --------- 4 files changed, 139 deletions(-) delete mode 100644 bower.json delete mode 100644 main.js delete mode 100644 package.json delete mode 100644 start.sh diff --git a/bower.json b/bower.json deleted file mode 100644 index f8b64ce..0000000 --- a/bower.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "resin-electronjs", - "description": "electronJS-based rpi2 resin application", - "main": "main.js", - "authors": [ - "Carlo Maria Curinga" - ], - "license": "Apache-2.0", - "keywords": [ - "resin", - "io", - "electron", - "js" - ], - "homepage": "https://github.com/fwrgit/resin-electronjs", - "moduleType": [], - "private": true, - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/main.js b/main.js deleted file mode 100644 index 704697b..0000000 --- a/main.js +++ /dev/null @@ -1,69 +0,0 @@ -(function() { - 'use strict'; - // since we control the whole environment, we can safely use ES6 syntax: - const electron = require('electron'); - const app = electron.app; - const BrowserWindow = electron.BrowserWindow; - - // simple parameters initialization - let window = null; - let resin_toolbar = false; - let resin_kiosk = false; - let resin_node = true; - - - // enable touch events if your device supports them - if (process.env.URL_LAUNCHER_TOUCH && process.env.URL_LAUNCHER_TOUCH === "true") { - app.commandLine.appendSwitch("--touch-devices"); - } - // simulate touch events - might be useful for touchscreen with partial driver support - if (process.env.URL_LAUNCHER_TOUCH_SIMULATE && process.env.URL_LAUNCHER_TOUCH_SIMULATE === "true") { - app.commandLine.appendSwitch("--simulate-touch-screen-with-mouse"); - } - - /* - we initialize our application display as a callback of the electronJS "ready" event - */ - app.on('ready', function() { - - if (process.env.URL_LAUNCHER_FRAME && process.env.URL_LAUNCHER_FRAME === "false") { - resin_toolbar = false; - } - if (process.env.URL_LAUNCHER_KIOSK && process.env.URL_LAUNCHER_KIOSK === "true") { - resin_kiosk = true; - } - if (process.env.URL_LAUNCHER_NODE && process.env.URL_LAUNCHER_NODE === "false") { - resin_node = false; - } - - // here we actually configure the behavour of electronJS - window = new BrowserWindow({ - width: parseInt(process.env.URL_LAUNCHER_WIDTH || 1920), - height: parseInt(process.env.URL_LAUNCHER_HEIGHT || 1080), - frame: resin_toolbar, - title: process.env.URL_LAUNCHER_TITLE || "RESIN.IO", - kiosk: resin_kiosk, - webPreferences: { - nodeIntegration: resin_node - } - }); - - window.webContents.on('did-finish-load', function() { - // The flash of white is still present for a very short - // while after the WebView reports it finished loading - // taken from etcher - https://goo.gl/n5X0gY ) - setTimeout(function() { - window.show(); - }, 100); - - }); - - // if the env-var is set to true, a portion of the screen will be dedicated to the chrome-dev-tools - if (process.env.URL_LAUNCHER_CONSOLE && process.env.URL_LAUNCHER_CONSOLE === "true") { - window.openDevTools(); - } - - // the big red button, here we go - window.loadURL(process.env.URL_LAUNCHER_URL || "file:///app/app/index.html"); - }); -})(); diff --git a/package.json b/package.json deleted file mode 100644 index 4c24271..0000000 --- a/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "resin-electronjs", - "version": "0.0.3", - "description": "electronJS-based rpi resin application", - "main": "main.js", - "scripts": { - "start": "NODE_ENV=production startx ./node_modules/electron-prebuilt/dist/electron .", - "test": "NODE_ENV=development startx ./node_modules/electron-prebuilt/dist/electron ." - }, - "repository": { - "type": "git", - "url": "git+https://github.com/fwrgit/resin-electronjs.git" - }, - "keywords": [ - "resin", - "io", - "electron", - "js" - ], - "dependencies": { - "electron-prebuilt": "^1.1.3", - "electron-rebuild" :"*" - }, - "author": "Carlo Maria Curinga", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/fwrgit/resin-electronjs/issues" - }, - "homepage": "https://github.com/fwrgit/resin-electronjs#readme", - "jshintConfig": { - "esnext": true, - "strict": true - } -} diff --git a/start.sh b/start.sh deleted file mode 100644 index 5f2669f..0000000 --- a/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# using electron-prebuilt module instead of the global electron let's you -# easily control specific version dependency between your app and electron itself. -# the syntax below starts an X istance with ONLY our electronJS fired up, -# it saves you a LOT of resources avoiding full-desktops envs - -while true; do - rm /tmp/.X0-lock || true - startx /app/node_modules/electron-prebuilt/dist/electron /app --enable-logging -done From 4f9d667eff2c73718c849bcabf8bd6ffe8735730 Mon Sep 17 00:00:00 2001 From: curcuz Date: Fri, 2 Sep 2016 23:34:04 +0200 Subject: [PATCH 04/12] slim down,enable resin-sync, get rid of rpi specifics --- Dockerfile.template | 51 +++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 069f544..2fae62a 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,17 +1,19 @@ -FROM resin/%%RESIN_MACHINE_NAME%%-node:latest +FROM resin/%%RESIN_MACHINE_NAME%%-node:slim -## uncomment if you want systemd -# ENV INITSYSTEM on +# Install wget and curl +RUN apt-get clean && apt-get update && apt-get install -y \ + wget \ + curl -# Install apt deps -RUN apt-get update && apt-get install -y \ +# Install other apt deps +RUN apt-get clean && apt-get update && apt-get install -y \ apt-utils \ + build-essential \ + clang \ xserver-xorg-core \ xserver-xorg-input-all \ xserver-xorg-video-fbdev \ xorg \ - build-essential \ - clang \ libdbus-1-dev \ libgtk2.0-dev \ libnotify-dev \ @@ -26,42 +28,37 @@ RUN apt-get update && apt-get install -y \ fluxbox \ libsmbclient \ libssh-4 \ - python-dev \ - python-pip \ - build-essential \ - git \ - curl \ - psmisc \ - libraspberrypi0 \ - libpcre3 \ - fonts-freefont-ttf \ fbset \ - bind9 \ - libdbus-1-dev \ - libexpat-dev \ - usbutils \ - && rm -rf /var/lib/apt/lists/* + libexpat-dev && rm -rf /var/lib/apt/lists/* # Set Xorg and FLUXBOX preferences RUN mkdir ~/.fluxbox RUN echo "xset s off\nxserver-command=X -s 0 dpms" > ~/.fluxbox/startup -RUN echo "#!/bin/sh\n\nexec /usr/bin/X -s 0 dpms -nocursor -nolisten tcp "$@"" > /etc/X11/xinit/xserverrc +RUN echo '#!/bin/sh\n\nexec /usr/bin/X -s 0 dpms -nocursor -nolisten tcp "$@"' > /etc/X11/xinit/xserverrc # Set npm RUN npm config set unsafe-perm true -# Move package to filesystem -COPY ./package.json ./app/ +# Save source folder +RUN printf "%s\n" "${PWD##}" > SOURCEFOLDER -# NPM i app -RUN npm i --prefix /app +# Move to app dir +WORKDIR /usr/src/app + +# Move package.json to filesystem +COPY "$SOURCEFOLDER/app/package.json" ./ +# NPM i app +RUN JOBS=MAX npm i --production # Move app to filesystem -COPY . ./app +COPY "$SOURCEFOLDER/app" ./ # NPM rebuild node native modules after electron is installed. RUN ./app/node_modules/.bin/electron-rebuild +## uncomment if you want systemd +ENV INITSYSTEM on + # Start app CMD ["bash", "/app/start.sh"] From 3567bff16c086904d34c1f794f9b9a24a4594251 Mon Sep 17 00:00:00 2001 From: curcuz Date: Fri, 2 Sep 2016 23:53:18 +0200 Subject: [PATCH 05/12] remove rpi reference since its now cross arch --- app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/package.json b/app/package.json index 386b876..c44a053 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "resin-electronjs", "version": "0.1.0", - "description": "electronJS-based rpi resin application", + "description": "electronJS-based resin application", "main": "main.js", "scripts": { "start": "NODE_ENV=production startx ./node_modules/electron-prebuilt/dist/electron .", From 809dfed145096bb72d8163e238a16d4255fcfff8 Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 00:02:13 +0200 Subject: [PATCH 06/12] get rid of httpredir (sorry debian) --- Dockerfile.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile.template b/Dockerfile.template index 2fae62a..12f785c 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -5,6 +5,9 @@ RUN apt-get clean && apt-get update && apt-get install -y \ wget \ curl +# WTF is going on with httpredir from debian? removing it the dirty way +RUN sed -i "s/httpredir.debian.org/`curl -s -D - http://httpredir.debian.org/demo/debian/ | awk '/^Link:/ { print $2 }' | sed -e 's@;@\1@g'`/" /etc/apt/sources.list + # Install other apt deps RUN apt-get clean && apt-get update && apt-get install -y \ apt-utils \ From 8659ae6d9e35bf0286e2bf994e1fe616e2efdd92 Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 00:02:33 +0200 Subject: [PATCH 07/12] add getting-started, make rpi optional --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 55759cf..63d390d 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,23 @@ a boilerplate for developing kiosks, digital signage or other human-machine inte This is the very basic layer on which [snappin.io](http://snappin.io) builds its touch-enabled apps. -### PRE-REQUISITES -this application is meant to be deployed to [RaspberryPi](https://www.raspberrypi.org/products/) devices via [resin.io](http://resin.io). +## Getting started -At least 64MB of GPU-dedicated RAM is required. You can achieve that locally following [these instructions](http://docs.resin.io/#/pages/hardware/i2c-and-spi.md#raspberry-pi-camera-module) (only the first parameter `gpu_mem=64` is required) or, __as we strongly suggest__, set it remotely with Resin's [Advanced Boot Configuration](http://docs.resin.io/#/pages/configuration/advanced.md#modifying-config-txt-remotely-) feature. +- Sign up on [resin.io](https://dashboard.resin.io/signup) +- go throught the [getting started guide](http://docs.resin.io/raspberrypi/nodejs/getting-started/) and create a new RPI zero application +- clone this repository to your local workspace +- add the _resin remote_ to your local workspace using the useful shortcut in the dashboard UI ![remoteadd](https://raw.githubusercontent.com/resin-io-playground/boombeastic/master/docs/gitresinremote.png) +- `git push resin master` +- see the magic happening, your device is getting updated Over-The-Air! + +## Configure via [environment variables](https://docs.resin.io/management/env-vars/) +Variable Name | Value | Description | Device-specific +------------ | ------------- | ------------- | ------------- +RESIN_HOST_CONFIG_gpu_mem | a value from `64` to `160` | the amount of RAM dedicated to the GPU | Raspberry Pi (all revs) ### WHY THIS TEMPLATE -Achieving kinda-smooth desktop application display on a raspberrypi is hard. This project aims to provide a quickstart template. +Achieving kinda-smooth desktop application display on a devices like the raspberrypi is hard. This project aims to provide a quickstart template. ### WHY FLUXBOX From 60519aca382c5bd4c884652d171d78f7f39d246e Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 00:17:02 +0200 Subject: [PATCH 08/12] fixed last 2 cmds pointing to old path --- Dockerfile.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 12f785c..710497b 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -58,10 +58,10 @@ RUN JOBS=MAX npm i --production COPY "$SOURCEFOLDER/app" ./ # NPM rebuild node native modules after electron is installed. -RUN ./app/node_modules/.bin/electron-rebuild +RUN ./node_modules/.bin/electron-rebuild ## uncomment if you want systemd ENV INITSYSTEM on # Start app -CMD ["bash", "/app/start.sh"] +CMD ["bash", "/usr/src/app/start.sh"] From 2a9932149bd24669165e3456f0d4ba6f51f968e6 Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 00:35:48 +0200 Subject: [PATCH 09/12] add zoom env var config --- README.md | 1 + app/main.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63d390d..df65cb5 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,4 @@ simply set these [environment varables](http://docs.resin.io/#/pages/management/ * **`URL_LAUNCHER_HEIGHT`** *int* (converted from *string*) - - *defaults to* `1080` * **`URL_LAUNCHER_TOUCH`** *bool* (converted from *string*) - enables touch events if your device supports them - *defaults to* `false` * **`URL_LAUNCHER_TOUCH_SIMULATE`** *bool* (converted from *string*) - simulates touch events - might be useful for touchscreen with partial driver support - be aware this could be a performance hog - *defaults to* `false` +* **`URL_LAUNCHER_ZOOM`** *float* (converted from *string*) - The default zoom factor of the page, 3.0 represents 300% - *defaults to* `1.0` diff --git a/app/main.js b/app/main.js index 7921f29..790e06f 100644 --- a/app/main.js +++ b/app/main.js @@ -16,7 +16,8 @@ "URL_LAUNCHER_HEIGHT": (process.env.URL_LAUNCHER_HEIGHT == null) ? 1080 : process.env.URL_LAUNCHER_HEIGHT, "URL_LAUNCHER_TITLE": (process.env.URL_LAUNCHER_TITLE == null) ? "RESIN.IO" : process.env.URL_LAUNCHER_TITLE, "URL_LAUNCHER_CONSOLE": (process.env.URL_LAUNCHER_CONSOLE == null) ? 0 : process.env.URL_LAUNCHER_CONSOLE, - "URL_LAUNCHER_URL": (process.env.URL_LAUNCHER_URL == null) ? "file:////usr/src/app/data/index.html" : process.env.URL_LAUNCHER_URL + "URL_LAUNCHER_URL": (process.env.URL_LAUNCHER_URL == null) ? "file:////usr/src/app/data/index.html" : process.env.URL_LAUNCHER_URL, + "URL_LAUNCHER_ZOOM": (process.env.URL_LAUNCHER_ZOOM == null) ? 1.0 : parseFloat(process.env.URL_LAUNCHER_ZOOM) }; let window = null; @@ -44,7 +45,8 @@ title: electronConfig.URL_LAUNCHER_TITLE, kiosk: electronConfig.URL_LAUNCHER_KIOSK, webPreferences: { - nodeIntegration: electronConfig.URL_LAUNCHER_NODE + nodeIntegration: electronConfig.URL_LAUNCHER_NODE, + zoomFactor: electronConfig.URL_LAUNCHER_ZOOM } }); From f23598988959574f0eb97daa0e61e9ef33c27b2a Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 00:51:05 +0200 Subject: [PATCH 10/12] boooools --- README.md | 12 ++++++------ app/main.js | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index df65cb5..c83a875 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ We did a lot of researches and tests with several window managers. [Fluxbox](htt simply set these [environment varables](http://docs.resin.io/#/pages/management/env-vars.md) in your app via the resin dashboard to configure the behaviour of your devices * **`URL_LAUNCHER_URL`** *string* - the URL to be loaded. use `file:///app/app/index.html` to load a local electronJS (or any website) app - *defaults to* `file:///app/app/index.html` -* **`URL_LAUNCHER_NODE`** *bool* (converted from *string*) - whether or not enable nodejs - *defaults to* `false` -* **`URL_LAUNCHER_KIOSK`** *bool* (converted from *string*) - whether or not enter KIOSK mode - *defaults to* `true` +* **`URL_LAUNCHER_NODE`** *bool* (converted from *string*) - whether or not enable nodejs - *defaults to* `0` +* **`URL_LAUNCHER_KIOSK`** *bool* (converted from *string*) - whether or not enter KIOSK mode - *defaults to* `1` * **`URL_LAUNCHER_TITLE`** *string* - the title of the window. Seen only with `URL_LAUNCHER_FRAME`=`true` - *defaults to* `RESIN.IO` -* **`URL_LAUNCHER_FRAME`** *bool* (converted from *string*) - set to "true" to display the window frame. Seen only with `URL_LAUNCHER_KIOSK`=`false` - *defaults to* `false` -* **`URL_LAUNCHER_CONSOLE`** *bool* (converted from *string*) - set to "true" to display the debug console - *defaults to* `false` +* **`URL_LAUNCHER_FRAME`** *bool* (converted from *string*) - set to "true" to display the window frame. Seen only with `URL_LAUNCHER_KIOSK`=`false` - *defaults to* `0` +* **`URL_LAUNCHER_CONSOLE`** *bool* (converted from *string*) - set to "true" to display the debug console - *defaults to* `0` * **`URL_LAUNCHER_WIDTH`** *int* (converted from *string*) - - *defaults to* `1920` * **`URL_LAUNCHER_HEIGHT`** *int* (converted from *string*) - - *defaults to* `1080` -* **`URL_LAUNCHER_TOUCH`** *bool* (converted from *string*) - enables touch events if your device supports them - *defaults to* `false` -* **`URL_LAUNCHER_TOUCH_SIMULATE`** *bool* (converted from *string*) - simulates touch events - might be useful for touchscreen with partial driver support - be aware this could be a performance hog - *defaults to* `false` +* **`URL_LAUNCHER_TOUCH`** *bool* (converted from *string*) - enables touch events if your device supports them - *defaults to* `0` +* **`URL_LAUNCHER_TOUCH_SIMULATE`** *bool* (converted from *string*) - simulates touch events - might be useful for touchscreen with partial driver support - be aware this could be a performance hog - *defaults to* `0` * **`URL_LAUNCHER_ZOOM`** *float* (converted from *string*) - The default zoom factor of the page, 3.0 represents 300% - *defaults to* `1.0` diff --git a/app/main.js b/app/main.js index 790e06f..9e58f06 100644 --- a/app/main.js +++ b/app/main.js @@ -7,15 +7,15 @@ // simple parameters initialization let electronConfig = { - "URL_LAUNCHER_TOUCH": (process.env.URL_LAUNCHER_TOUCH == null) ? 0 : process.env.URL_LAUNCHER_TOUCH, - "URL_LAUNCHER_TOUCH_SIMULATE": (process.env.URL_LAUNCHER_TOUCH_SIMULATE == null) ? 0 : process.env.URL_LAUNCHER_TOUCH_SIMULATE, - "URL_LAUNCHER_FRAME": (process.env.URL_LAUNCHER_FRAME == null) ? 0 : process.env.URL_LAUNCHER_FRAME, - "URL_LAUNCHER_KIOSK": (process.env.URL_LAUNCHER_KIOSK == null) ? 1 : process.env.URL_LAUNCHER_KIOSK, - "URL_LAUNCHER_NODE": (process.env.URL_LAUNCHER_NODE == null) ? 0 : process.env.URL_LAUNCHER_NODE, - "URL_LAUNCHER_WIDTH": (process.env.URL_LAUNCHER_WIDTH == null) ? 1920 : process.env.URL_LAUNCHER_WIDTH, - "URL_LAUNCHER_HEIGHT": (process.env.URL_LAUNCHER_HEIGHT == null) ? 1080 : process.env.URL_LAUNCHER_HEIGHT, + "URL_LAUNCHER_TOUCH": (process.env.URL_LAUNCHER_TOUCH == null) ? 0 : parseInt(process.env.URL_LAUNCHER_TOUCH), + "URL_LAUNCHER_TOUCH_SIMULATE": (process.env.URL_LAUNCHER_TOUCH_SIMULATE == null) ? 0 : parseInt(process.env.URL_LAUNCHER_TOUCH_SIMULATE), + "URL_LAUNCHER_FRAME": (process.env.URL_LAUNCHER_FRAME == null) ? 0 : parseInt(process.env.URL_LAUNCHER_FRAME), + "URL_LAUNCHER_KIOSK": (process.env.URL_LAUNCHER_KIOSK == null) ? 1 : parseInt(process.env.URL_LAUNCHER_KIOSK), + "URL_LAUNCHER_NODE": (process.env.URL_LAUNCHER_NODE == null) ? 0 : parseInt(process.env.URL_LAUNCHER_NODE), + "URL_LAUNCHER_WIDTH": (process.env.URL_LAUNCHER_WIDTH == null) ? 1920 : parseInt(process.env.URL_LAUNCHER_WIDTH), + "URL_LAUNCHER_HEIGHT": (process.env.URL_LAUNCHER_HEIGHT == null) ? 1080 : parseInt(process.env.URL_LAUNCHER_HEIGHT), "URL_LAUNCHER_TITLE": (process.env.URL_LAUNCHER_TITLE == null) ? "RESIN.IO" : process.env.URL_LAUNCHER_TITLE, - "URL_LAUNCHER_CONSOLE": (process.env.URL_LAUNCHER_CONSOLE == null) ? 0 : process.env.URL_LAUNCHER_CONSOLE, + "URL_LAUNCHER_CONSOLE": (process.env.URL_LAUNCHER_CONSOLE == null) ? 0 : parseInt(process.env.URL_LAUNCHER_CONSOLE), "URL_LAUNCHER_URL": (process.env.URL_LAUNCHER_URL == null) ? "file:////usr/src/app/data/index.html" : process.env.URL_LAUNCHER_URL, "URL_LAUNCHER_ZOOM": (process.env.URL_LAUNCHER_ZOOM == null) ? 1.0 : parseFloat(process.env.URL_LAUNCHER_ZOOM) }; From 2a67bf4cd3af6515c5b90db3ab9f37e2f8525a2e Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 01:00:26 +0200 Subject: [PATCH 11/12] statement based bool conversion --- app/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main.js b/app/main.js index 9e58f06..3e4efce 100644 --- a/app/main.js +++ b/app/main.js @@ -41,11 +41,11 @@ window = new BrowserWindow({ width: parseInt(electronConfig.URL_LAUNCHER_WIDTH), height: parseInt(electronConfig.URL_LAUNCHER_HEIGHT), - frame: electronConfig.URL_LAUNCHER_FRAME, + frame: (electronConfig.URL_LAUNCHER_FRAME) ? true : false, title: electronConfig.URL_LAUNCHER_TITLE, - kiosk: electronConfig.URL_LAUNCHER_KIOSK, + kiosk: (electronConfig.URL_LAUNCHER_KIOSK) ? true : false, webPreferences: { - nodeIntegration: electronConfig.URL_LAUNCHER_NODE, + nodeIntegration: (electronConfig.URL_LAUNCHER_NODE) ? true : false, zoomFactor: electronConfig.URL_LAUNCHER_ZOOM } }); From 5a995946f9d183c1c5301602a1eb2e30c152e6a0 Mon Sep 17 00:00:00 2001 From: curcuz Date: Sat, 3 Sep 2016 01:21:16 +0200 Subject: [PATCH 12/12] add overlay scrollbars and a breaking change warning --- README.md | 5 ++++- app/main.js | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c83a875..53b9f0e 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,10 @@ Achieving kinda-smooth desktop application display on a devices like the raspber We did a lot of researches and tests with several window managers. [Fluxbox](http://fluxbox.org/) ended up being the most balanced between minimum footprint and features ### 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](http://docs.resin.io/#/pages/management/env-vars.md) in your app via the resin dashboard to configure the behaviour of your devices +simply set these [environment varables](http://docs.resin.io/#/pages/management/env-vars.md) in your app via the resin 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_URL`** *string* - the URL to be loaded. use `file:///app/app/index.html` to load a local electronJS (or any website) app - *defaults to* `file:///app/app/index.html` * **`URL_LAUNCHER_NODE`** *bool* (converted from *string*) - whether or not enable nodejs - *defaults to* `0` @@ -42,3 +44,4 @@ simply set these [environment varables](http://docs.resin.io/#/pages/management/ * **`URL_LAUNCHER_TOUCH`** *bool* (converted from *string*) - enables touch events if your device supports them - *defaults to* `0` * **`URL_LAUNCHER_TOUCH_SIMULATE`** *bool* (converted from *string*) - simulates touch events - might be useful for touchscreen with partial driver support - be aware this could be a performance hog - *defaults to* `0` * **`URL_LAUNCHER_ZOOM`** *float* (converted from *string*) - The default zoom factor of the page, 3.0 represents 300% - *defaults to* `1.0` +* **`URL_LAUNCHER_OVERLAY_SCROLLBARS`** *bool* (converted from *string*) - enables overlay scrollbars - *defaults to* `0` diff --git a/app/main.js b/app/main.js index 3e4efce..983cd8f 100644 --- a/app/main.js +++ b/app/main.js @@ -17,7 +17,8 @@ "URL_LAUNCHER_TITLE": (process.env.URL_LAUNCHER_TITLE == null) ? "RESIN.IO" : process.env.URL_LAUNCHER_TITLE, "URL_LAUNCHER_CONSOLE": (process.env.URL_LAUNCHER_CONSOLE == null) ? 0 : parseInt(process.env.URL_LAUNCHER_CONSOLE), "URL_LAUNCHER_URL": (process.env.URL_LAUNCHER_URL == null) ? "file:////usr/src/app/data/index.html" : process.env.URL_LAUNCHER_URL, - "URL_LAUNCHER_ZOOM": (process.env.URL_LAUNCHER_ZOOM == null) ? 1.0 : parseFloat(process.env.URL_LAUNCHER_ZOOM) + "URL_LAUNCHER_ZOOM": (process.env.URL_LAUNCHER_ZOOM == null) ? 1.0 : parseFloat(process.env.URL_LAUNCHER_ZOOM), + "URL_LAUNCHER_OVERLAY_SCROLLBARS": (process.env.URL_LAUNCHER_OVERLAY_SCROLLBARS == null) ? 0 : parseInt(process.env.URL_LAUNCHER_OVERLAY_SCROLLBARS) }; let window = null; @@ -46,7 +47,8 @@ kiosk: (electronConfig.URL_LAUNCHER_KIOSK) ? true : false, webPreferences: { nodeIntegration: (electronConfig.URL_LAUNCHER_NODE) ? true : false, - zoomFactor: electronConfig.URL_LAUNCHER_ZOOM + zoomFactor: electronConfig.URL_LAUNCHER_ZOOM, + overlayScrollbars: (electronConfig.URL_LAUNCHER_OVERLAY_SCROLLBARS) ? true : false } });