Skip to content
Permalink
Browse files

feat(Windows): Add option to quit Franz from Taskbar icon

  • Loading branch information...
adlk committed Feb 12, 2019
1 parent 6f33c47 commit 952fc8b9b48de1c825c98b996afda5621db5fefe
Showing with 21 additions and 3 deletions.
  1. +3 −1 electron-builder.yml
  2. +2 −1 src/config.js
  3. +3 −0 src/helpers/asar-helpers.js
  4. +13 −1 src/index.js
@@ -43,4 +43,6 @@ protocols:
name: Franz
schemes: [franz]

asarUnpack: "./dictionaries"
asarUnpack:
- ./dictionaries
- ./assets/images/taskbar
@@ -1,5 +1,6 @@
import electron from 'electron';
import path from 'path';
import { asarPath } from './helpers/asar-helpers';

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

// Replacing app.asar is not beautiful but unforunately necessary
export const DICTIONARY_PATH = path.join(__dirname, 'dictionaries').replace('app.asar', 'app.asar.unpacked');
export const DICTIONARY_PATH = asarPath(path.join(__dirname, 'dictionaries').replace('app.asar', 'app.asar.unpacked'));
@@ -0,0 +1,3 @@
export function asarPath(dir = '') {
return dir.replace('app.asar', 'app.asar.unpacked');
}
@@ -33,6 +33,7 @@ import {
DEFAULT_APP_SETTINGS,
DEFAULT_WINDOW_OPTIONS,
} from './config';
import { asarPath } from './helpers/asar-helpers';
/* eslint-enable import/first */

const debug = require('debug')('Franz:App');
@@ -88,6 +89,12 @@ if (!gotTheLock) {
window.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100);
window.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height);
}, 1);
} else if (argv.includes('--quit')) {
// Needs to be delayed to not interfere with mainWindow.restore();
setTimeout(() => {
debug('Quitting Franz via Task');
app.quit();
}, 1);
}
});
}
@@ -294,10 +301,15 @@ app.on('ready', () => {
app.setUserTasks([{
program: process.execPath,
arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`,
iconPath: path.join(`${__dirname}`, '../src/assets/images/taskbar/win32/display.ico'),
iconPath: asarPath(path.join(isDevMode ? `${__dirname}../src/` : __dirname, 'assets/images/taskbar/win32/display.ico')),
iconIndex: 0,
title: 'Move Franz to Current Display',
description: 'Restore the position and size of Franz',
}, {
program: process.execPath,
arguments: `${isDevMode ? `${__dirname} ` : ''}--quit`,
iconIndex: 0,
title: 'Quit Franz',
}]);
}

0 comments on commit 952fc8b

Please sign in to comment.
You can’t perform that action at this time.