mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
add optional PiP hotkey
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
const path = require("path");
|
||||
|
||||
const { app, ipcMain } = require("electron");
|
||||
const electronLocalshortcut = require("electron-localshortcut");
|
||||
|
||||
const { setOptions, isEnabled } = require("../../config/plugins");
|
||||
const { injectCSS } = require("../utils");
|
||||
@ -100,6 +101,9 @@ module.exports = (_win, _options) => {
|
||||
ipcMain.on("picture-in-picture", async () => {
|
||||
await togglePiP();
|
||||
});
|
||||
if (options.hotkey) {
|
||||
electronLocalshortcut.register(win, options.hotkey, togglePiP);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.setOptions = setLocalOptions;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
const prompt = require("custom-electron-prompt");
|
||||
|
||||
const promptOptions = require("../../providers/prompt-options");
|
||||
const { setOptions } = require("./back.js");
|
||||
|
||||
module.exports = (win, options) => [
|
||||
@ -25,5 +28,34 @@ module.exports = (win, options) => [
|
||||
click: (item) => {
|
||||
setOptions({ saveSize: item.checked });
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Hotkey",
|
||||
type: "checkbox",
|
||||
checked: options.hotkey,
|
||||
click: async (item) => {
|
||||
const output = await prompt({
|
||||
title: "Picture in Picture Hotkey",
|
||||
label: "Choose a hotkey for toggling Picture in Picture",
|
||||
type: "keybind",
|
||||
keybindOptions: [{
|
||||
value: "hotkey",
|
||||
label: "Hotkey",
|
||||
default: options.hotkey
|
||||
}],
|
||||
...promptOptions()
|
||||
}, win)
|
||||
|
||||
if (output) {
|
||||
const { value, accelerator } = output[0];
|
||||
console.log({ [value]: accelerator }); // DELETE
|
||||
setOptions({ [value]: accelerator });
|
||||
|
||||
item.checked = !!accelerator;
|
||||
} else {
|
||||
// Reset checkbox if prompt was canceled
|
||||
item.checked = !item.checked;
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user