mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
added temp tray and renamed mediaKeysModule
This commit is contained in:
parent
f389f1d6a2
commit
e5dd8cb87a
@ -1,7 +1,8 @@
|
||||
const { app, BrowserWindow, globalShortcut } = require("electron");
|
||||
const path = require("path");
|
||||
const tidalUrl = "https://listen.tidal.com";
|
||||
const mediaKeys = require("./scripts/media-keys");
|
||||
const trayModule = require("./scripts/tray");
|
||||
const mediaKeysModule = require("./scripts/mediaKeys");
|
||||
let mainWindow;
|
||||
let icon = path.join(__dirname, "../assets/icon.png");
|
||||
|
||||
@ -46,7 +47,7 @@ function createWindow(options = {}) {
|
||||
}
|
||||
|
||||
function addGlobalShortcuts() {
|
||||
Object.values(mediaKeys).forEach((key) => {
|
||||
Object.values(mediaKeysModule).forEach((key) => {
|
||||
globalShortcut.register(key, () => {
|
||||
mainWindow.webContents.send("globalKey", key);
|
||||
});
|
||||
@ -60,6 +61,8 @@ app.on("ready", () => {
|
||||
// window with white backround
|
||||
createWindow();
|
||||
addGlobalShortcuts();
|
||||
trayModule.addTray({ icon });
|
||||
trayModule.refreshTray();
|
||||
});
|
||||
|
||||
app.on("activate", function() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { setTitle, getTitle } = require("./scripts/window-functions");
|
||||
const { dialog } = require("electron").remote;
|
||||
const hotkeys = require("./scripts/hotkeys");
|
||||
const mediaKeys = require("./scripts/media-keys");
|
||||
const mediaKeysModule = require("./scripts/mediaKeys");
|
||||
const notifier = require("node-notifier");
|
||||
const { ipcRenderer } = require("electron");
|
||||
const { app } = require("electron").remote;
|
||||
@ -189,13 +189,13 @@ function addIPCEventListeners() {
|
||||
|
||||
ipcRenderer.on("globalEvent", (event, args) => {
|
||||
switch (args) {
|
||||
case mediaKeys.playPause:
|
||||
case mediaKeysModule.playPause:
|
||||
playPause();
|
||||
break;
|
||||
case mediaKeys.next:
|
||||
case mediaKeysModule.next:
|
||||
elements.click("next");
|
||||
break;
|
||||
case mediaKeys.previous:
|
||||
case mediaKeysModule.previous:
|
||||
elements.click("previous");
|
||||
break;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
const mediaKeys = {
|
||||
const mediaKeysModule = {
|
||||
play: "MediaPlayPause",
|
||||
next: "MediaNextTrack",
|
||||
previous: "MediaPreviousTrack",
|
||||
};
|
||||
|
||||
module.exports = mediaKeys;
|
||||
module.exports = mediaKeysModule;
|
20
src/scripts/tray.js
Normal file
20
src/scripts/tray.js
Normal file
@ -0,0 +1,20 @@
|
||||
const { Tray, Menu } = require("electron");
|
||||
const trayModule = {};
|
||||
let tray;
|
||||
|
||||
trayModule.addTray = function(options = { icon: "" }) {
|
||||
tray = new Tray(options.icon);
|
||||
};
|
||||
|
||||
trayModule.refreshTray = function() {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: "Item1", type: "radio" },
|
||||
{ label: "Item2", type: "radio" },
|
||||
{ label: "Item3", type: "radio", checked: true },
|
||||
{ label: "Item4", type: "radio" },
|
||||
]);
|
||||
tray.setToolTip("This is my application.");
|
||||
tray.setContextMenu(contextMenu);
|
||||
};
|
||||
|
||||
module.exports = trayModule;
|
Loading…
Reference in New Issue
Block a user