mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-11 05:58:03 +02:00
DBUS_ENABLE_X11_AUTOLAUNCH obviously requires DBUS_BUILD_X11. However, the converse is not true. If DBUS_BUILD_X11 is defined, dbus-launch will be able to connect to the X server to determine when the session ends; most distributors will want this, but it can be disabled with the standard Autoconf option --without-x. If DBUS_ENABLE_X11_AUTOLAUNCH is *also* defined, dbus-launch and libdbus will be willing to perform autolaunch. Again, most distributors will want this, but it can be disabled with --disable-x11-autolaunch. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19997 Reviewed-by: Colin Walters <walters@verbum.org>
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <dbus/dbus.h>
|
|
#include "dbus/dbus-sysdeps.h"
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
DBusConnection *conn = NULL;
|
|
DBusError error;
|
|
|
|
_dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL);
|
|
|
|
dbus_error_init (&error);
|
|
|
|
conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
|
|
|
|
#ifdef DBUS_ENABLE_X11_AUTOLAUNCH
|
|
if (dbus_error_is_set (&error))
|
|
{
|
|
fprintf (stderr, "*** Failed to autolaunch session bus: %s\n",
|
|
error.message);
|
|
dbus_error_free (&error);
|
|
return 1;
|
|
}
|
|
#else
|
|
/* We don't necessarily expect it to *work* without X (although it might -
|
|
* for instance on Mac OS it might have used launchd). Just check that the
|
|
* results are consistent. */
|
|
|
|
if (dbus_error_is_set (&error) && conn != NULL)
|
|
{
|
|
fprintf (stderr, "*** Autolaunched session bus, but an error was set!\n");
|
|
return 1;
|
|
}
|
|
#endif
|
|
|
|
if (!dbus_error_is_set (&error) && conn == NULL)
|
|
{
|
|
fprintf (stderr, "*** Failed to autolaunch session bus but no error was set\n");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|