Skip to content

Commit 8808601

Browse files
committed
feat(Windows): Add option to quit Franz from Taskbar icon
1 parent 91a510a commit 8808601

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

electron-builder.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ protocols:
4343
name: Franz
4444
schemes: [franz]
4545

46-
asarUnpack: "./dictionaries"
46+
asarUnpack:
47+
- ./dictionaries
48+
- ./assets/images/taskbar

src/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import electron from 'electron';
22
import path from 'path';
3+
import { asarPath } from './helpers/asar-helpers';
34

45
const app = process.type === 'renderer' ? electron.remote.app : electron.app;
56
const systemPreferences = process.type === 'renderer' ? electron.remote.systemPreferences : electron.systemPreferences;
@@ -57,4 +58,4 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [
5758
export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config');
5859

5960
// 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'));

src/helpers/asar-helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function asarPath(dir = '') {
2+
return dir.replace('app.asar', 'app.asar.unpacked');
3+
}

src/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
DEFAULT_APP_SETTINGS,
3434
DEFAULT_WINDOW_OPTIONS,
3535
} from './config';
36+
import { asarPath } from './helpers/asar-helpers';
3637
/* eslint-enable import/first */
3738

3839
const debug = require('debug')('Franz:App');
@@ -88,6 +89,12 @@ if (!gotTheLock) {
8889
window.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100);
8990
window.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height);
9091
}, 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);
9198
}
9299
});
93100
}
@@ -265,10 +272,15 @@ app.on('ready', () => {
265272
app.setUserTasks([{
266273
program: process.execPath,
267274
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')),
269276
iconIndex: 0,
270277
title: 'Move Franz to Current Display',
271278
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',
272284
}]);
273285
}
274286

0 commit comments

Comments
 (0)