From d40bca8752d517100ebba1aba94bbfc5ed0041fe Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+KaizIqbal@users.noreply.github.com> Date: Sun, 9 Aug 2020 17:25:51 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=85=20code=20format=20&=20auto=20insta?= =?UTF-8?q?ll=20improvments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/install.sh | 211 +++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 104 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 1314915..fecedac 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,7 +1,30 @@ #! /bin/bash +# auto-install patch by @luizoti on Bibata Cursror => https://github.com/ful1e5/Bibata_Cursor/commit/eb84f27919e433f9b72e7ef9f6444d4a7d276ba9 INPUT=$1 +ROOT_UID=0 +DEST_DIR= +URL="https://github.com/ful1e5/apple_cursor/releases/download/1.0.1-beta/macOSBigSur.tar" +macOSBigSur="./macOSBigSur" +DOWNLOAD_FILE_NAME="$macOSBigSur.tar" + +cd "$( dirname "${BASH_SOURCE[0]}" )" || exitt + +# Destination directory +if [ "$UID" -eq "$ROOT_UID" ]; then + DEST_DIR="/usr/share/icons" +else + DEST_DIR="$HOME/.icons" +fi + +echo -e "\e[1m\n+---------------------------------------------+" +echo -e "| macOSBigSur Cursor Installer Script |" +echo -e "+---------------------------------------------+\n\e[0m" + + + +# -------------------- Color print Functions -------------------- show_question() { echo -e "\033[1;34m$@\033[0m" } @@ -19,6 +42,7 @@ end() { exit 0 } +# -------------------- Helpers -------------------- continue() { case ${INPUT} in '-a' ) @@ -50,68 +74,6 @@ replace() { } -install() { - - # PREVIEW - - # Show destination directory - echo -e "\nmacOSBigSur Cursor Theme will be installed in:\n" - show_dir "\t$DEST_DIR" - if [ "$UID" -eq "$ROOT_UID" ]; then - echo -e "\nIt will be available to all users." - else - echo -e "\nTo make them available to all users, run this script as root." - fi - - continue - - # INSTALL - - # Check destination directory - if [ ! -d $DEST_DIR ]; then - mkdir -p $DEST_DIR - elif [[ -d $DEST_DIR/macOSBigSur ]]; then - replace $DEST_DIR - fi - - echo -e "\nInstalling macOSBigSur..." - - # Copying files - cp -rf $macOSBigSur $DEST_DIR - chmod -R 755 $DEST_DIR/macOSBigSur - - echo "Installation complete!" - echo "Do not forget you have to set macOSBigSur Cursor." -} - -remove() { - - # PREVIEW - - # Show installation directory - if [[ -d $DEST_DIR/macOSBigSur ]]; then - echo -e "\nmacOSBigSur Theme installed in:\n" - show_dir "\t$DEST_DIR" - if [ "$UID" -eq "$ROOT_UID" ]; then - echo -e "\nIt will remove for all users." - else - echo -e "\nIt will remove only for current user." - fi - - continue - - else - show_error "\nmacOSBigSur Cursor is not installed in:\n" - show_dir "\t$DEST_DIR\n" - end - fi - - echo -e "\nRemoving macOSBigSur..." - rm -rf $DEST_DIR/macOSBigSur - - echo "Removing complete!" - echo "I hope to see you soon." -} # For download the package function download { @@ -155,7 +117,86 @@ function unpack { fi } +install() { + + # Cecking old version exits or not + if [ -f "$DOWNLOAD_FILE_NAME" ] || [ -f "$macOSBigSur" ]; then + echo -e "\nmacOSBigSur.tar file already exists" + show_question "\nDownload Fresh Theme OR Continue with existing file? (D)ownload File (recommended), (E)xisting File : \n " + read INPUT + case $INPUT in + ( [Dd]* ) download $URL $DOWNLOAD_FILE_NAME;; + ( [Ee]* ) ;; + ( * ) show_error "\nSorry, try again."; continue;; + esac + else + download $URL $DOWNLOAD_FILE_NAME + fi + + + # unpack file + unpack $DOWNLOAD_FILE_NAME + + # Show destination directory + echo -e "\nmacOSBigSur Cursor Theme will be installed in:\n" + show_dir "\t$DEST_DIR" + if [ "$UID" -eq "$ROOT_UID" ]; then + echo -e "\nIt will be available to all users." + else + echo -e "\nTo make them available to all users, run this script as root." + fi + + continue + + + # Check destination directory + if [ ! -d $DEST_DIR ]; then + mkdir -p $DEST_DIR + elif [[ -d $DEST_DIR/macOSBigSur ]]; then + replace $DEST_DIR + fi + + echo -e "\nInstalling macOSBigSur..." + + # Copying files + cp -rf $macOSBigSur $DEST_DIR + chmod -R 755 $DEST_DIR/macOSBigSur + + echo "Installation complete!" + echo "Do not forget you have to set macOSBigSur Cursor" +} + +remove() { + + # PREVIEW + + # Show installation directory + if [[ -d $DEST_DIR/macOSBigSur ]]; then + echo -e "\nmacOSBigSur Theme installed in:\n" + show_dir "\t$DEST_DIR" + if [ "$UID" -eq "$ROOT_UID" ]; then + echo -e "\nIt will remove for all users." + else + echo -e "\nIt will remove only for current user." + fi + + continue + + else + show_error "\nmacOSBigSur Cursor is not installed in:\n" + show_dir "\t$DEST_DIR\n" + end + fi + + echo -e "\nRemoving macOSBigSur..." + rm -rf $DEST_DIR/macOSBigSur + + echo "Removing complete" + echo "I hope to see you soon." +} + main() { + # Cases case ${INPUT} in '-a' ) install @@ -173,47 +214,9 @@ main() { esac ;; esac + + # Remove directory + rm -rf macOSBigSur } - -ROOT_UID=0 -DEST_DIR= -URL="https://github.com/ful1e5/apple_cursor/releases/download/1.0.1-beta/macOSBigSur.tar" -macOSBigSur="./macOSBigSur" -DOWNLOAD_FILE_NAME="$macOSBigSur.tar" - -cd "$( dirname "${BASH_SOURCE[0]}" )" || exitt - -# Download files at current directory -if [[ -f "$DOWNLOAD_FILE_NAME" ]]; then - echo -e "\nmacOSBigSur.tar file already exists" - show_question "\nDownload Fresh Theme OR Continue with existing file? (D)ownload File, (E)xisting File : \n" - read INPUT - case $INPUT in - ( [Dd]* ) download $URL $DOWNLOAD_FILE_NAME;; - ( [Ee]* ) ;; - ( * ) show_error "\nSorry, try again."; continue;; - esac -else - download $URL $DOWNLOAD_FILE_NAME -fi - - -# unpack file -unpack $DOWNLOAD_FILE_NAME - -# Destination directory -if [ "$UID" -eq "$ROOT_UID" ]; then - DEST_DIR="/usr/share/icons" -else - DEST_DIR="$HOME/.icons" -fi - -echo -e "\e[1m\n+---------------------------------------------+" -echo -e "| macOSBigSur Cursor Installer Script |" -echo -e "+---------------------------------------------+\n\e[0m" - -main - -# Remove directory -rm -rf macOSBigSur \ No newline at end of file +( cd /tmp/ && main ) \ No newline at end of file