Update install.sh

This commit is contained in:
vinceliuice 2022-03-19 10:32:20 +08:00
parent a4bff7bf91
commit f4f3354233

View file

@ -69,41 +69,40 @@ usage() {
} }
generate() { generate() {
# Make a themes directory if it doesn't exist # Make a themes directory if it doesn't exist
prompt -s "\n Checking for the existence of themes directory..." prompt -s "\n Checking for the existence of themes directory..."
[[ -d "${THEME_DIR}/${theme}" ]] && rm -rf "${THEME_DIR}/${theme}" [[ -d "${THEME_DIR}/${theme}" ]] && rm -rf "${THEME_DIR}/${theme}"
mkdir -p "${THEME_DIR}/${theme}" mkdir -p "${THEME_DIR}/${theme}"
# Copy theme # Copy theme
prompt -s "\n Installing ${theme} ${icon} ${screen} theme..." prompt -s "\n Installing ${theme} ${icon} ${screen} theme..."
# Don't preserve ownership because the owner will be root, and that causes the script to crash if it is ran from terminal by sudo # Don't preserve ownership because the owner will be root, and that causes the script to crash if it is ran from terminal by sudo
cp -a --no-preserve=ownership "${REO_DIR}/common/"{*.png,*.pf2} "${THEME_DIR}/${theme}" cp -a --no-preserve=ownership "${REO_DIR}/common/"{*.png,*.pf2} "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/config/theme-${screen}.txt" "${THEME_DIR}/${theme}/theme.txt" cp -a --no-preserve=ownership "${REO_DIR}/config/theme-${screen}.txt" "${THEME_DIR}/${theme}/theme.txt"
cp -a --no-preserve=ownership "${REO_DIR}/backgrounds/${screen}/background-${theme}.jpg" "${THEME_DIR}/${theme}/background.jpg" cp -a --no-preserve=ownership "${REO_DIR}/backgrounds/${screen}/background-${theme}.jpg" "${THEME_DIR}/${theme}/background.jpg"
# Use custom background.jpg as grub background image # Use custom background.jpg as grub background image
if [[ -f "${REO_DIR}/background.jpg" ]]; then if [[ -f "${REO_DIR}/background.jpg" ]]; then
prompt -w "\n Using custom background.jpg as grub background image..." prompt -w "\n Using custom background.jpg as grub background image..."
cp -a --no-preserve=ownership "${REO_DIR}/background.jpg" "${THEME_DIR}/${theme}/background.jpg" cp -a --no-preserve=ownership "${REO_DIR}/background.jpg" "${THEME_DIR}/${theme}/background.jpg"
convert -auto-orient "${THEME_DIR}/${theme}/background.jpg" "${THEME_DIR}/${theme}/background.jpg" convert -auto-orient "${THEME_DIR}/${theme}/background.jpg" "${THEME_DIR}/${theme}/background.jpg"
fi fi
if [[ ${screen} == 'ultrawide' ]]; then
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-1080p" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-1080p/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-1080p.png" "${THEME_DIR}/${theme}/info.png"
elif [[ ${screen} == 'ultrawide2k' ]]; then
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-2k" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-2k/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-2k.png" "${THEME_DIR}/${theme}/info.png"
else
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-${screen}" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-${screen}/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-${screen}.png" "${THEME_DIR}/${theme}/info.png"
fi
if [[ ${screen} == 'ultrawide' ]]; then
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-1080p" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-1080p/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-1080p.png" "${THEME_DIR}/${theme}/info.png"
elif [[ ${screen} == 'ultrawide2k' ]]; then
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-2k" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-2k/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-2k.png" "${THEME_DIR}/${theme}/info.png"
else
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-${icon}/icons-${screen}" "${THEME_DIR}/${theme}/icons"
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-${screen}/"*.png "${THEME_DIR}/${theme}"
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-${screen}.png" "${THEME_DIR}/${theme}/info.png"
fi
} }
install() { install() {
@ -198,7 +197,7 @@ install() {
prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' " prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' "
#Check if password is cached (if cache timestamp has not expired yet) #Check if password is cached (if cache timestamp has not expired yet)
elif sudo -n true 2> /dev/null && echo; then #No need for "$?" ==> https://github.com/koalaman/shellcheck/wiki/SC2181 elif sudo -n true 2> /dev/null && echo; then
sudo "$0" -t ${theme} -i ${icon} -s ${screen} sudo "$0" -t ${theme} -i ${icon} -s ${screen}
else else
@ -446,6 +445,7 @@ dialog_installer() {
fi fi
run_dialog run_dialog
install "${theme}" "${icon}" "${screen}" install "${theme}" "${icon}" "${screen}"
exit 1
} }
####################################################### #######################################################
@ -453,6 +453,7 @@ dialog_installer() {
####################################################### #######################################################
install=install install=install
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
PROG_ARGS+=("${1}") PROG_ARGS+=("${1}")
dialog='false' dialog='false'
@ -491,7 +492,7 @@ while [[ $# -gt 0 ]]; do
themes+=("${THEME_VARIANTS[3]}") themes+=("${THEME_VARIANTS[3]}")
shift shift
;; ;;
-*) # "-*" overrides "--*" -*)
break break
;; ;;
*) *)