How to use the dbus-next.sessionBus function in dbus-next

To help you get started, we’ve selected a few dbus-next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github headsetapp / headset-electron / src / lib / mediaKeys / linux.js View on Github external
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();
  });
};
github Superjo149 / auryo / src / main / features / linux / dbusService.ts View on Github external
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);
    }
github MarshallOfSound / Google-Play-Music-Desktop-Player-UNOFFICIAL- / src / main / features / linux / mediaKeysDBus.js View on Github external
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
}
github dbusjs / mpris-service / src / index.js View on Github external
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) {
github Sn8z / Poddr / utils / dbus.js View on Github external
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);
	}
};