From 63cfc4eff57149bd73c78b5a24b33604ee73996a Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 21 Mar 2022 15:10:30 -0400 Subject: [PATCH 1/2] scripts: Support short options being squished togethers for plymouth-set-default-theme People expect to be able to squish short options together, so this commit adds some glob matching to support that feature. --- scripts/plymouth-set-default-theme.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/plymouth-set-default-theme.in b/scripts/plymouth-set-default-theme.in index ed999e90..c6ebd932 100755 --- a/scripts/plymouth-set-default-theme.in +++ b/scripts/plymouth-set-default-theme.in @@ -122,6 +122,27 @@ while [ $# -gt 0 ]; do DO_HELP=1 ;; + -[!-]*-*) + echo "Short options can't have embedded dashes" >&2 + echo $(usage) >&2 + exit 1 + ;; + + -[!-][!-]*) + COMPRESSED_OPTIONS="$1" + shift + + ARGS=($COMPRESSED_OPTIONS $(echo $COMPRESSED_OPTIONS | sed -e 's/^-//' -e 's/[^-]/-& /g') "$@") + + set -- "${ARGS[@]}" + ;; + + -*) + echo "Unknown option: '$1'" >&2 + echo $(usage) >&2 + exit 1 + ;; + *) if [ -n "$THEME_NAME" ]; then echo "You can only specify one theme at a time" >&2 From fd961ef391273506de84da07ec7f211b6e56e319 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 21 Mar 2022 15:13:15 -0400 Subject: [PATCH 2/2] scripts: Support -R with -r and standalone for plymouth-set-default-theme 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/plymouth-set-default-theme.in b/scripts/plymouth-set-default-theme.in index c6ebd932..5e978eb5 100755 --- a/scripts/plymouth-set-default-theme.in +++ b/scripts/plymouth-set-default-theme.in @@ -17,7 +17,7 @@ fi function usage () { - echo "usage: plymouth-set-default-theme { --list | --reset | [ --rebuild-initrd ] | --help }" + echo "usage: plymouth-set-default-theme { --list | --reset [ --rebuild-initrd ] | [ --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