-
Notifications
You must be signed in to change notification settings - Fork 533
/
minimizeShortcut.plugin.js
40 lines (32 loc) · 1.22 KB
/
minimizeShortcut.plugin.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
//////////META { "name": "minimizeShortcut" } *//////////
var minimizeShortcut = (function(){
var win, globalShortcut, shortcut, minimizeToTray, listener;
// CONFIG
shortcut = "CommandOrControl+D"; // have a look at this if your shortcut doesn't work: https://electron.atom.io/docs/api/accelerator/
minimizeToTray = false; // true or false
// CONFIG
class minimizeShortcut {
getName(){return "Minimize-Shortcut"}
getDescription(){return "Provides you with a shortcut to show/hide/minimize discord. Edit the file to configure the plugin."}
getVersion(){return "1.0.0"}
getAuthor(){return "square"}
load(){}
start(){
win = require("electron").remote.require("electron").BrowserWindow.getAllWindows()[0];
globalShortcut = require("electron").remote.require("electron").globalShortcut;
globalShortcut.register(shortcut, listener);
}
stop(){
globalShortcut.unregister(shortcut);
}
}
listener = function() {
if( win.isVisible() && !win.isMinimized() )
minimizeToTray ? win.hide() : win.minimize();
else if( win.isVisible() )
win.restore();
else
win.show() || win.focus();
}
return minimizeShortcut;
})()