From c0158234d046381a6bc8c004c82577576977d0d7 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 4 May 2003 03:22:46 +0000 Subject: 2003-05-03 Havoc Pennington * dbus/dbus-watch.c (dbus_watch_handle): warn and return if a watch is invalid when handled * tools/Makefile.am, tools/dbus-launch.c, tools/dbus-launch.1: add dbus-launch utility to launch the bus from a shell script. Didn't actually implement dbus-launch yet, it's just a placeholder still. --- tools/Makefile.am | 8 +++-- tools/dbus-launch.1 | 54 ++++++++++++++++++++++++++++++++ tools/dbus-launch.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 tools/dbus-launch.1 create mode 100644 tools/dbus-launch.c (limited to 'tools') diff --git a/tools/Makefile.am b/tools/Makefile.am index 868b5028..c33caae7 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -6,7 +6,7 @@ else GLIB_TOOLS= endif -bin_PROGRAMS=dbus-send $(GLIB_TOOLS) +bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus_send_SOURCES= \ dbus-send.c @@ -14,8 +14,12 @@ dbus_send_SOURCES= \ dbus_monitor_SOURCES= \ dbus-monitor.c +dbus_launch_SOURCES= \ + dbus-launch.c + dbus_send_LDADD= $(top_builddir)/dbus/libdbus-1.la dbus_monitor_LDADD= $(top_builddir)/glib/libdbus-glib-1.la +dbus_launch_LDADD= $(top_builddir)/dbus/libdbus-1.la -man_MANS = dbus-send.1 dbus-monitor.1 +man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 EXTRA_DIST = $(man_MANS) diff --git a/tools/dbus-launch.1 b/tools/dbus-launch.1 new file mode 100644 index 00000000..9342423d --- /dev/null +++ b/tools/dbus-launch.1 @@ -0,0 +1,54 @@ +.\" +.\" dbus-launch manual page. +.\" Copyright (C) 2003 Red Hat, Inc. +.\" +.TH dbus-launch 1 +.SH NAME +dbus-launch \- Utility to start a message bus from a shell script +.SH SYNOPSIS +.PP +.B dbus-launch [\-\-version] [\-\-exit-with-session] + +.SH DESCRIPTION + +The \fIdbus-launch\fP command is used to start \fIdbus-daemon-1\fP +from a shell script. It would normally be called from a user's login +scripts. Unlike the daemon itself, \fIdbus-launch\fP exits, so +backticks or the $() construct can be used to read information from +\fIdbus-launch\fP. \fIdbus-launch\fP prints information about the +launched daemon in KEY=VALUE format. + +.PP +See http://www.freedesktop.org/software/dbus/ for more information +about D-BUS. See also the man page for \fIdbus-daemon-1\fP. + +.PP +Here is an example of how to use \fIdbus-launch\fP with an +sh-compatible shell: +.nf + + VARIABLES=`dbus-launch` + eval $VARIABLES + echo "D-BUS per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" + +.fi + +.SH OPTIONS +The following options are supported: +.TP +.I "--exit-with-session" +If this option is provided, a persistent "babysitter" process will be +created that watches stdin for HUP and tries to connect to the X +server. If this process gets a HUP on stdin or loses its X connection, +it kills the message bus daemon. + +.TP +.I "--version" +Print the version of dbus-launch + +.SH AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + +.SH BUGS +Please send bug reports to the D-BUS mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c new file mode 100644 index 00000000..b21c7e9d --- /dev/null +++ b/tools/dbus-launch.c @@ -0,0 +1,89 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-launch.c dbus-launch utility + * + * Copyright (C) 2003 Red Hat, Inc. + * + * Licensed under the Academic Free License version 1.2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DBUS_BUILD_X11 +#include +#endif + +static void +usage (void) +{ + fprintf (stderr, "dbus-launch [--version] [--exit-with-session]\n"); + exit (1); +} + +static void +version (void) +{ + printf ("D-BUS Message Bus Launcher %s\n" + "Copyright (C) 2003 Red Hat, Inc.\n" + "This is free software; see the source for copying conditions.\n" + "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", + VERSION); + exit (0); +} + +int +main (int argc, char **argv) +{ + const char *prev_arg; + dbus_bool_t exit_with_session; + int i; + + exit_with_session = FALSE; + + prev_arg = NULL; + i = 1; + while (i < argc) + { + const char *arg = argv[i]; + + if (strcmp (arg, "--help") == 0 || + strcmp (arg, "-h") == 0 || + strcmp (arg, "-?") == 0) + usage (); + else if (strcmp (arg, "--version") == 0) + version (); + else if (strcmp (arg, "--exit-with-session") == 0) + exit_with_session = TRUE; + else + usage (); + + prev_arg = arg; + + ++i; + } + + + + return 0; +} -- cgit