Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Tags:

c++

qt

dbus

qtdbus

I have a QT/C++ terminal application which binds to D-Bus, but when I attempt to bind on the session bus I'm getting the following error:

"Unable to autolaunch a dbus-daemon without a $DISPLAY for X11"

This is just a simple terminal application, code snippet:

if (!QDBusConnection::sessionBus().isConnected()) {
    fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
                    "To start it, run:\n"
                    "\teval `dbus-launch --auto-syntax`\n");
    fprintf(stderr, "%s\n",
            qPrintable(QDBusConnection::sessionBus().lastError().message()));
    return 1;
}

I don't need X11 support, so I'm just looking for the easiest way to deal with this error

like image 261
RandomUser Avatar asked Jul 31 '15 23:07

RandomUser


1 Answers

For anyone who is interested, I just set env variables from within the program:

setenv("DISPLAY", ":0", true);
like image 200
RandomUser Avatar answered Nov 02 '22 21:11

RandomUser