aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Stefan <stefan@adlk.io>2019-02-12 15:40:50 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-02-12 15:42:58 +0100
commit88086011a634acbfd5179fcfb855de0bfd31930c (patch)
treec7c651f69ec6be2df3e48838db5c9678a08c1d1a /src
parentBump version to 5.0.0 (diff)
downloadferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.tar.gz
ferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.tar.zst
ferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.zip
feat(Windows): Add option to quit Franz from Taskbar icon
Diffstat (limited to 'src')
-rw-r--r--src/config.js3
-rw-r--r--src/helpers/asar-helpers.js3
-rw-r--r--src/index.js14
3 files changed, 18 insertions, 2 deletions
diff --git a/src/config.js b/src/config.js
index 789ddd1a0..101a4379a 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,5 +1,6 @@
1import electron from 'electron'; 1import electron from 'electron';
2import path from 'path'; 2import path from 'path';
3import { asarPath } from './helpers/asar-helpers';
3 4
4const app = process.type === 'renderer' ? electron.remote.app : electron.app; 5const app = process.type === 'renderer' ? electron.remote.app : electron.app;
5const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; 6const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences;
@@ -57,4 +58,4 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [
57export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); 58export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config');
58 59
59// Replacing app.asar is not beautiful but unforunately necessary 60// Replacing app.asar is not beautiful but unforunately necessary
60export const DICTIONARY_PATH = path.join(__dirname, 'dictionaries').replace('app.asar', 'app.asar.unpacked'); 61export const DICTIONARY_PATH = asarPath(path.join(__dirname, 'dictionaries').replace('app.asar', 'app.asar.unpacked'));
diff --git a/src/helpers/asar-helpers.js b/src/helpers/asar-helpers.js
new file mode 100644
index 000000000..9e4380c06
--- /dev/null
+++ b/src/helpers/asar-helpers.js
@@ -0,0 +1,3 @@
1export function asarPath(dir = '') {
2 return dir.replace('app.asar', 'app.asar.unpacked');
3}
diff --git a/src/index.js b/src/index.js
index a2b4acb00..6a0ee600f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -33,6 +33,7 @@ import {
33 DEFAULT_APP_SETTINGS, 33 DEFAULT_APP_SETTINGS,
34 DEFAULT_WINDOW_OPTIONS, 34 DEFAULT_WINDOW_OPTIONS,
35} from './config'; 35} from './config';
36import { asarPath } from './helpers/asar-helpers';
36/* eslint-enable import/first */ 37/* eslint-enable import/first */
37 38
38const debug = require('debug')('Franz:App'); 39const debug = require('debug')('Franz:App');
@@ -88,6 +89,12 @@ if (!gotTheLock) {
88 window.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100); 89 window.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100);
89 window.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height); 90 window.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height);
90 }, 1); 91 }, 1);
92 } else if (argv.includes('--quit')) {
93 // Needs to be delayed to not interfere with mainWindow.restore();
94 setTimeout(() => {
95 debug('Quitting Franz via Task');
96 app.quit();
97 }, 1);
91 } 98 }
92 }); 99 });
93 } 100 }
@@ -265,10 +272,15 @@ app.on('ready', () => {
265 app.setUserTasks([{ 272 app.setUserTasks([{
266 program: process.execPath, 273 program: process.execPath,
267 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`, 274 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`,
268 iconPath: path.join(`${__dirname}`, '../src/assets/images/taskbar/win32/display.ico'), 275 iconPath: asarPath(path.join(isDevMode ? `${__dirname}../src/` : __dirname, 'assets/images/taskbar/win32/display.ico')),
269 iconIndex: 0, 276 iconIndex: 0,
270 title: 'Move Franz to Current Display', 277 title: 'Move Franz to Current Display',
271 description: 'Restore the position and size of Franz', 278 description: 'Restore the position and size of Franz',
279 }, {
280 program: process.execPath,
281 arguments: `${isDevMode ? `${__dirname} ` : ''}--quit`,
282 iconIndex: 0,
283 title: 'Quit Franz',
272 }]); 284 }]);
273 } 285 }
274 286