Skip to content

Commit 3d73772

Browse files
authored
Update README.md
1 parent 51d7cf5 commit 3d73772

File tree

1 file changed

+57
-38
lines changed

1 file changed

+57
-38
lines changed

README.md

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,68 @@ the new API.
2323

2424
### General
2525

26-
**Node-gyp**
27-
`$ npm install -g node-gyp`
28-
[https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
26+
* **Node-gyp**
2927

30-
**libdbus**
31-
`$ sudo apt-get install libdbus-1-dev`
32-
or equivalent for your system
28+
```bash
29+
$ npm install -g node-gyp
30+
```
3331

34-
**glib2.0**
35-
`$ sudo apt-get install libglib2.0-dev`
36-
or equivalent for your system
32+
[https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
33+
34+
* **libdbus**
35+
36+
```bash
37+
$ sudo apt-get install libdbus-1-dev
38+
```
39+
40+
or equivalent for your system
41+
42+
* **glib2.0**
43+
44+
```bash
45+
$ sudo apt-get install libglib2.0-dev
46+
```
47+
48+
or equivalent for your system
3749

3850
### MacOS with MacPorts/HomeBrew
3951

40-
**Node-gyp**
41-
`$ npm install -g node-gyp`
42-
[https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
52+
* **Node-gyp**
53+
54+
```bash
55+
$ npm install -g node-gyp
56+
```
57+
58+
[https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
4359

44-
**libdbus**
45-
MacPorts: `$ sudo port install pkg-config dbus`
46-
HomeBrew: `$ sudo brew install pkg-config dbus`
60+
* **libdbus**
61+
MacPorts: `$ sudo port install pkg-config dbus`
62+
HomeBrew: `$ sudo brew install pkg-config dbus`
4763

48-
**glib2.0**
49-
MacPorts: `$ sudo port install glib2`
50-
HomeBrew: `$ sudo brew install glib`
64+
* **glib2.0**
65+
MacPorts: `$ sudo port install glib2`
66+
HomeBrew: `$ sudo brew install glib`
5167

5268
## Getting Started
69+
5370
Best way to get started is by looking at the examples. After the build:
5471

5572
1. Navigate to `path/to/dbus/examples` folder
56-
1. Run `node service.js &`
57-
1. Run `node hello.js`
73+
2. Run `node service.js &`
74+
3. Run `node hello.js`
5875

5976
Work your way through other examples to explore supported functionality.
6077

6178
## Note on systems without X11
79+
6280
If no X server is running, the module fails when attempting to obtain a D-Bus
6381
connection at `DBus.getBus()`. This can be remedied by setting two environment
6482
variables manually (the actual bus address might be different):
6583

66-
process.env.DISPLAY = ':0';
67-
process.env.DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/dbus/system_bus_socket';
68-
84+
```javascript
85+
process.env.DISPLAY = ':0';
86+
process.env.DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/dbus/system_bus_socket';
87+
```
6988

7089
## API
7190

@@ -83,7 +102,7 @@ bus or `"session"` to connect to the session bus.
83102

84103
Returns a `Bus`.
85104

86-
```
105+
```javascript
87106
var bus = DBus.getBus('session');
88107
```
89108

@@ -102,15 +121,15 @@ registered._
102121

103122
Returns a `Service`.
104123

105-
```
124+
```javascript
106125
var service = DBus.registerService('session', 'com.example.Library');
107126
```
108127

109128
#### *DEPRECATED* `new DBus()`
110129

111130
Create a new DBus instance.
112131

113-
```
132+
```javascript
114133
var DBus = require('dbus')
115134
var dbus = new DBus()
116135
```
@@ -140,7 +159,7 @@ Get an existing object's interface from a well-known service.
140159
Once retrieved, `callback` will be called with either an error or with an
141160
`Interface`.
142161

143-
```
162+
```javascript
144163
bus.getInterface('com.example.Library', '/com/example/Library/authors/DAdams', 'com.example.Library.Author1', function(err, interface) {
145164
if (err) {
146165
...
@@ -169,7 +188,7 @@ Get the value of a property.
169188
Once retrieved `callback` will be called with either an error or with the value
170189
of the property.
171190

172-
```
191+
```javascript
173192
interface.getProperty('Name', function(err, name) {
174193
});
175194
```
@@ -184,7 +203,7 @@ Set the value of a property.
184203

185204
Once set `callback` will be called with either an error or nothing.
186205

187-
```
206+
```javascript
188207
interface.setProperty('Name', 'Douglas Adams', function(err) {
189208
});
190209
```
@@ -199,7 +218,7 @@ Once retrieved `callback` will be called with either an error or with an object
199218
where the keys are the names of the properties, and the values are the values
200219
of those properties.
201220

202-
```
221+
```javascript
203222
interface.getProperties(function(err, properties) {
204223
console.log(properties.Name);
205224
});
@@ -219,7 +238,7 @@ Call a method on the interface.
219238
Once executed, `callback` will be called with either an error or with the
220239
result of the method call.
221240

222-
```
241+
```javascript
223242
interface.AddBook("The Hitchhiker's Guide to the Galaxy", { timeout: 1000 }, function(err, result) {
224243
})
225244
```
@@ -237,7 +256,7 @@ Create an object that is exposed over DBus.
237256

238257
Returns a `ServiceObject`.
239258

240-
```
259+
```javascript
241260
var object = service.createObject('/com/example/Library/authors/DAdams');
242261
```
243262

@@ -270,7 +289,7 @@ Create an interface on an object.
270289

271290
Returns a `ServiceInterface`.
272291

273-
```
292+
```javascript
274293
var interface = object.createInterface('com.example.Library.Author1');
275294
```
276295

@@ -289,7 +308,7 @@ An interface for an object that is exposed over DBus.
289308

290309
Add a method that can be called over DBus.
291310

292-
```
311+
```javascript
293312
interface.addMethod('AddBook', {
294313
in: [DBus.Define(String), DBus.Define(Number)],
295314
out: [DBus.Define(Number)]
@@ -314,7 +333,7 @@ interface.addMethod('AddBook', {
314333

315334
Add a property that can be get, and/or optionally set, over DBus.
316335

317-
```
336+
```javascript
318337
interface.addProperty('BooksWritten', {
319338
type: DBus.Define(Number),
320339
getter: function(callback) {
@@ -348,7 +367,7 @@ interface.addProperty('Name', {
348367
349368
Create a DBus signal.
350369
351-
```
370+
```javascript
352371
interface.addSignal('bookCreated', {
353372
types: [DBus.Define(Object)]
354373
});
@@ -361,7 +380,7 @@ interface.addSignal('bookCreated', {
361380
362381
Emit a signal
363382
364-
```
383+
```javascript
365384
interface.emit('bookCreated', { name: "The Hitchhiker's Guide to the Galaxy" })
366385
```
367386
@@ -383,7 +402,7 @@ A DBus-specific error
383402
384403
Create a new error. The name must be a valid error name.
385404
386-
```
405+
```javascript
387406
throw new DBus.Error('com.example.Library.Error.BookExistsError', 'The book already exists');
388407
```
389408

0 commit comments

Comments
 (0)