From 8f737a2ae695495deeea871b138f95365a219e08 Mon Sep 17 00:00:00 2001 From: Elian Van Cutsem Date: Sat, 25 Jan 2020 18:16:24 +0100 Subject: [PATCH 1/3] added better OO support and root access --- install.sh | 60 +++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/install.sh b/install.sh index 04504b7..9393a34 100755 --- a/install.sh +++ b/install.sh @@ -89,6 +89,7 @@ install() { # Checking for root access and proceed if it is present if [ "$UID" -eq "$ROOT_UID" ]; then + clear # Create themes directory if not exists echo -e "\n Checking for the existence of themes directory..." @@ -129,33 +130,8 @@ install() { # Update grub config prompt -i "\n Updating grub config..." - if has_command update-grub; then - update-grub - elif has_command grub-mkconfig; then - grub-mkconfig -o /boot/grub/grub.cfg - elif has_command zypper; then - grub2-mkconfig -o /boot/grub2/grub.cfg - elif has_command dnf; then - grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg - fi - - # Success message - prompt -s "\n * All done!" - prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' " - - else - # Error message - prompt -e "\n [ Error! ] -> Run me as root " - - # persisted execution of the script as root - read -p "[ trusted ] specify the root password : " -t${MAX_DELAY} -s - [[ -n "$REPLY" ]] && { - if [[ -n "${theme}" && -n "${screen}" ]]; then - sudo -S <<< $REPLY $0 --${theme} --${screen} - fi - } || { - operation_canceled - } + + updating_grub fi } @@ -199,10 +175,26 @@ run_dialog() { operation_canceled() { clear - prompt "\n Operation canceled by user Bye" + prompt "\n Operation canceled by user, Bye!" exit 1 } +updating_grub() { + if has_command update-grub; then + update-grub + elif has_command grub-mkconfig; then + grub-mkconfig -o /boot/grub/grub.cfg + elif has_command zypper; then + grub2-mkconfig -o /boot/grub2/grub.cfg + elif has_command dnf; then + grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg + fi + + # Success message + prompt -s "\n * All done!" + prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' " +} + install_dialog() { if [ ! "$(which dialog 2> /dev/null)" ]; then prompt -i "\n 'dialog' needs to be installed for this shell" @@ -254,17 +246,7 @@ remove() { # Update grub config prompt -i "\n Resetting grub theme...\n" - if has_command update-grub; then - update-grub - elif has_command grub-mkconfig; then - grub-mkconfig -o /boot/grub/grub.cfg - elif has_command grub2-mkconfig; then - grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg - fi - - # Success message - prompt -s "\n * All done!" - prompt -w "\n * At the next restart of your computer you will see your default Grub theme back! " + updating_grub else # Error message From 1cdf4d57be8237613c39a1421e25b8c374cc25dd Mon Sep 17 00:00:00 2001 From: Elian Van Cutsem Date: Sat, 25 Jan 2020 18:22:00 +0100 Subject: [PATCH 2/3] whitespace --- install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9393a34..8176a87 100755 --- a/install.sh +++ b/install.sh @@ -130,7 +130,7 @@ install() { # Update grub config prompt -i "\n Updating grub config..." - + updating_grub fi } @@ -150,6 +150,7 @@ run_dialog() { 4) theme="slaze" ;; *) operation_canceled ;; esac + tui=$(dialog --backtitle "GRUB2 THEMES" \ --radiolist "Choose icon style : " 15 40 5 \ 1 "white" off \ @@ -159,6 +160,7 @@ run_dialog() { 2) icon="color" ;; *) operation_canceled ;; esac + tui=$(dialog --backtitle "GRUB2 THEMES" \ --radiolist "Choose your Display Resolution : " 15 40 5 \ 1 "1080p" on \ @@ -320,7 +322,7 @@ while [[ $# -ge 1 ]]; do ;; *) prompt -e "\n ERROR: Unrecognized installation option '$1'." - prompt -i "\n Try '$0 --help' for more information." + prompt -i "Try '$0 --help' for more information." exit 1 ;; esac From 76a9b50898e20390732201f33c2c6848d6eb46b4 Mon Sep 17 00:00:00 2001 From: Elian Van Cutsem Date: Mon, 27 Jan 2020 09:16:40 +0100 Subject: [PATCH 3/3] fixed typo --- install.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 8176a87..24028ec 100755 --- a/install.sh +++ b/install.sh @@ -52,7 +52,7 @@ usage() { printf " %-25s%s\n" "-v, --vimix" "vimix grub theme" printf " %-25s%s\n" "-w, --white" "Install white icon version" printf " %-25s%s\n" "-2, --2k" "Install 2k(2560x1440) background image" - printf " %-25s%s\n" "-4, --24" "Install 4k(3840x2160) background image" + printf " %-25s%s\n" "-4, --4k" "Install 4k(3840x2160) background image" printf " %-25s%s\n" "-r, --remove" "Remove theme (must add theme name option)" printf " %-25s%s\n" "-h, --help" "Show this help" } @@ -331,9 +331,7 @@ done if [[ "${remove:-}" != 'true' ]]; then install -fi - -if [[ "${remove:-}" == 'true' ]]; then +elif [[ "${remove:-}" == 'true' ]]; then remove fi