| 1 | #!/bin/env bash |
| 2 | |
| 3 | currentDir="$(dirname "$(readlink -f "$0")")" |
| 4 | cd "$currentDir" |
| 5 | |
| 6 | ## Install necessary desktop packages |
| 7 | source "$currentDir/packages/pkg_desktop.sh" |
| 8 | source "$currentDir/packages/pkg_utils.sh" |
| 9 | sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}" |
| 10 | |
| 11 | ## Install dev tools |
| 12 | read -rp "Do you wish to install development tools? [y/N]" install_dev_tools |
| 13 | source "$currentDir/packages/pkg_dev_tools.sh" |
| 14 | if [[ $install_dev_tools == y ]]; then |
| 15 | sudo pacman -S --needed "${pkg_dev_tools[@]}" |
| 16 | fi |
| 17 | |
| 18 | ## Install optional packages |
| 19 | read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg |
| 20 | if [[ $install_optional_pkg == y ]]; then |
| 21 | source "$currentDir/packages/pkg_optional.sh" |
| 22 | sudo pacman -S --needed "${pkg_optional[@]}" |
| 23 | fi |
| 24 | |
| 25 | ## Install nvidia drivers |
| 26 | read -rp "Do you wish to install Nvidia drivers? [y/N]" install_nvidia_drivers |
| 27 | if [[ $install_nvidia_drivers == y ]]; then |
| 28 | source "$currentDir/packages/pkg_nvidia.sh" |
| 29 | sudo pacman -S --needed "${pkg_nvidia[@]}" |
| 30 | fi |
| 31 | |
| 32 | |
| 33 | ## Install aur packages |
| 34 | read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg |
| 35 | if [[ $install_aur_pkg == y ]]; then |
| 36 | ## Install paru if it isn't already installed |
| 37 | if ! command -v paru >/dev/null 2>&1; then |
| 38 | echo "Installing paru..." |
| 39 | git clone https://aur.archlinux.org/paru-bin.git |
| 40 | cd paru-bin |
| 41 | makepkg -sri |
| 42 | cd .. |
| 43 | rm -rf paru-bin |
| 44 | else |
| 45 | echo "Skipping paru (already in PATH)" |
| 46 | fi |
| 47 | ## Install aur packages |
| 48 | source "$currentDir/packages/pkg_aur.sh" |
| 49 | paru -S --needed "${pkg_aur[@]}" |
| 50 | fi |
| 51 | |
| 52 | |
| 53 | ## Setup dotfiles |
| 54 | echo "⚠️ WARNING: This will DELETE any conflicting files and replace them with symlinks from this repo." |
| 55 | echo "Make sure you have already backed up all your existing config files (~/.config)" |
| 56 | read -rp "Continue with stow (y/N): " confirm |
| 57 | if [[ "$confirm" =~ ^[Yy]$ ]]; then |
| 58 | echo "Detecting conflicts..." |
| 59 | conflicts=$(stow . --no-folding -nv 2>&1 | \ |
| 60 | sed -n 's/.*existing target \(.*\) since neither.*/\1/p') |
| 61 | |
| 62 | if [[ -z "$conflicts" ]]; then |
| 63 | echo "No conflicts. Running stow normally..." |
| 64 | stow . --no-folding |
| 65 | echo "✅ Done." |
| 66 | else |
| 67 | echo "These paths conflict and will be removed:" |
| 68 | printf ' %s\n' $conflicts |
| 69 | read -rp "Proceed with deleting these files? (y/N): " ok |
| 70 | if [[ ! "$ok" =~ ^[Yy]$ ]]; then |
| 71 | echo "Aborted." |
| 72 | fi |
| 73 | |
| 74 | # Remove conflicts relative to $HOME |
| 75 | for path in $conflicts; do |
| 76 | echo "Removing $HOME/$path" |
| 77 | rm -rf "$HOME/$path" |
| 78 | done |
| 79 | |
| 80 | echo "Running stow..." |
| 81 | stow . --no-folding |
| 82 | echo "✅ Dotfiles stowed with overwrite." |
| 83 | fi |
| 84 | else |
| 85 | echo "Aborted stow" |
| 86 | fi |
| 87 | |
| 88 | |
| 89 | ## Setup neovim dotfiles |
| 90 | read -rp "Clone neovim dotfiles as well? (y/N): " confirm |
| 91 | if [[ "$confirm" =~ ^[Yy]$ ]]; then |
| 92 | echo "Taking backup of neovim config (if already exists)" |
| 93 | mv ~/.config/nvim{,.bak} |
| 94 | mv ~/.local/share/nvim{,.bak} |
| 95 | mv ~/.local/state/nvim{,.bak} |
| 96 | mv ~/.cache/nvim{,.bak} |
| 97 | git clone --depth=1 git@github.com:krolyxon/nvim.git ~/.config/nvim |
| 98 | fi |
| 99 | |
| 100 | ## Change default shell to zsh |
| 101 | if [[ "$SHELL" != "$(which zsh)" ]]; then |
| 102 | read -rp "Change default shell to ZSH? (y/N): " confirm |
| 103 | if [[ "$confirm" =~ ^[Yy]$ ]]; then |
| 104 | echo "Changing default shell to zsh..." |
| 105 | chsh -s $(which zsh) |
| 106 | fi |
| 107 | else |
| 108 | echo "Skipping: zsh is already the default shell" |
| 109 | fi |
| 110 | |
| 111 | |
| 112 | printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = |
| 113 | echo "" |
| 114 | echo "Done! 😊" |