Merge pull request #94 from Dragon8oy/autocomment-console

Autocomment GRUB_TERMINAL, preserve position of other modified configs
This commit is contained in:
Vince 2020-10-18 18:10:42 +08:00 committed by GitHub
commit f296659e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,21 +162,36 @@ install() {
# Backup grub config # Backup grub config
cp -an /etc/default/grub /etc/default/grub.bak cp -an /etc/default/grub /etc/default/grub.bak
grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_THEME=/d' /etc/default/grub if grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null; then
grep "GRUB_GFXMODE=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_GFXMODE=/d' /etc/default/grub #Replace GRUB_THEME
sed -i "s|.*GRUB_THEME=.*|GRUB_THEME=\"${THEME_DIR}/${name}/theme.txt\"|" /etc/default/grub
# Edit grub config else
#Append GRUB_THEME
echo "GRUB_THEME=\"${THEME_DIR}/${name}/theme.txt\"" >> /etc/default/grub echo "GRUB_THEME=\"${THEME_DIR}/${name}/theme.txt\"" >> /etc/default/grub
fi
# Make sure set the right resolution for grub # Make sure set the right resolution for grub
if [[ ${screen} == '1080p' ]]; then if [[ ${screen} == '1080p' ]]; then
echo "GRUB_GFXMODE=1920x1080,auto" >> /etc/default/grub gfxmode="GRUB_GFXMODE=1920x1080,auto"
elif [[ ${screen} == '1080p_21:9' ]]; then elif [[ ${screen} == '1080p_21:9' ]]; then
echo "GRUB_GFXMODE=2560x1080,auto" >> /etc/default/grub gfxmode="GRUB_GFXMODE=2560x1080,auto"
elif [[ ${screen} == '4k' ]]; then elif [[ ${screen} == '4k' ]]; then
echo "GRUB_GFXMODE=3840x2160,auto" >> /etc/default/grub gfxmode="GRUB_GFXMODE=3840x2160,auto"
elif [[ ${screen} == '2k' ]]; then elif [[ ${screen} == '2k' ]]; then
echo "GRUB_GFXMODE=2560x1440,auto" >> /etc/default/grub gfxmode="GRUB_GFXMODE=2560x1440,auto"
fi
if grep "GRUB_GFXMODE=" /etc/default/grub 2>&1 >/dev/null; then
#Replace GRUB_GFXMODE
sed -i "s|.*GRUB_GFXMODE=.*|${gfxmode}|" /etc/default/grub
else
#Append GRUB_GFXMODE
echo "${gfxmode}" >> /etc/default/grub
fi
if grep "GRUB_TERMINAL=console" /etc/default/grub 2>&1 >/dev/null; then
#Replace GRUB_TERMINAL
sed -i "s|.*GRUB_TERMINAL=console.*|#GRUB_TERMINAL=console|" /etc/default/grub
fi fi
# Update grub config # Update grub config