From 0fb6a305a316c39f32259aea5434336c864a7d9c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 26 May 2017 09:45:30 +0100 Subject: [PATCH] uber basic multi-profile support for electron app Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/package.json | 3 ++- electron_app/src/electron-main.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/electron_app/package.json b/electron_app/package.json index df9c3bd2..e001f51d 100644 --- a/electron_app/package.json +++ b/electron_app/package.json @@ -6,6 +6,7 @@ "description": "A feature-rich client for Matrix.org", "author": "Vector Creations Ltd.", "dependencies": { - "electron-window-state": "^4.1.0" + "electron-window-state": "^4.1.0", + "minimist": "^1.2.0" } } diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index 26f8f972..9170d4b4 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -23,6 +23,7 @@ limitations under the License. const check_squirrel_hooks = require('./squirrelhooks'); if (check_squirrel_hooks()) return; +const argv = require('minimist')(process.argv); const electron = require('electron'); const tray = require('./tray'); @@ -32,6 +33,10 @@ const webContentsHandler = require('./webcontents-handler'); const windowStateKeeper = require('electron-window-state'); +if (argv.profile) { + electron.app.setPath('userData', `${electron.app.getPath('userData')}-${argv.profile}`); +} + let vectorConfig = {}; try { vectorConfig = require('../../webapp/config.json'); @@ -191,7 +196,7 @@ electron.app.on('ready', () => { brand: vectorConfig.brand || 'Riot' }); - if (!process.argv.includes('--hidden')) { + if (!argv.hidden) { mainWindow.once('ready-to-show', () => { mainWindow.show(); });