mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
add windows interactive notifications
This commit is contained in:
@ -1,19 +1,57 @@
|
||||
const {setOptions} = require("../../config/plugins");
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
const path = require("path");
|
||||
const { app } = require("electron");
|
||||
const icon = path.join(__dirname, "assets", "youtube-music.png");
|
||||
const fs = require("fs");
|
||||
|
||||
const tempIcon = path.join(app.getPath("userData"), "tempIcon.png");
|
||||
|
||||
module.exports.urgencyLevels = [
|
||||
{name: "Low", value: "low"},
|
||||
{name: "Normal", value: "normal"},
|
||||
{name: "High", value: "critical"},
|
||||
{ name: "Low", value: "low" },
|
||||
{ name: "Normal", value: "normal" },
|
||||
{ name: "High", value: "critical" },
|
||||
];
|
||||
module.exports.setUrgency = (options, level) => {
|
||||
options.urgency = level
|
||||
setOption(options)
|
||||
options.urgency = level;
|
||||
setOption(options);
|
||||
};
|
||||
module.exports.setUnpause = (options, value) => {
|
||||
options.unpauseNotification = value
|
||||
setOption(options)
|
||||
options.unpauseNotification = value;
|
||||
setOption(options);
|
||||
};
|
||||
module.exports.setInteractive = (options, value) => {
|
||||
options.interactive = value;
|
||||
setOption(options);
|
||||
}
|
||||
|
||||
module.exports.notificationImage = function (songInfo, url = false) {
|
||||
//return local url
|
||||
if (!!songInfo && url) {
|
||||
try {
|
||||
fs.writeFileSync(tempIcon,
|
||||
songInfo.image
|
||||
.resize({ height: 256, width: 256 })
|
||||
.toPNG()
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(`Error downloading song icon:\n${err.toString()}`)
|
||||
return icon;
|
||||
}
|
||||
return tempIcon;
|
||||
}
|
||||
//else: return image
|
||||
return songInfo.image
|
||||
? songInfo.image.resize({ height: 256, width: 256 })
|
||||
: icon
|
||||
};
|
||||
|
||||
let setOption = options => {
|
||||
setOptions("notifications", options)
|
||||
};
|
||||
|
||||
module.exports.icons = {
|
||||
play: "\u{1405}", // ᐅ
|
||||
pause: "\u{2016}", // ‖
|
||||
next: "\u{1433}", // ᐳ
|
||||
previous: "\u{1438}" // ᐸ
|
||||
}
|
||||
Reference in New Issue
Block a user