From: Ray Strode Date: Tue, 23 Mar 2010 21:48:48 +0000 (-0400) Subject: [set-default-theme] Write plymouthd.conf instead of symlink X-Git-Tag: 0.8.0~16^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5baed15f096fa9457a4f1e0f2be36ee155099fe8;p=thirdparty%2Fplymouth.git [set-default-theme] Write plymouthd.conf instead of symlink Now that the daemon looks for the default theme in configuration files, we should make plymouth-set-default-theme write the configuration files instead of doing symlinks. That's what this commit does. --- diff --git a/scripts/plymouth-set-default-theme.in b/scripts/plymouth-set-default-theme.in index 21549726..732f8ad2 100755 --- a/scripts/plymouth-set-default-theme.in +++ b/scripts/plymouth-set-default-theme.in @@ -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)