diff --git a/build.sh b/build.sh index 2fc0792b..ab7bff5e 100755 --- a/build.sh +++ b/build.sh @@ -202,7 +202,7 @@ esac show_pre "Generating Installer...\\r" if [ "src/in.inst" ]; then - cp src/in.inst Bibata.sh + cp src/install install.sh fi if [ $? -eq 0 ] @@ -216,15 +216,15 @@ fi show_pre "Making Installer Executable...\n" -if [ "Bibata.sh" ]; then - sudo chmod +x Bibata.sh +if [ "install.sh" ]; then + sudo chmod +x install.sh fi if [ $? -eq 0 ] then show "Making Installer Executable... DONE" show_Msg "For Installation Use Following Command:\n" - show_Msg "\t sudo ./Bibata.sh\n\t\tOR\n\t./Bibata.sh" + show_Msg "\t sudo ./install.sh\n\t\tOR\n\t./install.sh" else error "Making Installer Executable... FAIL" error "\nAborting..." diff --git a/src/in.inst b/install.sh old mode 100644 new mode 100755 similarity index 84% rename from src/in.inst rename to install.sh index 0b7aa1f7..0a9d3cbc --- a/src/in.inst +++ b/install.sh @@ -64,9 +64,10 @@ install() { echo -e "\nInstalling Bibata..." # Copying files - cp -rf Bibata_Oil $DEST_DIR - cp -rf Bibata_Ice $DEST_DIR - cp -rf Bibata_Amber $DEST_DIR + cp -rf $Bibata_Classic $DEST_DIR + cp -rf $Bibata_Oil $DEST_DIR + cp -rf $Bibata_Ice $DEST_DIR + cp -rf $Bibata_Amber $DEST_DIR chmod -R 755 $DEST_DIR/Bibata_* @@ -80,7 +81,7 @@ remove() { # PREVIEW # Show installation directory - if [[ -d $DEST_DIR/Bibata_Oil || -d $DEST_DIR/Bibata_Ice ]]; then + if [[ -d $DEST_DIR/Bibata_Classic || -d $DEST_DIR/Bibata_Oil || -d $DEST_DIR/Bibata_Ice || -d $DEST_DIR/Bibata_Amber ]]; then echo -e "\nBibata Cursor Theme installed in:\n" show_dir "\t$DEST_DIR" if [ "$UID" -eq "$ROOT_UID" ]; then @@ -102,6 +103,7 @@ remove() { echo -e "\nRemoving Bibata..." # Removing files + rm -rf $DEST_DIR/Bibata_Classic rm -rf $DEST_DIR/Bibata_Oil rm -rf $DEST_DIR/Bibata_Ice rm -rf $DEST_DIR/Bibata_Amber @@ -122,6 +124,10 @@ main() { ROOT_UID=0 DEST_DIR= +Bibata_Classic=./Bibata_Classic/out/X11/Bibata_Classic +Bibata_Oil=./Bibata_Oil/out/X11/Bibata_Oil +Bibata_Ice=./Bibata_Ice/out/X11/Bibata_Ice +Bibata_Amber=./Bibata_Amber/out/X11/Bibata_Amber cd "$( dirname "${BASH_SOURCE[0]}" )" || exit # Destination directory diff --git a/src/install b/src/install new file mode 100644 index 00000000..0a9d3cbc --- /dev/null +++ b/src/install @@ -0,0 +1,144 @@ +#! /bin/bash + +show_question() { + echo -e "\033[1;34m$@\033[0m" +} + +show_dir() { + echo -e "\033[1;32m$@\033[0m" +} + +show_error() { + echo -e "\033[1;31m$@\033[0m" +} + +end() { + echo -e "\nExiting...\n" + exit 0 +} + +continue() { + show_question "\nDo you want to continue? (Y)es, (N)o : \n" + read INPUT + case $INPUT in + ( [Yy]* ) ;; + ( [Nn]* ) end;; + ( * ) show_error "\nSorry, try again."; continue;; + esac +} + +replace() { + show_question "\nFound an existing installation. Replace it? (Y)es, (N)o :\n" + read INPUT + case $INPUT in + ( [Yy]* ) rm -rf "$@/Bibata*" 2>/dev/null;; + ( [Nn]* ) ;; + ( * ) show_error "\tSorry, try again."; replace $@;; + esac +} + +install() { + + # PREVIEW + + # Show destination directory + echo -e "\nBibata 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/Bibata ]]; then + replace $DEST_DIR + fi + + echo -e "\nInstalling Bibata..." + + # Copying files + cp -rf $Bibata_Classic $DEST_DIR + cp -rf $Bibata_Oil $DEST_DIR + cp -rf $Bibata_Ice $DEST_DIR + cp -rf $Bibata_Amber $DEST_DIR + chmod -R 755 $DEST_DIR/Bibata_* + + + + echo "Installation complete!" + echo "Do not forget you have to set Bibata Cursor." +} + +remove() { + + # PREVIEW + + # Show installation directory + if [[ -d $DEST_DIR/Bibata_Classic || -d $DEST_DIR/Bibata_Oil || -d $DEST_DIR/Bibata_Ice || -d $DEST_DIR/Bibata_Amber ]]; then + echo -e "\nBibata Cursor 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 "\nBibata Cursor is not installed in:\n" + show_dir "\t$DEST_DIR\n" + end + fi + + # REMOVE + + echo -e "\nRemoving Bibata..." + + # Removing files + rm -rf $DEST_DIR/Bibata_Classic + rm -rf $DEST_DIR/Bibata_Oil + rm -rf $DEST_DIR/Bibata_Ice + rm -rf $DEST_DIR/Bibata_Amber + + echo "Removing complete!" + echo "I hope to see you soon." +} + +main() { + show_question "What you want to do: (I)nstall, (R)emove : \n" + read INPUT + case $INPUT in + ( [Ii]* ) install;; + ( [Rr]* ) remove;; + ( * ) show_error "\nSorry, try again."; main;; + esac +} + +ROOT_UID=0 +DEST_DIR= +Bibata_Classic=./Bibata_Classic/out/X11/Bibata_Classic +Bibata_Oil=./Bibata_Oil/out/X11/Bibata_Oil +Bibata_Ice=./Bibata_Ice/out/X11/Bibata_Ice +Bibata_Amber=./Bibata_Amber/out/X11/Bibata_Amber +cd "$( dirname "${BASH_SOURCE[0]}" )" || exit + +# 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 "| Bibata Cursor Installer Script |" +echo -e "+---------------------------------------------+\n\e[0m" + +main