mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-08 05:28:01 +02:00
[branch-merge] Add daemon configuration mechanism
This series of commits adds a few configuration files to replace the kludgey symlink we use now for theme specification. In the future, these config files could potentially be used for other things as well.
This commit is contained in:
commit
b75a0ab5a7
8 changed files with 132 additions and 33 deletions
16
configure.ac
16
configure.ac
|
|
@ -110,16 +110,6 @@ AC_SUBST(background_start_color)
|
|||
AC_ARG_WITH(background-end-color-stop, AS_HELP_STRING([--with-background-end-color-stop],[first color end in background gradients used by boot splash plugins]),background_end_color=${withval},background_end_color=0x3a362f)
|
||||
AC_SUBST(background_end_color)
|
||||
|
||||
AC_ARG_WITH(default-plugin, AS_HELP_STRING([--with-default-plugin=fade-throbber],[Plugin to use by default]),default_plugin_name=${withval},default_plugin_name=fade-throbber)
|
||||
AM_CONDITIONAL(ADD_DEFAULT_PLUGIN_LINK,
|
||||
[test "$default_plugin_name" = "spinfinity" \
|
||||
-o "$default_plugin_name" = "fade-throbber" \
|
||||
-o "$default_plugin_name" = "text" \
|
||||
-o "$default_plugin_name" = "glow" \
|
||||
-o "$default_plugin_name" = "solar" \
|
||||
-o "$default_plugin_name" = "details"])
|
||||
AC_SUBST(default_plugin_name)
|
||||
|
||||
AC_ARG_WITH(release-file, AS_HELP_STRING([--with-release-file=<path_to_release_file>],[Release File to use to detect distribution (by default /etc/system-reelase)]),RELEASE_FILE=${withval},RELEASE_FILE=/etc/system-release)
|
||||
|
||||
AC_SUBST(RELEASE_FILE)
|
||||
|
|
@ -214,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)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
[ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
|
||||
[ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@logofile@"
|
||||
[ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)
|
||||
[ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@"
|
||||
[ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@"
|
||||
|
||||
if [ -z "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then
|
||||
|
||||
|
|
@ -78,6 +80,8 @@ inst ${PLYMOUTH_DATADIR}/plymouth/themes/details/details.plymouth $INITRDDIR
|
|||
inst ${PLYMOUTH_PLUGIN_PATH}/details.so $INITRDDIR
|
||||
inst ${PLYMOUTH_LOGO_FILE} $INITRDDIR
|
||||
inst @RELEASE_FILE@ $INITRDDIR
|
||||
inst ${PLYMOUTH_POLICYDIR}/plymouthd.defaults $INITRDDIR
|
||||
inst ${PLYMOUTH_CONFDIR}/plymouthd.conf $INITRDDIR
|
||||
|
||||
if [ -z "$PLYMOUTH_THEME_NAME" ]; then
|
||||
echo "No default plymouth plugin is set" > /dev/stderr
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ set -e
|
|||
|
||||
[ -z "$PLYMOUTH_LIBEXECDIR" ] && PLYMOUTH_LIBEXECDIR="@PLYMOUTH_LIBEXECDIR@"
|
||||
[ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="@PLYMOUTH_DATADIR@"
|
||||
[ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@"
|
||||
[ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@"
|
||||
if [ -z "$PLYMOUTH_PLUGIN_PATH" ]; then
|
||||
if [ -z "$LIB" ]; then
|
||||
PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
|
||||
|
|
@ -40,14 +42,27 @@ function list_themes ()
|
|||
done
|
||||
}
|
||||
|
||||
function read_theme_name_from_file ()
|
||||
{
|
||||
echo $(grep -v '^#' $1 2> /dev/null |
|
||||
awk '
|
||||
BEGIN {
|
||||
RS="[[][[:blank:]]*[^[:space:]]+[:blank:]*[]\n]";
|
||||
FS="[=[:space:]]+";
|
||||
OFS="";
|
||||
ORS=""
|
||||
}
|
||||
$1 ~/Theme/ { print $2 }
|
||||
')
|
||||
}
|
||||
|
||||
function get_default_theme ()
|
||||
{
|
||||
THEME_NAME=$(basename $(readlink ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth) .plymouth)
|
||||
if [ "$THEME_NAME" = ".plymouth" ]; then
|
||||
$0 --reset
|
||||
THEME_NAME=$(basename $(readlink ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth) .plymouth)
|
||||
THEME_NAME=$(read_theme_name_from_file ${PLYMOUTH_CONFDIR}/plymouthd.conf)
|
||||
if [ -z "$THEME_NAME" ]; then
|
||||
THEME_NAME=$(read_theme_name_from_file ${PLYMOUTH_POLICYDIR}/plymouthd.defaults)
|
||||
fi
|
||||
[ "$THEME_NAME" = ".so" ] || echo $THEME_NAME && exit 1
|
||||
[ -z "$THEME_NAME" ] || echo $THEME_NAME && exit 1
|
||||
}
|
||||
|
||||
DO_RESET=0
|
||||
|
|
@ -144,11 +159,9 @@ if [ `id -u` -ne 0 ]; then
|
|||
fi
|
||||
|
||||
if [ $DO_RESET -ne 0 ]; then
|
||||
THEME_NAME=$(basename $(ls -1 -t ${PLYMOUTH_DATADIR}/plymouth/themes/*/*.plymouth 2> /dev/null | tail -n 1) .plymouth)
|
||||
if [ $THEME_NAME = .plymouth ]; then
|
||||
rm -f ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth
|
||||
exit 0
|
||||
fi
|
||||
[ -f ${PLYMOUTH_CONFDIR}/plymouthd.conf ] || exit 0
|
||||
sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ ! -e ${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth ]; then
|
||||
|
|
@ -163,8 +176,10 @@ if [ ! -e ${PLYMOUTH_PLUGIN_PATH}${MODULE_NAME}.so ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
(cd ${PLYMOUTH_DATADIR}/plymouth/themes;
|
||||
ln -sf ${THEME_NAME}/${THEME_NAME}.plymouth default.plymouth && \
|
||||
([ $DO_INITRD_REBUILD -ne 0 ] && \
|
||||
${PLYMOUTH_LIBEXECDIR}/plymouth/plymouth-update-initrd) || :)
|
||||
[ -d ${PLYMOUTH_CONFDIR} ] || mkdir -p ${PLYMOUTH_CONFDIR}
|
||||
fgrep -q '[Daemon]' ${PLYMOUTH_CONFDIR}/plymouthd.conf 2> /null || echo '[Daemon]' >> ${PLYMOUTH_CONFDIR}/plymouthd.conf
|
||||
sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf
|
||||
sed -i -e "s/\([[]Daemon[]]\)\n*/\1\nTheme=${THEME_NAME}/" ${PLYMOUTH_CONFDIR}/plymouthd.conf
|
||||
|
||||
[ $DO_INITRD_REBUILD -ne 0 ] && (${PLYMOUTH_LIBEXECDIR}/plymouth/plymouth-update-initrd)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
82
src/main.c
82
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 ("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");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,2 @@
|
|||
SUBDIRS = throbgress fade-throbber text details space-flares two-step script
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
if ADD_DEFAULT_PLUGIN_LINK
|
||||
install-data-hook:
|
||||
(cd $(DESTDIR)$(libdir)/plymouth; ln -sf $(default_plugin_name).so default.so)
|
||||
endif
|
||||
|
|
|
|||
3
src/plymouthd.conf
Normal file
3
src/plymouthd.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Administrator customizations go in this file
|
||||
#[Daemon]
|
||||
#Theme=fade-in
|
||||
8
src/plymouthd.defaults
Normal file
8
src/plymouthd.defaults
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Distribution defaults. Changes to this file will get overwritten during
|
||||
# upgrades.
|
||||
[Daemon]
|
||||
Theme=fade-in
|
||||
Foo=bar
|
||||
|
||||
[z]
|
||||
ffoo=yo
|
||||
Loading…
Add table
Reference in a new issue