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: name: Franz schemes: [franz] -asarUnpack: "./dictionaries" +asarUnpack: + - ./dictionaries + - ./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 @@ 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')); 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 @@ +export function asarPath(dir = '') { + return dir.replace('app.asar', 'app.asar.unpacked'); +} 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 { 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); } }); } @@ -265,10 +272,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', }]); }