mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
add optional PiP hotkey
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const { app, ipcMain } = require("electron");
|
const { app, ipcMain } = require("electron");
|
||||||
|
const electronLocalshortcut = require("electron-localshortcut");
|
||||||
|
|
||||||
const { setOptions, isEnabled } = require("../../config/plugins");
|
const { setOptions, isEnabled } = require("../../config/plugins");
|
||||||
const { injectCSS } = require("../utils");
|
const { injectCSS } = require("../utils");
|
||||||
@ -100,6 +101,9 @@ module.exports = (_win, _options) => {
|
|||||||
ipcMain.on("picture-in-picture", async () => {
|
ipcMain.on("picture-in-picture", async () => {
|
||||||
await togglePiP();
|
await togglePiP();
|
||||||
});
|
});
|
||||||
|
if (options.hotkey) {
|
||||||
|
electronLocalshortcut.register(win, options.hotkey, togglePiP);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.setOptions = setLocalOptions;
|
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");
|
const { setOptions } = require("./back.js");
|
||||||
|
|
||||||
module.exports = (win, options) => [
|
module.exports = (win, options) => [
|
||||||
@ -25,5 +28,34 @@ module.exports = (win, options) => [
|
|||||||
click: (item) => {
|
click: (item) => {
|
||||||
setOptions({ saveSize: item.checked });
|
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