-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
81 lines (70 loc) · 2.28 KB
/
main.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { app, Tray, Menu } = require('electron')
const HiddenFiles = require('./src/hiddenFiles');
const DesktopIcons = require('./src/desktopIcons');
const Launcher = require('./src/launcher');
const ScreenCapture = require('./src/screenCapture');
const IpService = require('./src/ip');
let locale = 'en';
let launcherState = false;
let muLauncher = new Launcher();
let hFiles = new HiddenFiles();
let desckIcons = new DesktopIcons();
let muScreenCapture = new ScreenCapture();
let ip = new IpService();
app.dock.hide();
/**
* App is ready ... init!
*/
app.on('ready', function() {
muLauncher.isEnabled().then(function(isEnabled) {
launcherState = isEnabled;
locale = app.getLocale();
setMenu();
});
});
/**
* Set menu application
*/
function setMenu() {
tray = new Tray(__dirname + '/muTemplate.png')
const contextMenu = Menu.buildFromTemplate([
{label: 'Show hidden files', type: 'checkbox', checked: hFiles.readState(), click (item) {
hFiles.setState(item.checked);
}},
{label: 'Show desktop icons', type: 'checkbox', checked: desckIcons.readState(), click (item) {
desckIcons.setState(item.checked);
}},
{type: 'separator'},
{label: 'Save screenshots as', submenu: [
{label: 'png', type: 'radio', checked:muScreenCapture.isType('png'), click () {
muScreenCapture.setType('png')
}},
{label: 'jpg', type: 'radio', checked:muScreenCapture.isType('jpg'), click () {
muScreenCapture.setType('jpg')
}},
{label: 'pdf', type: 'radio', checked:muScreenCapture.isType('pdf'), click () {
muScreenCapture.setType('pdf')
}},
{label: 'tiff', type: 'radio', checked:muScreenCapture.isType('tiff'), click () {
muScreenCapture.setType('tiff')
}},
]},
{label: 'Make screenshot on desktop', click () {
muScreenCapture.take();
}},
{type: 'separator'},
{label: 'Copy external ip: ' + ip.readIp(), click () {
ip.copyIp();
}},
{type: 'separator'},
{label: 'Start app on system startup', type: 'checkbox', checked: launcherState, click(item) {
muLauncher.setState(item.checked)
}},
{type: 'separator'},
{label: 'Quit', click () {
app.quit();
}}
]);
tray.setToolTip('mu - mac utilities');
tray.setContextMenu(contextMenu);
}