[Goodies-commits] r6929 - in xfce4-power-manager/trunk: . src

Ali Abdallah aliov at xfce.org
Mon Mar 16 23:48:19 CET 2009


Author: aliov
Date: 2009-03-16 22:48:19 +0000 (Mon, 16 Mar 2009)
New Revision: 6929

Modified:
   xfce4-power-manager/trunk/ChangeLog
   xfce4-power-manager/trunk/src/xfpm-main.c
Log:
Run as daemon by default unless no-daemon is specified

Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog	2009-03-16 22:27:10 UTC (rev 6928)
+++ xfce4-power-manager/trunk/ChangeLog	2009-03-16 22:48:19 UTC (rev 6929)
@@ -1,4 +1,7 @@
 
+2009-03-16 23:48 Ali aliov at xfce.org 
+	 * : Run as daemon by default unless no-daemon is specified
+
 2009-03-16 23:27 Ali aliov at xfce.org 
 	 * : Added freedesktop.PowerManagement power interfaces and methods
 

Modified: xfce4-power-manager/trunk/src/xfpm-main.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-main.c	2009-03-16 22:27:10 UTC (rev 6928)
+++ xfce4-power-manager/trunk/src/xfpm-main.c	2009-03-16 22:48:19 UTC (rev 6929)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <unistd.h>
+
 #include <gtk/gtk.h>
 #include <glib.h>
 
@@ -54,14 +56,16 @@
 {
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
 
-    static gboolean run     = FALSE;
-    static gboolean quit    = FALSE;
-    static gboolean config  = FALSE;
-    static gboolean version = FALSE;
+    gboolean run     = FALSE;
+    gboolean quit    = FALSE;
+    gboolean config  = FALSE;
+    gboolean version = FALSE;
+    gboolean no_daemon  = FALSE;
 
-    static GOptionEntry option_entries[] = 
+    GOptionEntry option_entries[] = 
     {
-	{ "run",'r', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,&run,NULL,NULL },
+	{ "run",'r', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &run, NULL, NULL },
+	{ "no-daemon",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL },
 	{ "customize", 'c', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &config, N_("Show the configuration dialog"), NULL },
 	{ "quit", 'q', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &quit, N_("Quit any running xfce power manager"), NULL },
 	{ "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL },
@@ -102,6 +106,11 @@
 	return EXIT_FAILURE;
     }
     
+    if ( no_daemon == FALSE && daemon(0,0) )
+    {
+	g_critical ("Could not daemonize");
+    }
+        
     DBusGConnection *bus;
     bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
     




More information about the Goodies-commits mailing list