A D-Bus binding for Node
npm install dbus

!GitHub contributors
!GitHub last commit
!npm
``bash`
$ npm install dbus
or npm install.Migrating to version 1.0
The API changed between version 0.2.21 and version 1.0.0. See
[migrating][migrating] for information on how to migrate your application to
the new API.
Dependencies
$3
* Node-gyp
`bash
$ npm install -g node-gyp
` https://www.npmjs.com/package/node-gyp
* libdbus
`bash
$ sudo apt-get install libdbus-1-dev
` or equivalent for your system
* glib2.0
`bash
$ sudo apt-get install libglib2.0-dev
`
or equivalent for your system$3
* Node-gyp
`bash
$ npm install -g node-gyp
` https://www.npmjs.com/package/node-gyp
* libdbus
MacPorts:
$ sudo port install pkg-config dbus
HomeBrew: $ sudo brew install pkg-config dbus* glib2.0
MacPorts:
$ sudo port install glib2
HomeBrew: $ sudo brew install glibGetting Started
Best way to get started is by looking at the examples. After the build:
1. Navigate to
path/to/dbus/examples folder
2. Run node service.js &
3. Run node hello.jsWork your way through other examples to explore supported functionality.
Note on systems without X11
If no X server is running, the module fails when attempting to obtain a D-Bus
connection at
DBus.getBus(). This can be remedied by setting two environment
variables manually (the actual bus address might be different):`javascript
process.env.DISPLAY = ':0';
process.env.DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/dbus/system_bus_socket';
`API
$3
The root object of this module.
####
DBus.getBus(busName)* busName
Connect to a bus.
busName must be either "system" to connect to the system
bus or "session" to connect to the session bus.Returns a
Bus.`javascript
var bus = DBus.getBus('session');
`####
DBus.registerService(busName, serviceName)* busName
* serviceName Register a service on a specific bus. This allows the caller to create a DBus
service.
busName must be either "system" to create the service on the system bus, or
"session" to create the service on the session bus. _Note: the system bus
often has security requirements that need to be met before the service can be
registered._Returns a
Service.`javascript
var service = DBus.registerService('session', 'com.example.Library');
`#### DEPRECATED
new DBus()Create a new DBus instance.
`javascript
var DBus = require('dbus')
var dbus = new DBus()
`#### DEPRECATED
DBus.prototype.getBus(busName)Use
DBus.getBus(busName).#### DEPRECATED
DBus.prototype.registerService(busName, serviceName)Use
DBus.registerService(busName, serviceName)
$3
An active connection to one of DBus' buses.
####
Bus.prototype.getInterface(serviceName, objectPath, interfaceName, callback)* serviceName
- The well-known name of the service that owns the object.
* objectPath - The path of the object.
* interfaceName - Which of the object's interfaces to retrieve.
* callback Get an existing object's interface from a well-known service.
Once retrieved,
callback will be called with either an error or with an
Interface.`javascript
bus.getInterface('com.example.Library', '/com/example/Library/authors/DAdams', 'com.example.Library.Author1', function(err, interface) {
if (err) {
...
} // Do something with the interface
});
`####
Bus.prototype.disconnect()Disconnect from DBus. This disconnection makes it so that Node isn't kept
running based on this active connection. It also makes this bus, and all of its
children (interfaces that have been retrieved, etc.) unusable.
$3
####
Interface.prototype.getProperty(propertyName, callback)* propertyName
- The name of the property to get.
* callback Get the value of a property.
Once retrieved
callback will be called with either an error or with the value
of the property.`javascript
interface.getProperty('Name', function(err, name) {
});
`####
Interface.prototype.setProperty(propertyName, value, callback)* propertyName
- The name of the property to get.
* value - The value of the property to set.
* callback Set the value of a property.
Once set
callback will be called with either an error or nothing.`javascript
interface.setProperty('Name', 'Douglas Adams', function(err) {
});
`####
Interface.prototype.getProperties(callback)* callback
Get the value of all of the properties of the interface.
Once retrieved
callback will be called with either an error or with an object
where the keys are the names of the properties, and the values are the values
of those properties.`javascript
interface.getProperties(function(err, properties) {
console.log(properties.Name);
});
`####
Interface.prototypemethodName* methodName
- The name of the method on the interface to call.
* ...args - The arguments that must be passed to the method.
* options