forked from Bunkerbewohner/tidal-music-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
69 lines (59 loc) · 2.16 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
var electron = require('electron');
var app = electron.app; // Module to control application life.
var BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
var globalShortcut = electron.globalShortcut;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
// TODO: Determine path to Pepper flash plugin, rather than hardcoding it
var pepperFlashPluginPath = '/usr/lib/adobe-flashplugin/libpepflashplayer.so'
app.commandLine.appendSwitch('ppapi-flash-path', pepperFlashPluginPath);
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// don't quit until user explicitly asks for it
app.quit();
});
// Prevent multiple instances
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
return true;
});
if (shouldQuit) {
app.quit();
return;
}
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
frame: true,
icon: "icon.png",
autoHideMenuBar: true,
darkTheme: true,
plugin:true,
webPreferences: {
plugins: true
}
});
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html', {userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36"});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
mainWindow = null;
});
console.log("APP READY")
// handle media keys
var routeShortcuts = ["MediaPreviousTrack", "MediaNextTrack", "MediaPlayPause", "MediaStop"]
routeShortcuts.forEach(shortcut => {
if (!globalShortcut.register(shortcut, function() {
mainWindow.webContents.send("playback-control", shortcut)
})) {
console.log("Failed to register shortcut", shortcut, "Is your desktop environment already handling it?");
}
})
});