diff options
author | 2019-02-12 15:40:50 +0100 | |
---|---|---|
committer | 2019-02-12 15:40:50 +0100 | |
commit | 952fc8b9b48de1c825c98b996afda5621db5fefe (patch) | |
tree | e4d3e481912af2241cf13b6824c7a088e5291101 | |
parent | Update & reuse electron-rebuild (diff) | |
download | ferdium-app-952fc8b9b48de1c825c98b996afda5621db5fefe.tar.gz ferdium-app-952fc8b9b48de1c825c98b996afda5621db5fefe.tar.zst ferdium-app-952fc8b9b48de1c825c98b996afda5621db5fefe.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 a3c770797..69cfa77e7 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 | } |
@@ -294,10 +301,15 @@ app.on('ready', () => { | |||
294 | app.setUserTasks([{ | 301 | app.setUserTasks([{ |
295 | program: process.execPath, | 302 | program: process.execPath, |
296 | arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`, | 303 | arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`, |
297 | iconPath: path.join(`${__dirname}`, '../src/assets/images/taskbar/win32/display.ico'), | 304 | iconPath: asarPath(path.join(isDevMode ? `${__dirname}../src/` : __dirname, 'assets/images/taskbar/win32/display.ico')), |
298 | iconIndex: 0, | 305 | iconIndex: 0, |
299 | title: 'Move Franz to Current Display', | 306 | title: 'Move Franz to Current Display', |
300 | description: 'Restore the position and size of Franz', | 307 | description: 'Restore the position and size of Franz', |
308 | }, { | ||
309 | program: process.execPath, | ||
310 | arguments: `${isDevMode ? `${__dirname} ` : ''}--quit`, | ||
311 | iconIndex: 0, | ||
312 | title: 'Quit Franz', | ||
301 | }]); | 313 | }]); |
302 | } | 314 | } |
303 | 315 | ||