use Electron with ToastXML instead of SnoreToast

* Add support for protocol commands
* Remove node-notifier dependency
This commit is contained in:
Araxeus
2023-01-07 19:31:29 +02:00
parent e6146940b1
commit 2c49f6c740
18 changed files with 193 additions and 187 deletions

View File

@ -0,0 +1,44 @@
const { app } = require("electron");
const path = require("path");
const getSongControls = require("./song-controls");
const APP_PROTOCOL = "youtubemusic";
let protocolHandler;
function setupProtocolHandler(win) {
if (process.defaultApp && process.argv.length >= 2) {
app.setAsDefaultProtocolClient(
APP_PROTOCOL,
process.execPath,
[path.resolve(process.argv[1])]
);
} else {
app.setAsDefaultProtocolClient(APP_PROTOCOL)
}
const songControls = getSongControls(win);
protocolHandler = (cmd) => {
if (Object.keys(songControls).includes(cmd)) {
songControls[cmd]();
}
}
}
function handleProtocol(cmd) {
protocolHandler(cmd);
}
function changeProtocolHandler(f) {
protocolHandler = f;
}
module.exports = {
APP_PROTOCOL,
setupProtocolHandler,
handleProtocol,
changeProtocolHandler,
};