Skip to content

DBus Specification

KYЯΛ edited this page Jan 14, 2023 · 3 revisions

Lodestar provides a public API over DBus for interfacing with it's various functions. This can be done using tools like dbus-send or language-specific libraries.

Lodestar can either hose it's own peer at tcp://localhost:44881 to receive connections or connect to the session bus if there is one available. By default, the daemon will try to connect to the session bus on *nix and host a peer on Windows. This is user configurable in the settings.json however.

Objects

The base path for the exposed objects is /org/mercurius/

Object Path Description
Profiles /org/mercurius/{name} Loaded profiles are each exposed as individual objects with their name being the {name}.profile.json part of the filename
Profile Messenger org/mercurius/ProfileManager The object used to do meta-management of profiles (create,delete,list, etc.)

Example

(Using theTmds.Dbus implementation of the DBus protocol for C#.)

This uwu.profile.json is file is an example of a client-side profile called 'uwu' with minecraft version 1.19.2 for Fabric loader. The profile contains one mod: Sodium version 0.4.4. (For further explanation read the profiles page of the docs)

{
  "Name": "uwu",
  "MinecraftVersion": "1.19.2",
  "ServerSide": false,
  "Loader": 1,
  "Mods": [
    {
      "Title": "Sodium",
      "FileName": "sodium-fabric-mc1.19.2-0.4.4\u002Bbuild.18.jar",
      "DownloadURL": "https://cdn.modrinth.com/data/AANobbMI/versions/rAfhHfow/sodium-fabric-mc1.19.2-0.4.4%2Bbuild.18.jar",
      "ProjectId": "AANobbMI",
      "VersionId": "rAfhHfow",
      "MinecraftVersion": "1.19.2",
      "ModVersion": "mc1.19.2-0.4.4",
      "Loaders": [
        2,
        3
      ],
      "DependencyVersions": [],
      "ClientDependency": 0
    }
  ],
  "Path": "/home/kyra/.mercurius/Profiles/uwu.profile.json"
}

We make a method call over DBus to GetProfileData (takes no args) that returns a struct with some basic profile data:

using Tmds.DBus;
using mercurius.DBus;

ObjectPath path = new ObjectPath("/org/mercurius/profile/uwu"); 

using (Connection client = new Connection("tcp:host=localhost,port=44881"))  {
    await client.ConnectAsync(); // Connect to the DBus client
    System.Console.WriteLine("Client connected");
    var proxy = client.CreateProxy<IDbusProfile>("org.mercurius.profile", path); // Create an instance of IDbusProfile that is used to proxy the DBus object

    var info = await proxy.GetProfileInfoAsync(); // Make method call

    Console.Write("Profile {0}:\n  MC Version: {1}\n  Mod Loader: {2}\n  File Path: {3}", // Print response
        info.Name, info.MinecraftVersion, info.Loader, info.FilePath);            
}

Output:

Client connected
Profile uwu:
  MC Version: 1.19.2
  Mod Loader: fabric
  File Path: /home/kyra/.mercurius/Profiles/uwu.profile.json
Clone this wiki locally