]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[set-default-theme] Write plymouthd.conf instead of symlink
authorRay Strode <rstrode@redhat.com>
Tue, 23 Mar 2010 21:48:48 +0000 (17:48 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 23 Mar 2010 21:54:08 +0000 (17:54 -0400)
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.

scripts/plymouth-set-default-theme.in

index 215497263a8d98ee77b07379a9495fcacea02b38..732f8ad24dd59c79349b7e3c15557674b4258653 100755 (executable)
@@ -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)