From c1288d027c5abd1f2d0ddfe270c3b8b92f4c8873 Mon Sep 17 00:00:00 2001 From: Marin Kitagawa <49131888+Marin-Kitagawa@users.noreply.github.com> Date: Mon, 17 Apr 2023 00:56:26 +0530 Subject: [PATCH 1/4] Enhanced the installation script --- install.sh | 90 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 48a3659..e263c1f 100755 --- a/install.sh +++ b/install.sh @@ -1,29 +1,91 @@ #!/bin/bash -# Update system and install Git -sudo pacman -Syu git --noconfirm +if [[ "$(id -u)" -eq 0 ]]; then + echo "This script must not be run as root" + exit 1 +fi + +is_installed() { + pacman -Qi "$1" &>/dev/null + return $? +} + +# Update system +sudo pacman -Syu + +if ! is_installed git; then + sudo pacman -S git --noconfirm +else + echo "git v$(git -v | cut -d' ' -f3) is already installed in your system" +fi # Clone and install Paru -git clone https://aur.archlinux.org/paru-bin.git && cd paru-bin && makepkg -si --noconfirm && cd .. +if command -v paru &>/dev/null; then + echo "paru $(paru -V | cut -d' ' -f2) is already installed in your system" +else + if command -v yay &>/dev/null; then + "yay $(yay -V | cut -d' ' -f2) is installed in your system" + else + echo "Both yay and paru are not present in your system." + echo "Installing paru..." + git clone https://aur.archlinux.org/paru-bin.git && cd paru-bin && makepkg -si --noconfirm && cd .. + fi +fi -# Install necessary packages using Paru -paru -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git sddm --noconfirm +# Update and install dependencies +if command -v paru &>/dev/null +then + paru -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git --noconfirm --needed + if ! is_installed lightdm && ! is_installed sddm + paru -S sddm + fi +else + if command -v yay &>/dev/null + then + yay -Syu base-devel qtile python-psutil pywal-git picom-jonaburg-fix dunst zsh starship mpd ncmpcpp playerctl brightnessctl alacritty pfetch htop flameshot thunar roficlip rofi ranger cava pulseaudio pavucontrol neovim vim git sddm --noconfirm --needed + if ! is_installed lightdm && ! is_installed sddm + yay -S sddm + fi +fi -# Set Zsh as the default shell -chsh -s $(which zsh) +# Check and set Zsh as the default shell +[[ "$(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) " =~ "zsh " ]] || chsh -s $(which zsh) # Install Oh My Zsh -sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended +if [ ! -d ~/.oh-my-zsh/ ]; then + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended +else + omz update +fi # Install Zsh plugins -git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +[[ "${plugins[*]} " =~ "zsh-autosuggestions " ]] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +[[ "${plugins[*]} " =~ "zsh-syntax-highlighting" ]] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting + +# Make Backup +echo "Backing up the current configs. All the backeup files will be available at ~/.cozy.bak" +mkdir ~/.cozy.bak +for folder in .config/*; do + rel=$(echo $folder | rev | cut -d/ -f1 | rev) + if [ -d ~/.config/$rel ]; then + echo "Backing up ~/.config/$rel" + cp -r ~/.config/$rel ~/.cozy.bak + echo "Backed up ~/.config/$rel" successfully. + echo "Removing old config for $rel" + rm -rf ~/.config/$rel + echo "Copying new config for $rel" + cp -r .config/$rel ~/.config/$rel + else + echo "Folder ~/.config/$rel doesn't exist" + echo "Copying new config for $rel" + cp -r .config/$rel ~/.config/$rel + fi +done -# Clone and install Cozytile -p -R ./. ~/ cp -R ~/Fonts/Jetbrains/ttf/. ~/.local/share/fonts/ # Enable and start SDDM -sudo systemctl enable sddm && sudo systemctl start sddm - +if is_installed sddm + sudo systemctl enable sddm && sudo systemctl start sddm +fi From 15af14db5fe51537ee6b728ae30b4e187fa67115 Mon Sep 17 00:00:00 2001 From: Marin Kitagawa <49131888+Marin-Kitagawa@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:45:19 +0530 Subject: [PATCH 2/4] Corrected a minor error --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e263c1f..4d5ca59 100755 --- a/install.sh +++ b/install.sh @@ -78,7 +78,7 @@ for folder in .config/*; do else echo "Folder ~/.config/$rel doesn't exist" echo "Copying new config for $rel" - cp -r .config/$rel ~/.config/$rel + cp -r .config/$rel ~/.config fi done From ec76d69dc3b4dce320a04249d6839de5bbee7626 Mon Sep 17 00:00:00 2001 From: Marin Kitagawa <49131888+Marin-Kitagawa@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:46:29 +0530 Subject: [PATCH 3/4] Update install.sh Made a correction in `cp` command --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 4d5ca59..ae292e4 100755 --- a/install.sh +++ b/install.sh @@ -74,7 +74,7 @@ for folder in .config/*; do echo "Removing old config for $rel" rm -rf ~/.config/$rel echo "Copying new config for $rel" - cp -r .config/$rel ~/.config/$rel + cp -r .config/$rel ~/.config else echo "Folder ~/.config/$rel doesn't exist" echo "Copying new config for $rel" From 191c2c9347d918a159932b6094ca41067c65cdbc Mon Sep 17 00:00:00 2001 From: Marin Kitagawa <49131888+Marin-Kitagawa@users.noreply.github.com> Date: Mon, 17 Apr 2023 04:01:49 +0530 Subject: [PATCH 4/4] Update install.sh A very minor correction in `zsh` plugins --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ae292e4..0b7f111 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,7 @@ fi # Install Zsh plugins [[ "${plugins[*]} " =~ "zsh-autosuggestions " ]] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -[[ "${plugins[*]} " =~ "zsh-syntax-highlighting" ]] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +[[ "${plugins[*]} " =~ "zsh-syntax-highlighting " ]] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # Make Backup echo "Backing up the current configs. All the backeup files will be available at ~/.cozy.bak"