Package selection guidance compiled from public package information, community data, and project usage.
A native Dart implementation of the D-Bus message bus client, enabling Dart applications to directly communicate with Linux desktop services. This package provides low-level access to D-Bus, allowing interaction with system and application services such as session management, hardware events, and desktop integration. It is designed for developers building desktop applications on Linux, with support for Windows and macOS through compatible D-Bus implementations. The library offers a clean, Dart-native API for sending and receiving messages over D-Bus.
Use cases
Interacting with Linux system services
Integrating desktop features in Dart apps
Accessing hardware and session events
Building cross-platform desktop utilities
Enabling communication with other desktop applications
You can then use the generated test-remote-object.dart to access that remote object from your program:
import'package:dbus/dbus.dart';
import'test-remote-object.dart';
Future<void> main() async {
var client = DBusClient.session();
var object = ComExampleTestObject(client, 'com.example.Test');
var version = await object.getVersion();
print('version: $version');
var reversedText = await object.callReverseText('Hello World');
print(reversedText);
await client.close();
}
The code generated by dart-dbus may not be the cleanest API you want to expose for your service. It is recommended that you use the generated code as a starting point and then modify it as necessary.
Exporting local objects
The above interface definition can also be processed to generate a class for exporting this object.
You can also choose to access D-Bus objects directly without interface definitions and dbus-dart.
This requires writing more code and handing more error cases.
The following code shows how to access the remote object in the above examples:
import'package:dbus/dbus.dart';
Future<void> main() async {
var client = DBusClient.session();
var object = DBusRemoteObject(client, name: 'com.example.Test', path: DBusObjectPath('/com/example/Test/Object'));
var value = await object.getProperty('com.example.Test', 'Version', signature: DBusSignature('s'));
var version = value.asString();
print('version: $version');
var response = await object.callMethod('com.example.Test', 'ReverseText', [DBusString('Hello World')], replySignature: DBusSignature('s'));
var reversedText = response.values[0].asString();
print('$reversedText');
await client.close();
}
And the following shows how to export that object: