Permalink
Browse files

Merge branch 'master' of https://github.com/sidorares/node-dbus

  • Loading branch information...
2 parents 33652cd + ebe92ff commit 2864af52834cdaf4b81a6e8d908c1d168ef80599 @sidorares committed Dec 30, 2012
Showing with 21 additions and 22 deletions.
  1. +21 −22 README.md
View
@@ -5,6 +5,8 @@ D-bus protocol client and server for node.js
Installation
------------
+Important: install `socat` to be able to use session bus.
+
```shell
npm install dbus-native
```
@@ -20,27 +22,24 @@ sudo cp examples/com.github.sidorares.dbus.Example.conf /etc/dbus-1/system.d/ #
Usage
------
- var dbus = require('dbus-native');
- // TODO: docs for options
- var connection = dbus(options);
- // raw message: (everything else is wrapper around message)
- // same as dbus-send org.freedesktop.dbus /org/freedesktop/dbus Hello
- var cookie = connection.message({
- type: dbus.messageType.functionCall, // optional, default to functionCall
- // flags: // optional, default to no flags
- path: '/org/freedesktop/DBus',
- interface: 'org.freedesktop.DBus',
- destination: 'org.freedesktop.DBus'
- member: 'Hello'
+Short example using desktop notifications service
+
+```js
+var dbus = require('dbus-native');
+var sessionBus = dbus.sessionBus();
+sessionBus.getService('org.freedesktop.Notifications').getInterface(
+ '/org/freedesktop/Notifications',
+ '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);
});
-
- connection.on('message', function(message) {
- // handle reply
+ 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);
});
-
- // higher-level API:
- connection.invoke(..., callback);
-
- // TODO: introspection and proxies
-
-TODO: examples using dbus-send and corresponding dbus-native api.
+});
+```

0 comments on commit 2864af5

Please sign in to comment.