patches/gnome-settings-daemon-08-find-xrdb.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 15054 240f8afbe6c8
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.

/jds/bin/diff -uprN gnome-settings-daemon-2.25.90.old/plugins/xrdb/gsd-xrdb-manager.c gnome-settings-daemon-2.25.90/plugins/xrdb/gsd-xrdb-manager.c
--- gnome-settings-daemon-2.25.90.old/plugins/xrdb/gsd-xrdb-manager.c	2009-02-10 19:24:58.047186000 +0000
+++ gnome-settings-daemon-2.25.90/plugins/xrdb/gsd-xrdb-manager.c	2009-02-10 19:26:38.849890000 +0000
@@ -420,11 +420,22 @@ spawn_with_input (const char *command,
         g_child_watch_add (child_pid, (GChildWatchFunc) child_watch_cb, (gpointer)command);
 }
 
+#define XRDB_COMMAND_NAME       "xrdb"
+#define XRDB_COMMAND_FORMAT_STR "%s -merge"
+
+static char*    xrdb_known_dirs[] = {
+    "/usr/openwin/bin",
+    "/usr/X11R6/bin",
+    "/usr/X11/bin",
+    NULL
+};
+
 static void
 apply_settings (GsdXrdbManager *manager,
                 GtkStyle       *style)
 {
-        const char *command;
+        char       *command;
+        char       *command_path;
         GString    *string;
         GSList     *list;
         GSList     *p;
@@ -432,7 +443,27 @@ apply_settings (GsdXrdbManager *manager,
 
         gnome_settings_profile_start (NULL);
 
-        command = "xrdb -merge -quiet";
+        if ( (command_path = g_find_program_in_path( XRDB_COMMAND_NAME )) == NULL ) {
+            g_warning("Couldn't find xrdb in path");
+            /* Search in well-known dirs */
+            for ( int i = 0; xrdb_known_dirs[i] != NULL; i++ ) {
+                gchar* path = g_build_filename( xrdb_known_dirs[i], XRDB_COMMAND_NAME, NULL );
+                if ( path && (command_path = g_find_program_in_path( path )) != NULL  ) {
+                    /* Got a match, so break and use command_path */
+                    g_warning("Found xrdb as : %s", command_path );
+                    g_free(path);
+                    break;
+                }
+                g_free(path);
+            }
+        }
+
+        if ( command_path != NULL ) {
+            command = g_strdup_printf( XRDB_COMMAND_FORMAT_STR, command_path );
+        }
+        else {
+            command = g_strdup( XRDB_COMMAND_NAME );
+        }
 
         string = g_string_sized_new (256);
         append_theme_colors (style, string);
@@ -475,6 +506,9 @@ apply_settings (GsdXrdbManager *manager,
 
         gnome_settings_profile_end (NULL);
 
+    
+        g_free (command);
+
         return;
 }