]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[main] Try getting default theme from config file
authorRay Strode <rstrode@redhat.com>
Tue, 23 Mar 2010 20:46:56 +0000 (16:46 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 23 Mar 2010 20:46:56 +0000 (16:46 -0400)
Right now we figure out the default theme via a symlink.
This apprach is very simple, but is also a little cumbersome.

It means as the default theme is changed around we have to move
the symlink around.

The symlink is in /usr.  We really shouldn't be mucking with
/usr when changing defaults.

This commit checks the filesystem for two config files:

/usr/share/plymouth/plymouthd.defaults
and
/etc/plymouth/plymouthd.conf

The first one is for distributions to use.  This is how they can
manage which splash to show from release to release.

The second one is for system administrators.  This is how they
can override distribution policy.

We don't actually ship these files yet.  In the mean time,
(and even after for the forseeable future) the old symlink method
will still work.

configure.ac
src/Makefile.am
src/main.c

index a8ac587da881c8ad350c19ea1996b22c2e00c83f..b78e21f986feabd5750b77e14270cb595fae87ed 100644 (file)
@@ -204,6 +204,12 @@ AS_AC_EXPAND(PLYMOUTH_THEME_PATH, $plymouththemedir)
 plymouthplugindir=$libdir/plymouth/
 AS_AC_EXPAND(PLYMOUTH_PLUGIN_PATH, $plymouthplugindir)
 
+plymouthpolicydir=$datadir/plymouth/
+AS_AC_EXPAND(PLYMOUTH_POLICY_DIR, $plymouthpolicydir)
+
+plymouthconfdir=$sysconfdir/plymouth/
+AS_AC_EXPAND(PLYMOUTH_CONF_DIR, $plymouthconfdir)
+
 AS_AC_EXPAND(PLYMOUTH_LIBDIR, $libdir)
 AS_AC_EXPAND(PLYMOUTH_LIBEXECDIR, $libexecdir)
 AS_AC_EXPAND(PLYMOUTH_DATADIR, $datadir)
index 3f6e4ff5572ba5d6775f08bbb997351b78a51648..249a694098e1b44f3ecb74fc93790b6b122fe57c 100644 (file)
@@ -13,7 +13,9 @@ plymouthdbin_PROGRAMS = plymouthd
 
 plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS)                                         \
                   -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\"         \
-                  -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\"
+                  -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\"          \
+                  -DPLYMOUTH_POLICY_DIR=\"$(PLYMOUTH_POLICY_DIR)/\"          \
+                  -DPLYMOUTH_CONF_DIR=\"$(PLYMOUTH_CONF_DIR)/\"
 plymouthd_LDADD = $(PLYMOUTH_LIBS) libply/libply.la libply-splash-core/libply-splash-core.la
 plymouthd_SOURCES =                                                            \
                    ply-boot-protocol.h                                        \
index ac10a7897f35ca72f0f8dc9771f2718e654c2ddb..b823f8b4750cde4ae1a2d0fd7b5cf34a1a8d5f54 100644 (file)
@@ -111,6 +111,8 @@ typedef struct
 
   char *kernel_console_tty;
   char *override_splash_path;
+  char *system_default_splash_path;
+  char *distribution_default_splash_path;
   const char *default_tty;
 
   int number_of_errors;
@@ -213,6 +215,64 @@ find_override_splash (state_t *state)
     }
 }
 
+static void
+find_system_default_splash (state_t *state)
+{
+  ply_key_file_t *key_file;
+  char *splash_string;
+
+  if (state->system_default_splash_path != NULL)
+      return;
+
+  ply_trace ("Trying to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
+  key_file = ply_key_file_new (PLYMOUTH_CONF_DIR "plymouthd.conf");
+
+  if (ply_key_file_load (key_file))
+    {
+      ply_trace ("failed to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
+      ply_key_file_free (key_file);
+      return;
+    }
+
+  splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
+
+  ply_trace ("System default splash is configured to be '%s'", splash_string);
+
+  asprintf (&state->override_splash_path,
+            PLYMOUTH_THEME_PATH "%s/%s.plymouth",
+            splash_string, splash_string);
+  free (splash_string);
+}
+
+static void
+find_distribution_default_splash (state_t *state)
+{
+  ply_key_file_t *key_file;
+  char *splash_string;
+
+  if (state->distribution_default_splash_path != NULL)
+      return;
+
+  ply_trace ("Trying to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults");
+  key_file = ply_key_file_new (PLYMOUTH_POLICY_DIR "plymouthd.defaults");
+
+  if (ply_key_file_load (key_file))
+    {
+      ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.conf");
+      ply_key_file_free (key_file);
+      return;
+    }
+
+  splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
+
+  ply_trace ("Distribution default splash is configured to be '%s'", splash_string);
+
+  asprintf (&state->override_splash_path,
+            PLYMOUTH_THEME_PATH "%s/%s.plymouth",
+            splash_string, splash_string);
+  free (splash_string);
+}
+
 static void
 show_default_splash (state_t *state)
 {
@@ -223,21 +283,37 @@ show_default_splash (state_t *state)
   find_override_splash (state);
   if (state->override_splash_path != NULL)
     {
-      ply_trace ("Starting override splash at '%s'", state->override_splash_path);
+      ply_trace ("Trying override splash at '%s'", state->override_splash_path);
       state->boot_splash = start_boot_splash (state,
                                               state->override_splash_path);
     }
 
+  find_system_default_splash (state);
+  if (state->boot_splash == NULL)
+    {
+      ply_trace ("Trying system default splash");
+      state->boot_splash = start_boot_splash (state,
+                                              state->system_default_splash_path);
+    }
+
+  find_distribution_default_splash (state);
+  if (state->boot_splash == NULL)
+    {
+      ply_trace ("Trying distribution default splash");
+      state->boot_splash = start_boot_splash (state,
+                                              state->distribution_default_splash_path);
+    }
+
   if (state->boot_splash == NULL)
     {
-      ply_trace ("Starting default splash");
+      ply_trace ("Trying old scheme for default splash");
       state->boot_splash = start_boot_splash (state,
                                               PLYMOUTH_THEME_PATH "default.plymouth");
     }
 
   if (state->boot_splash == NULL)
     {
-      ply_trace ("Could not start graphical splash screen,"
+      ply_trace ("Could not start default splash screen,"
                  "showing text splash screen");
       state->boot_splash = start_boot_splash (state,
                                               PLYMOUTH_THEME_PATH "text/text.plymouth");