diff options
author | Stefan <stefan@adlk.io> | 2019-02-12 15:40:50 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-02-12 15:42:58 +0100 |
commit | 88086011a634acbfd5179fcfb855de0bfd31930c (patch) | |
tree | c7c651f69ec6be2df3e48838db5c9678a08c1d1a | |
parent | Bump version to 5.0.0 (diff) | |
download | ferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.tar.gz ferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.tar.zst ferdium-app-88086011a634acbfd5179fcfb855de0bfd31930c.zip |
feat(Windows): Add option to quit Franz from Taskbar icon
-rw-r--r-- | electron-builder.yml | 4 | ||||
-rw-r--r-- | src/config.js | 3 | ||||
-rw-r--r-- | src/helpers/asar-helpers.js | 3 | ||||
-rw-r--r-- | src/index.js | 14 |
4 files changed, 21 insertions, 3 deletions
diff --git a/electron-builder.yml b/electron-builder.yml index 1d62669bf..97aafa207 100644 --- a/electron-builder.yml +++ b/electron-builder.yml | |||
@@ -43,4 +43,6 @@ protocols: | |||
43 | name: Franz | 43 | name: Franz |
44 | schemes: [franz] | 44 | schemes: [franz] |
45 | 45 | ||
46 | asarUnpack: "./dictionaries" | 46 | asarUnpack: |
47 | - ./dictionaries | ||
48 | - ./assets/images/taskbar | ||
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 @@ | |||
1 | import electron from 'electron'; | 1 | import electron from 'electron'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import { asarPath } from './helpers/asar-helpers'; | ||
3 | 4 | ||
4 | const app = process.type === 'renderer' ? electron.remote.app : electron.app; | 5 | const app = process.type === 'renderer' ? electron.remote.app : electron.app; |
5 | const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; | 6 | const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences; |
@@ -57,4 +58,4 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [ | |||
57 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); | 58 | export 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 |
60 | export const DICTIONARY_PATH = path.join(__dirname, 'dictionaries').replace('app.asar', 'app.asar.unpacked'); | 61 | export 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 @@ | |||
1 | export 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'; |
36 | import { asarPath } from './helpers/asar-helpers'; | ||
36 | /* eslint-enable import/first */ | 37 | /* eslint-enable import/first */ |
37 | 38 | ||
38 | const debug = require('debug')('Franz:App'); | 39 | const 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 | ||