Skip to content
D-bus protocol client and server for node.js written in native javascript
Branch: master
Clone or download
sidorares Merge pull request #254 from iczero/fix-property-getters
Fix issue where getter for properties would return undefined
Latest commit 19cfe9d Nov 29, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Add support for xml2js beyond 0.1 and attempt some kind of unit testi… Jun 16, 2018
examples Replace two top level lets with const in examples Nov 20, 2017
lib Fix issue where getter for properties would return undefined Nov 29, 2018
test Add support for xml2js beyond 0.1 and attempt some kind of unit testi… Jun 16, 2018
.eslintrc Fix message serials Mar 23, 2018
.travis.yml Update travis node version configuration Oct 18, 2017 Rename CHANGELOG for now Jun 19, 2018
index.js fix: error object not being passed to emit Jan 8, 2018
package-lock.json 0.4.0 Nov 28, 2018
package.json 0.4.0 Nov 28, 2018


Greenkeeper badge D-bus protocol client and server for node.js

Build Status


npm install dbus-native


git clone # clone the repo
cd node-dbus
npm install # install dependencies
sudo cp examples/com.github.sidorares.dbus.Example.conf /etc/dbus-1/system.d/ # if you want to test examples/service.js


Short example using desktop notifications service

var dbus = require('dbus-native');
var sessionBus = dbus.sessionBus();
    'org.freedesktop.Notifications', function(err, notifications) {

    // dbus signals are EventEmitter events
    notifications.on('ActionInvoked', function() {
        console.log('ActionInvoked', arguments);
    notifications.on('NotificationClosed', function() {
        console.log('NotificationClosed', arguments);
    notifications.Notify('exampl', 0, '', 'summary 3', 'new message text', ['xxx yyy', 'test2', 'test3', 'test4'], [],  5, function(err, id) {
       //setTimeout(function() { n.CloseNotification(id, console.log); }, 4000);


Low level messaging: bus connection

connection = dbus.createClient(options)


  • socket - unix socket path
  • port - TCP port
  • host - TCP host
  • busAddress - encoded bus address. Default is DBUS_SESSION_BUS_ADDRESS environment variable. See
  • authMethods - array of authentication methods, which are attempted in the order provided (default:['EXTERNAL', 'DBUS_COOKIE_SHA1', 'ANONYMOUS'])
  • ayBuffer - boolean (default:true): if true 'ay' dbus fields are returned as buffers
  • ReturnLongjs - boolean (default:false): if true 64 bit dbus fields (x/t) are read out as Long.js objects, otherwise they are converted to numbers (which should be good up to 53 bits)
  • ( TODO: add/document option to use adress from X11 session )

connection has only one method, message(msg)

message fields:

  • type - methodCall, methodReturn, error or signal
  • path - object path
  • interface
  • destination
  • sender
  • member
  • serial
  • signature
  • body
  • errorName
  • replySerial

connection signals:

  • connect - emitted after successful authentication
  • message
  • error


var dbus = require('dbus-native');
var conn = dbus.createConnection();
    destination: 'org.freedesktop.DBus',
    'interface': 'org.freedesktop.DBus',
    member: 'Hello',
    type: dbus.messageType.methodCall
conn.on('message', function(msg) { console.log(msg); });

Note on INT64 'x' and UINT64 't'

Long.js is used for 64 Bit support. The following javascript types can be marshalled into 64 bit dbus fields:

  • typeof 'number' up to 53bits
  • typeof 'string' (consisting of decimal digits with no separators or '0x' prefixed hexadecimal) up to full 64bit range
  • Long.js objects (or object with compatible properties)

By default 64 bit dbus fields are unmarshalled into a 'number' (with precision loss beyond 53 bits). Use {ReturnLongjs:true} option to return the actual Long.js object and preserve the entire 64 bits.


You can’t perform that action at this time.