This repository was archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.js
More file actions
59 lines (48 loc) · 1.57 KB
/
main.js
File metadata and controls
59 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
const { app, systemPreferences } = require('electron')
const shellEnv = require('shell-env')
const path = require('path')
const sudo = require('sudo-prompt')
const { createTray, createWindow, updateTrayIcon, updateDarkMode } = require('./src/electron/window')
if ('darwin' == process.platform) {
app.dock.hide()
}
app.on('ready', () => {
global.sharedObject = {
isDarkMode: 'darwin' == process.platform ? systemPreferences.isDarkMode() : false
}
const envVars = shellEnv.sync()
// Ask for root permissions
const serverpath = path.join(__dirname, 'dist', 'monday-server')
sudo.exec(`${serverpath} &`, {
name: 'Monday',
env: {
'HOME': envVars.HOME || '',
'GOPATH': envVars.GOPATH || '',
'MONDAY_CONFIG_PATH': envVars.MONDAY_CONFIG_PATH || '',
'MONDAY_KUBE_CONFIG': envVars.MONDAY_KUBE_CONFIG || '',
'PATH': envVars.PATH || '',
'TERM': 'xterm',
},
},
function (error, stdout, stderr) {
if (error) throw error
launchApplication()
}
)
})
const launchApplication = () => {
createTray()
createWindow(app)
}
const themeHasChanged = () => {
global.sharedObject.isDarkMode = systemPreferences.isDarkMode()
updateTrayIcon()
updateDarkMode()
}
if ('darwin' == process.platform) {
systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', themeHasChanged)
}
app.on('window-all-closed', () => {
app.quit()
})