Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (win) => {
logger.media('Registering media Keys');
try {
const bus = DBus.sessionBus();
registerBindings(win, 'gnome', bus);
registerBindings(win, 'gnome3', bus);
registerBindings(win, 'mate', bus);
} catch (error) {
console.error(error);
}
// Register shortcut key to open Developer Tools
globalShortcut.register('CommandOrControl+Shift+I', () => {
logger.info('Opening Developer Tools');
win.webContents.openDevTools();
});
};
async register() {
try {
dbus.setBigIntCompat(true);
const session = dbus.sessionBus();
try {
await this.registerBindings('gnome', session);
} catch (err) {
// ignore
}
try {
await this.registerBindings('mate', session);
} catch (err) {
// ignore
}
} catch (e) {
this.logger.error(e);
}
const interfaceLegacy = legacy.getInterface(`org.${desktopEnv}.SettingsDaemon.MediaKeys`);
interfaceLegacy.on('MediaPlayerKeyPressed', listener);
app.on('browser-window-focus', () => {
interfaceLegacy.GrabMediaPlayerKeys('GPMDP', 0); // eslint-disable-line
});
const future = await session.getProxyObject(`org.${desktopEnv}.SettingsDaemon.MediaKeys`, `/org/${desktopEnv}/SettingsDaemon/MediaKeys`);
const interfaceFuture = future.getInterface(`org.${desktopEnv}.SettingsDaemon.MediaKeys`);
interfaceFuture.on('MediaPlayerKeyPressed', listener);
app.on('browser-window-focus', () => {
interfaceFuture.GrabMediaPlayerKeys('GPMDP', 0); // eslint-disable-line
});
}
try {
const session = dbus.sessionBus();
registerBindings('gnome', session);
registerBindings('mate', session);
} catch (e) {
// Do nothing
}
Player.prototype.init = function(opts) {
this.serviceName = `org.mpris.MediaPlayer2.${this.name}`;
dbus.validators.assertBusNameValid(this.serviceName);
this._bus = dbus.sessionBus();
this._bus.on('error', (err) => {
this.emit('error', err);
});
this.interfaces = {};
this._addRootInterface(this._bus, opts);
if (this.supportedInterfaces.indexOf('player') >= 0) {
this._addPlayerInterface(this._bus);
}
if (this.supportedInterfaces.indexOf('trackList') >= 0) {
this._addTracklistInterface(this._bus);
}
if (this.supportedInterfaces.indexOf('playlists') >= 0) {
default:
return;
}
});
app.on("browser-window-focus", () => {
log.info("Main Process :: Grabbing Mediakeys.");
mediaKeys.GrabMediaPlayerKeys("org." + desktop + ".SettingsDaemon.MediaKeys", 0);
});
}).catch((error) => {
log.error("ERROR " + error);
});
};
try {
log.info("Main Process :: Registering mediakey bindings using DBUS.");
const bus = dbus.sessionBus();
registerDbus("gnome", bus);
registerDbus("mate", bus);
} catch (error) {
log.error("Main Process :: " + error);
}
};