[main] Try getting default theme from config file

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.
This commit is contained in:
Ray Strode 2010-03-23 16:46:56 -04:00
parent 65550c2d5d
commit 27562c4f69
3 changed files with 88 additions and 4 deletions

View 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)

View 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 \

View 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 ("Starting default splash");
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 ("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");