From fb9f7d5eb9aed703adf4daae64d17398e45bb1e6 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Wed, 22 Feb 2012 14:10:58 +0900 Subject: [PATCH] Added --daemon option and .service file --- data/Makefile.am | 6 ++++++ data/org.xfce.AppFinder.service.in | 3 +++ src/main.c | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 data/org.xfce.AppFinder.service.in diff --git a/data/Makefile.am b/data/Makefile.am index 2d232b4..0c9a3ad 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -6,6 +6,12 @@ apps_in_files = \ apps_DATA = $(apps_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ +servicedir = $(datadir)/dbus-1/services +service_in_files = org.xfce.AppFinder.service.in +service_DATA = $(service_in_files:.service.in=.service) +%.service: %.service.in + $(AM_V_GEN) sed -e "s,\@bindir\@,$(bindir),g" < $< > $@ + EXTRA_DIST = \ $(apps_in_files) diff --git a/data/org.xfce.AppFinder.service.in b/data/org.xfce.AppFinder.service.in new file mode 100644 index 0000000..0e292f2 --- /dev/null +++ b/data/org.xfce.AppFinder.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.xfce.Appfinder +Exec=@bindir@/xfce4-appfinder --daemon diff --git a/src/main.c b/src/main.c index 3c2cdb8..52dbf1d 100644 --- a/src/main.c +++ b/src/main.c @@ -59,6 +59,7 @@ static gboolean opt_version = FALSE; static gboolean opt_replace = FALSE; static gboolean opt_quit = FALSE; static gboolean opt_disable_server = FALSE; +static gboolean opt_daemon = FALSE; static GSList *windows = NULL; static gboolean service_owner = FALSE; static XfceAppfinderModel *model_cache = NULL; @@ -77,6 +78,7 @@ static GOptionEntry option_entries[] = { "replace", 'r', 0, G_OPTION_ARG_NONE, &opt_replace, N_("Replace the existing service"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &opt_quit, N_("Quit all instances"), NULL }, { "disable-server", 0, 0, G_OPTION_ARG_NONE, &opt_disable_server, N_("Do not try to use or become a D-Bus service"), NULL }, + { "daemon", 0, 0, G_OPTION_ARG_NONE, &opt_daemon, N_("Start a D-Bus service without opening any windows."), NULL }, { NULL } }; @@ -168,7 +170,8 @@ appfinder_window_destroyed (GtkWidget *window) /* check if we're going to the background * if the last window is closed */ - if (windows == NULL) + /* don't leave when started with a --daemon option */ + if (windows == NULL && !opt_daemon) { if (!service_owner) { @@ -550,7 +553,8 @@ main (gint argc, gchar **argv) /* become the serivce owner or ask the current * owner to spawn an instance */ - if (G_LIKELY (!opt_disable_server)) + /* --daemon takes precedence over --disable-server */ + if (G_LIKELY (!opt_disable_server || opt_daemon)) dbus_connection = appfinder_dbus_service (startup_id); /* if the value is unset, fallback to XFCE, if the @@ -574,8 +578,12 @@ main (gint argc, gchar **argv) appfinder_refcount_debug_init (); #endif - /* create initial window */ - appfinder_window_new (NULL, !opt_collapsed); + /* don't open a window if --daemon is used */ + if (G_LIKELY (!opt_daemon)) + { + /* create initial window */ + appfinder_window_new (NULL, !opt_collapsed); + } APPFINDER_DEBUG ("enter mainloop"); -- 1.7.5.4