]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
scripts: Support -R with -r and standalone for plymouth-set-default-theme
authorRay Strode <rstrode@redhat.com>
Mon, 21 Mar 2022 19:13:15 +0000 (15:13 -0400)
committerRay Strode <halfline@gmail.com>
Mon, 28 Mar 2022 16:24:06 +0000 (16:24 +0000)
Right now plymouth-set-default-theme only supports rebuilding the initrd if a theme
is passed explicitly.

This commit improves the script to also work for --reset and even in a
standalone mode where no theme is passed at all.

Closes https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/174

scripts/plymouth-set-default-theme.in

index c6ebd932f385f7038fdb712909e6b87bd5e62625..5e978eb5d6e5786dd8160efc690b3eabde4ff9a2 100755 (executable)
@@ -17,7 +17,7 @@ fi
 
 function usage ()
 {
-  echo "usage: plymouth-set-default-theme { --list | --reset | <theme-name> [ --rebuild-initrd ] | --help }"
+  echo "usage: plymouth-set-default-theme { --list | --reset [ --rebuild-initrd ] | <theme-name> [ --rebuild-initrd ] | --rebuild-initrd | --help }"
 }
 
 function show_help() {
@@ -189,9 +189,15 @@ if [ `id -u` -ne 0 ]; then
 fi
 
 if [ $DO_RESET -ne 0 ]; then
-        [ -f ${PLYMOUTH_CONFDIR}/plymouthd.conf ] || exit 0
-        sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf
-        exit $?
+        if [ -f ${PLYMOUTH_CONFDIR}/plymouthd.conf ]; then
+                sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf || exit $?
+        fi
+
+        [ $DO_INITRD_REBUILD -eq 0 ] && exit 0
+fi
+
+if [ $DO_INITRD_REBUILD -ne 0 -a -z $THEME_NAME]; then
+        THEME_NAME=$(get_default_theme)
 fi
 
 if [ ! -e ${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth ]; then