mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
Add mpris support
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
const { globalShortcut } = require("electron");
|
||||
const electronLocalshortcut = require("electron-localshortcut");
|
||||
const { setupMPRIS } = require("./mpris");
|
||||
|
||||
const getSongControls = require("../../providers/song-controls");
|
||||
|
||||
@ -25,6 +26,22 @@ function registerShortcuts(win, options) {
|
||||
_registerLocalShortcut(win, "CommandOrControl+F", search);
|
||||
_registerLocalShortcut(win, "CommandOrControl+L", search);
|
||||
|
||||
if (is.linux()) {
|
||||
try {
|
||||
const player = setupMPRIS();
|
||||
|
||||
player.on("raise", () => {
|
||||
win.setSkipTaskbar(false);
|
||||
win.show();
|
||||
});
|
||||
player.on("playpause", playPause);
|
||||
player.on("next", next);
|
||||
player.on("previous", previous);
|
||||
} catch (e) {
|
||||
console.warn("Error in MPRIS", e);
|
||||
}
|
||||
}
|
||||
|
||||
const { global, local } = options;
|
||||
(global || []).forEach(({ shortcut, action }) => {
|
||||
console.debug("Registering global shortcut", shortcut, ":", action);
|
||||
|
||||
19
plugins/shortcuts/mpris.js
Normal file
19
plugins/shortcuts/mpris.js
Normal file
@ -0,0 +1,19 @@
|
||||
const mpris = require("mpris-service");
|
||||
|
||||
function setupMPRIS() {
|
||||
const player = mpris({
|
||||
name: "youtube-music",
|
||||
identity: "YouTube Music",
|
||||
canRaise: true,
|
||||
supportedUriSchemes: ["https"],
|
||||
supportedMimeTypes: ["audio/mpeg"],
|
||||
supportedInterfaces: ["player"],
|
||||
desktopEntry: "youtube-music",
|
||||
});
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setupMPRIS,
|
||||
};
|
||||
Reference in New Issue
Block a user