/* Compiling:
 * gcc `pkg-config --cflags --libs dbus-1` pa-dbus-test.c -o pa-dbus-test
 */

#include <stdio.h>
#include <dbus/dbus.h>

int main(int argc, char *argv[]) {
        printf("Started.\n");
        if (argc < 2) {
                printf("Too few arguments!\n");
                return 1;
        }
        DBusConnection *connection = dbus_connection_open(argv[1], NULL);
        if (!connection) {
                printf("Connection failed!\n");
                return 1;
        }
        printf("Connected.\n");
        DBusMessage *message = dbus_message_new_method_call(NULL, "/org/pulseaudio/core1", "org.PulseAudio.Core1", "LoadModule");
        dbus_connection_send(connection, message, NULL);
        while (dbus_connection_read_write(connection, -1))
                ;
        return 0;
}