#!/bin/env sh

PLYMOYTH_THEME="colorful_loop"
PLYMOYTH_CONFIG_PATH="/etc/plymouth/plymouthd.conf"

addApplications plymouth plymouth-theme-colorful-loop-git

plymouthNeedsSetup() {
  if [[ ! -f $PLYMOYTH_CONFIG_PATH ]]; then
    return 0
  fi

  if ! cat $PLYMOYTH_CONFIG_PATH | grep "Theme=${PLYMOYTH_THEME}"; then
    return 0
  fi

  return 1
}

setupPlymouth() {
  sudo plymouth-set-default-theme ${PLYMOYTH_THEME}
  sudo dracut --force --hostonly
}

if plymouthNeedsSetup; then
  addActions setupPlymouth
fi
