From: Ray Strode Date: Tue, 23 Mar 2010 20:46:56 +0000 (-0400) Subject: [main] Try getting default theme from config file X-Git-Tag: 0.8.0~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27562c4f69fd084afc2d5961005c7cc2dbf6995c;p=thirdparty%2Fplymouth.git [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. --- diff --git a/configure.ac b/configure.ac index a8ac587d..b78e21f9 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/src/Makefile.am b/src/Makefile.am index 3f6e4ff5..249a6940 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/main.c b/src/main.c index ac10a789..b823f8b4 100644 --- a/src/main.c +++ b/src/main.c @@ -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");