From 6a184b069be952c6c23cce432d5e0650e79dcc03 Mon Sep 17 00:00:00 2001 From: Andreas 'count' Kotes Date: Sat, 10 Dec 2016 17:02:54 +0100 Subject: [PATCH] make electronOptions configurable, remove kioskmode from documentation --- CHANGELOG.md | 1 + README.md | 2 +- js/defaults.js | 1 + js/electron.js | 12 ++++++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 673b5669..fb41a8de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added option `zoom` to scale the whole mirror display with a given factor. - Added option `roundTemp` for currentweather and weatherforecast modules to display temperatures rounded to nearest integer. - Added abilty set the classes option to compliments module for style and text size of compliments. +- Added ability to configure electronOptions ### Updated - Modified translations for Frysk. diff --git a/README.md b/README.md index 4476447d..7c5286dd 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,12 @@ The following properties can be configured: | `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. | | `address` | The ip address the accept connections. The default open bind `::` is IPv6 is available or `0.0.0.0` IPv4 run on. Example config: `192.168.10.100`. | | `ipWhitelist` | The list of IPs from which you are allowed to access the MagicMirror². The default value is `["127.0.0.1", "::ffff:127.0.0.1", "::1"]`. It is possible to specify IPs with subnet masks (`["127.0.0.1", "127.0.0.1/24"]`) or define ip ranges (`["127.0.0.1", ["192.168.0.1", "192.168.0.100"]]`).| -| `kioskmode` | This allows MagicMirror² to run in Kiosk Mode. It protects from other programs popping on top of your screen. The default value is `false`| | `zoom` | This allows to scale the mirror contents with a given zoom factor. The default value is `1.0`| | `language` | The language of the interface. (Note: Not all elements will be localized.) Possible values are `en`, `nl`, `ru`, `fr`, etc., but the default value is `en`. | | `timeFormat` | The form of time notation that will be used. Possible values are `12` or `24`. The default is `24`. | | `units` | The units that will be used in the default weather modules. Possible values are `metric` or `imperial`. The default is `metric`. | | `modules` | An array of active modules. **The array must contain objects. See the next table below for more information.** | +| `electronOptions` | An optional array of Electron (browser) options. This allows configuration of e.g. the browser screen size and position (defaults `.width = 800` & `.height = 600`). Kiosk mode can be enabled by setting `.kiosk = true`, `.autoHideMenuBar = false`, `.fullscreen = false`. More options can be found [here](https://github.com/electron/electron/blob/master/docs/api/browser-window.md). | Module configuration: diff --git a/js/defaults.js b/js/defaults.js index b48edb21..b5b11561 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -10,6 +10,7 @@ var defaults = { port: 8080, kioskmode: false, + electronOptions: {}, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "en", diff --git a/js/electron.js b/js/electron.js index 589c265c..edd4896b 100644 --- a/js/electron.js +++ b/js/electron.js @@ -19,7 +19,7 @@ let mainWindow; function createWindow() { - var electronOptions = { + var electronOptionsDefaults = { width: 800, height: 600, x: 0, @@ -31,13 +31,17 @@ function createWindow() { } } + // DEPRECATED: "kioskmode" backwards compatibility, to be removed + // settings these options directly instead provides cleaner interface if (config.kioskmode) { - electronOptions.kiosk = true; + electronOptionsDefaults.kiosk = true; } else { - electronOptions.fullscreen = true; - electronOptions.autoHideMenuBar = true; + electronOptionsDefaults.fullscreen = true; + electronOptionsDefaults.autoHideMenuBar = true; } + var electronOptions = Object.assign({}, electronOptionsDefaults, config.electronOptions); + // Create the browser window. mainWindow = new BrowserWindow(electronOptions);