Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit 62b190d

Browse files
authored
Start in System Tray (#537)
* maximize window when not in dev environnement on startup * remove unused screen import * reduce minimum window size * add start in tray option in tray * start in tray logic implemented
1 parent 6997784 commit 62b190d

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
{
2+
"start in tray": "start in tray"
23
}

src/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ async function createWindow () {
161161
menu = createMenu(win, i18nextMainBackend)
162162
tray = createTray(win, i18nextMainBackend)
163163
})
164+
165+
if(store.get('settings.start_in_trays'))
166+
win.hide()
164167
}
165168

166169
function signInInoreader () {

src/main/tray.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import {
44
Menu,
55
Tray
66
} from 'electron'
7+
import Store from 'electron-store'
78
import os from 'os'
89

910
export default function createTray(mainWindow, i18nextMain) {
11+
const store = new Store({
12+
encryptionKey: process.env.VUE_APP_ENCRYPT_KEY
13+
})
14+
1015
let trayImage
1116

1217
if (os.platform() === 'darwin') {
@@ -23,13 +28,23 @@ export default function createTray(mainWindow, i18nextMain) {
2328

2429
const tray = new Tray(trayImage)
2530

26-
const contextMenu = Menu.buildFromTemplate([{
27-
label: i18nextMain.t('Quit'),
28-
click: () => {
29-
app.isQuiting = true
30-
app.quit()
31+
const contextMenu = Menu.buildFromTemplate([
32+
{
33+
label: i18nextMain.t('start in tray'),
34+
type: "checkbox",
35+
checked: store.get('settings.start_in_trays'),
36+
click: () => {
37+
store.set('settings.start_in_trays', contextMenu.items[0].checked)
38+
}
39+
},
40+
{
41+
label: i18nextMain.t('Quit'),
42+
click: () => {
43+
app.isQuiting = true
44+
app.quit()
45+
}
3146
}
32-
}])
47+
])
3348

3449
if (os.platform() !== 'linux') {
3550
tray.on('right-click', () => {

0 commit comments

Comments
 (0)