Add mpris support

This commit is contained in:
Manish
2021-09-02 16:00:42 +05:30
parent fe0f213919
commit e255777283
4 changed files with 214 additions and 3 deletions

View File

@ -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);