mirror of
https://github.com/vinceliuice/grub2-themes.git
synced 2026-03-07 11:14:01 +08:00
Fixed #244
This commit is contained in:
44
install.sh
44
install.sh
@@ -116,13 +116,14 @@ generate() {
|
|||||||
|
|
||||||
# Determine which configuration file and assets to use
|
# Determine which configuration file and assets to use
|
||||||
if [[ -n "$custom_resolution" ]]; then
|
if [[ -n "$custom_resolution" ]]; then
|
||||||
|
install_depends ImageMagick
|
||||||
asset_type=$(get_asset_type "$custom_resolution")
|
asset_type=$(get_asset_type "$custom_resolution")
|
||||||
cp -a --no-preserve=ownership "${REO_DIR}/config/theme-${asset_type}.txt" "${THEME_DIR}/${theme}/theme.txt"
|
cp -a --no-preserve=ownership "${REO_DIR}/config/theme-${asset_type}.txt" "${THEME_DIR}/${theme}/theme.txt"
|
||||||
# Replace resolution in theme.txt
|
# Replace resolution in theme.txt
|
||||||
sed -i "s/[0-9]\+x[0-9]\+/${custom_resolution}/" "${THEME_DIR}/${theme}/theme.txt"
|
sed -i "s/[0-9]\+x[0-9]\+/${custom_resolution}/" "${THEME_DIR}/${theme}/theme.txt"
|
||||||
# Use appropriate background as base and resize it
|
# Use appropriate background as base and resize it
|
||||||
cp -a --no-preserve=ownership "${REO_DIR}/backgrounds/${asset_type}/background-${theme}.jpg" "${THEME_DIR}/${theme}/background.jpg"
|
cp -a --no-preserve=ownership "${REO_DIR}/backgrounds/${asset_type}/background-${theme}.jpg" "${THEME_DIR}/${theme}/background.jpg"
|
||||||
convert "${THEME_DIR}/${theme}/background.jpg" -resize ${custom_resolution}^ -gravity center -extent ${custom_resolution} "${THEME_DIR}/${theme}/background.jpg"
|
magick "${THEME_DIR}/${theme}/background.jpg" -resize ${custom_resolution}^ -gravity center -extent ${custom_resolution} "${THEME_DIR}/${theme}/background.jpg"
|
||||||
else
|
else
|
||||||
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"
|
||||||
@@ -130,9 +131,10 @@ generate() {
|
|||||||
|
|
||||||
# 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
|
||||||
|
install_depends ImageMagick
|
||||||
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"
|
magick -auto-orient "${THEME_DIR}/${theme}/background.jpg" "${THEME_DIR}/${theme}/background.jpg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine which assets to use based on custom resolution or screen
|
# Determine which assets to use based on custom resolution or screen
|
||||||
@@ -267,11 +269,19 @@ install() {
|
|||||||
|
|
||||||
#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
|
elif sudo -n true 2> /dev/null && echo; then
|
||||||
|
if [[ -n "$custom_resolution" ]]; then
|
||||||
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
|
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution} -b
|
||||||
|
else
|
||||||
|
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution}
|
||||||
|
fi
|
||||||
|
else
|
||||||
if [[ "${install_boot}" == 'true' ]]; then
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b
|
sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b
|
||||||
else
|
else
|
||||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen}
|
sudo "$0" -t ${theme} -i ${icon} -s ${screen}
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
#Ask for password
|
#Ask for password
|
||||||
if [[ -n ${tui_root_login} ]] ; then
|
if [[ -n ${tui_root_login} ]] ; then
|
||||||
@@ -281,16 +291,30 @@ install() {
|
|||||||
else
|
else
|
||||||
sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login}
|
sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login}
|
||||||
fi
|
fi
|
||||||
|
elif [[ -n "$custom_resolution" ]]; then
|
||||||
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
|
sudo -S $0 -t ${theme} -i ${icon} -c ${custom_resolution} -b <<< ${tui_root_login}
|
||||||
|
else
|
||||||
|
sudo -S $0 -t ${theme} -i ${icon} -c ${custom_resolution} <<< ${tui_root_login}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
prompt -e "\n [ Error! ] -> Run me as root! "
|
prompt -e "\n [ Error! ] -> Run me as root! "
|
||||||
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
||||||
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
||||||
#Correct password, use with sudo's stdin
|
#Correct password, use with sudo's stdin
|
||||||
|
if [[ -n "$custom_resolution" ]]; then
|
||||||
if [[ "${install_boot}" == 'true' ]]; then
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} -b <<< ${REPLY}
|
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution} -b <<< ${REPLY}
|
||||||
else
|
else
|
||||||
sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY}
|
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution} <<< ${REPLY}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
|
sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b <<< ${REPLY}
|
||||||
|
else
|
||||||
|
sudo "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#block for 3 seconds before allowing another attempt
|
#block for 3 seconds before allowing another attempt
|
||||||
@@ -427,10 +451,12 @@ function install_program () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dialog() {
|
install_depends() {
|
||||||
if [ ! "$(which dialog 2> /dev/null)" ]; then
|
local depend=${1}
|
||||||
prompt -w "\n 'dialog' need to be installed for this shell"
|
|
||||||
install_program "dialog"
|
if [ ! "$(which '${depend}' 2> /dev/null)" ]; then
|
||||||
|
prompt -w "\n '${depend}' need to be installed for this shell"
|
||||||
|
install_program "${depend}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +563,7 @@ dialog_installer() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
install_dialog
|
install_depends dialog
|
||||||
fi
|
fi
|
||||||
run_dialog
|
run_dialog
|
||||||
install "${theme}" "${icon}" "${screen}"
|
install "${theme}" "${icon}" "${screen}"
|
||||||
|
|||||||
Reference in New Issue
Block a user