init method
Start the runner and listen for queries.
Implementation
Future<void> init() async {
final client = DBusClient.session();
DBusRequestNameReply result;
try {
result = await client.requestName(
identifier,
flags: {
DBusRequestNameFlag.allowReplacement,
DBusRequestNameFlag.doNotQueue,
DBusRequestNameFlag.replaceExisting,
},
);
} catch (e) {
print('Unable to get DBus name for this runner: $e');
exit(1);
}
if (result != DBusRequestNameReply.primaryOwner) {
print('Unable to get DBus name for this runner: $result');
exit(1);
} else {
print('Got DBus ownership for this runner, proceeding to activate.');
}
await client.registerObject(
KRunnerDBusInterface(
name,
matchQueryCallback: matchQuery,
retrieveActionsCallback: retrieveActions,
runActionCallback: runAction,
),
);
}