mirror of
https://github.com/vinceliuice/grub2-themes.git
synced 2026-03-08 03:34:00 +08:00
Compare commits
7 Commits
2025-03-03
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80dd04ddf3 | ||
|
|
8f30385f55 | ||
|
|
6f235a8bc5 | ||
|
|
03d8c9cf0d | ||
|
|
6c26f99622 | ||
|
|
739cddf60f | ||
|
|
7cf2f0918f |
@@ -86,7 +86,7 @@ After that, you can configure the theme as shown below. In this example it is in
|
||||
- Finally, run `grub-mkconfig -o /boot/grub/grub.cfg` to update your grub config
|
||||
|
||||
### Setting a custom background:
|
||||
- Make sure you have `imagemagick` installed, or at least something that provides `convert`
|
||||
- Make sure you have `imagemagick` installed, or at least something that provides `convert` or `magick`
|
||||
- Find the resolution of your display, and make sure your background matches the resolution
|
||||
- 1920x1080 >> 1080p
|
||||
- 2560x1080 >> ultrawide
|
||||
|
||||
79
install.sh
79
install.sh
@@ -116,13 +116,18 @@ generate() {
|
||||
|
||||
# Determine which configuration file and assets to use
|
||||
if [[ -n "$custom_resolution" ]]; then
|
||||
if has_command apt || has_command pacman || has_command eopkg; then
|
||||
install_depends imagemagick
|
||||
else
|
||||
install_depends ImageMagick
|
||||
fi
|
||||
asset_type=$(get_asset_type "$custom_resolution")
|
||||
cp -a --no-preserve=ownership "${REO_DIR}/config/theme-${asset_type}.txt" "${THEME_DIR}/${theme}/theme.txt"
|
||||
# Replace resolution in 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
|
||||
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
|
||||
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"
|
||||
@@ -130,9 +135,14 @@ generate() {
|
||||
|
||||
# Use custom background.jpg as grub background image
|
||||
if [[ -f "${REO_DIR}/background.jpg" ]]; then
|
||||
if has_command apt || has_command pacman || has_command eopkg; then
|
||||
install_depends imagemagick
|
||||
else
|
||||
install_depends ImageMagick
|
||||
fi
|
||||
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"
|
||||
convert -auto-orient "${THEME_DIR}/${theme}/background.jpg" "${THEME_DIR}/${theme}/background.jpg"
|
||||
magick "${THEME_DIR}/${theme}/background.jpg" -auto-orient "${THEME_DIR}/${theme}/background.jpg"
|
||||
fi
|
||||
|
||||
# Determine which assets to use based on custom resolution or screen
|
||||
@@ -213,11 +223,8 @@ install() {
|
||||
fi
|
||||
|
||||
if grep "GRUB_BACKGROUND=" /etc/default/grub 2>&1 >/dev/null; then
|
||||
#Replace GRUB_BACKGROUND
|
||||
sed -i "s|.*GRUB_BACKGROUND=.*|GRUB_BACKGROUND=\"${THEME_DIR}/${theme}/background.jpg\"|" /etc/default/grub
|
||||
else
|
||||
#Append GRUB_BACKGROUND
|
||||
echo "GRUB_BACKGROUND=\"${THEME_DIR}/${theme}/background.jpg\"" >> /etc/default/grub
|
||||
# remove GRUB_BACKGROUND
|
||||
sed -i "s|.*GRUB_BACKGROUND=.*||" /etc/default/grub
|
||||
fi
|
||||
|
||||
# Make sure the right resolution for grub is set
|
||||
@@ -267,10 +274,18 @@ install() {
|
||||
|
||||
#Check if password is cached (if cache timestamp has not expired yet)
|
||||
elif sudo -n true 2> /dev/null && echo; then
|
||||
if [[ "${install_boot}" == 'true' ]]; then
|
||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b
|
||||
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
|
||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen}
|
||||
if [[ "${install_boot}" == 'true' ]]; then
|
||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b
|
||||
else
|
||||
sudo "$0" -t ${theme} -i ${icon} -s ${screen}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
#Ask for password
|
||||
@@ -281,16 +296,30 @@ install() {
|
||||
else
|
||||
sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login}
|
||||
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
|
||||
else
|
||||
prompt -e "\n [ Error! ] -> Run me as root! "
|
||||
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
||||
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
||||
#Correct password, use with sudo's stdin
|
||||
if [[ "${install_boot}" == 'true' ]]; then
|
||||
sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} -b <<< ${REPLY}
|
||||
if [[ -n "$custom_resolution" ]]; then
|
||||
if [[ "${install_boot}" == 'true' ]]; then
|
||||
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution} -b <<< ${REPLY}
|
||||
else
|
||||
sudo "$0" -t ${theme} -i ${icon} -c ${custom_resolution} <<< ${REPLY}
|
||||
fi
|
||||
else
|
||||
sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY}
|
||||
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
|
||||
else
|
||||
#block for 3 seconds before allowing another attempt
|
||||
@@ -415,22 +444,30 @@ updating_grub() {
|
||||
|
||||
function install_program () {
|
||||
if has_command zypper; then
|
||||
zypper in "$@"
|
||||
zypper in -y "$@"
|
||||
elif has_command swupd; then
|
||||
swupd bundle-add "$@"
|
||||
elif has_command apt-get; then
|
||||
apt-get install "$@"
|
||||
elif has_command dnf; then
|
||||
dnf install -y "$@"
|
||||
elif has_command yum; then
|
||||
yum install "$@"
|
||||
yum install -y "$@"
|
||||
elif has_command pacman; then
|
||||
pacman -S --noconfirm "$@"
|
||||
pacman -Syyu --noconfirm --needed "$@"
|
||||
elif has_command xbps-install; then
|
||||
xbps-install -Sy "$@"
|
||||
elif has_command eopkg; then
|
||||
eopkg -y install "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
install_dialog() {
|
||||
if [ ! "$(which dialog 2> /dev/null)" ]; then
|
||||
prompt -w "\n 'dialog' need to be installed for this shell"
|
||||
install_program "dialog"
|
||||
install_depends() {
|
||||
local depend=${1}
|
||||
|
||||
if [ ! "$(which '${depend}' 2> /dev/null)" ]; then
|
||||
prompt -w "\n '${depend}' need to be installed for this shell"
|
||||
install_program "${depend}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -537,7 +574,7 @@ dialog_installer() {
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
install_dialog
|
||||
install_depends dialog
|
||||
fi
|
||||
run_dialog
|
||||
install "${theme}" "${icon}" "${screen}"
|
||||
|
||||
Reference in New Issue
Block a user