aurora37a6873
use gum for pretty prompts
+194 −76
2 files changed
- M install.sh +193 −76
- M packages/pkg_gpu.sh +1 −0
| @@ -17,73 +17,134 @@ log() { | |||
| 17 | 17 | "$color" "$(date '+%H:%M:%S')" "$level" "$reset" "$*" >&2 | |
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | − | # Prevent user from running this script as root | |
| 20 | + | ||
| 21 | + | ## Prevent user from running this script as root | |
| 21 | 22 | if [[ "$EUID" -eq 0 ]]; then | |
| 22 | 23 | log ERROR "This script must NOT be run as root." | |
| 23 | 24 | log INFO "If you need elevated privileges, the script will ask for sudo when required." | |
| 24 | 25 | exit 1 | |
| 25 | 26 | fi | |
| 26 | 27 | ||
| 28 | + | ||
| 29 | + | ## Check if gum is installed | |
| 30 | + | if ! command -v gum >/dev/null 2>&1; then | |
| 31 | + | echo "gum is required. Install it first." | |
| 32 | + | exit 1 | |
| 33 | + | fi | |
| 34 | + | ||
| 35 | + | ## Check if git is installed | |
| 36 | + | if ! command -v git >/dev/null 2>&1; then | |
| 37 | + | echo "git is required. Install it first." | |
| 38 | + | exit 1 | |
| 39 | + | fi | |
| 40 | + | ||
| 41 | + | ||
| 27 | 42 | currentDir="$(dirname "$(readlink -f "$0")")" | |
| 28 | 43 | cd "$currentDir" | |
| 29 | 44 | ||
| 30 | − | ## Install necessary desktop packages | |
| 31 | − | source "$currentDir/packages/pkg_desktop.sh" | |
| 45 | + | ||
| 46 | + | choose_packages() { | |
| 47 | + | local -n arr=$1 | |
| 48 | + | gum choose --no-limit \ | |
| 49 | + | --selected "$(IFS=,; echo "${arr[*]}")" \ | |
| 50 | + | "${arr[@]}" | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | prompt_style() { | |
| 54 | + | gum style --border rounded \ | |
| 55 | + | --border double \ | |
| 56 | + | --padding "0 1" \ | |
| 57 | + | "$1" | |
| 58 | + | } | |
| 59 | + | ||
| 60 | + | gum_warn(){ | |
| 61 | + | gum style --bold --foreground 196 "⚠ $1" | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | gum_to_array() { | |
| 65 | + | mapfile -t "$1" | |
| 66 | + | } | |
| 67 | + | ||
| 68 | + | ################# | |
| 69 | + | ## GATEKEEPING ## | |
| 70 | + | ################# | |
| 71 | + | ||
| 72 | + | DISCLAIMER=$(gum style \ | |
| 73 | + | --border double \ | |
| 74 | + | --border-foreground 196 \ | |
| 75 | + | --padding "1 2" \ | |
| 76 | + | --bold \ | |
| 77 | + | "⚠️ DISCLAIMER | |
| 78 | + | ||
| 79 | + | This script is provided AS IS, WITHOUT ANY WARRANTY. | |
| 80 | + | There is NO guarantee that it will work on your system. | |
| 81 | + | ||
| 82 | + | It may: | |
| 83 | + | • Modify system files | |
| 84 | + | • Overwrite or DELETE existing configuration | |
| 85 | + | • Potentially break your setup | |
| 86 | + | ||
| 87 | + | You are STRONGLY ADVISED to back up: | |
| 88 | + | • ~/.config | |
| 89 | + | • ~/.local | |
| 90 | + | • /etc (if modified) | |
| 91 | + | ||
| 92 | + | Proceed at your OWN RISK." | |
| 93 | + | ) | |
| 94 | + | ||
| 95 | + | gum confirm --default=false "$DISCLAIMER | |
| 96 | + | ||
| 97 | + | Do you understand the risks and want to continue?" || exit 1 | |
| 98 | + | ||
| 99 | + | ||
| 100 | + | ########### | |
| 101 | + | ## UTILS ## | |
| 102 | + | ########### | |
| 32 | 103 | source "$currentDir/packages/pkg_utils.sh" | |
| 33 | − | log INFO "Starting Script" | |
| 34 | − | log INFO "Installing necessary packages for hyprland" | |
| 35 | − | sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}" | |
| 36 | − | ||
| 37 | − | ## Install dev tools | |
| 38 | − | read -rp "Do you wish to install development tools? [y/N]" install_dev_tools | |
| 39 | − | if [[ $install_dev_tools == y ]]; then | |
| 40 | − | log INFO "Installing development tools" | |
| 41 | − | source "$currentDir/packages/pkg_dev_tools.sh" | |
| 42 | − | sudo pacman -S --needed "${pkg_dev_tools[@]}" | |
| 43 | − | fi | |
| 104 | + | prompt_style "Important utilities (Most likely go with defaults)" | |
| 105 | + | gum_to_array UTILITY_PKGS < <(choose_packages pkg_utils) | |
| 44 | 106 | ||
| 45 | − | ## Install optional packages | |
| 46 | − | read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg | |
| 47 | − | if [[ $install_optional_pkg == y ]]; then | |
| 48 | − | log INFO "Installing development tools" | |
| 49 | − | source "$currentDir/packages/pkg_optional.sh" | |
| 50 | − | sudo pacman -S --needed "${pkg_optional[@]}" | |
| 51 | − | fi | |
| 52 | 107 | ||
| 53 | − | ## Install nvidia drivers | |
| 54 | − | read -rp "Do you wish to install GPU drivers? (Intel & Nvidia) [y/N]" install_gpu_drivers | |
| 55 | − | if [[ $install_gpu_drivers == y ]]; then | |
| 56 | − | log INFO "Installing GPU Drivers" | |
| 57 | − | source "$currentDir/packages/pkg_gpu.sh" | |
| 58 | − | sudo pacman -S --needed "${pkg_gpu[@]}" | |
| 59 | − | fi | |
| 108 | + | ############### | |
| 109 | + | ## DEV TOOLS ## | |
| 110 | + | ############### | |
| 111 | + | source "$currentDir/packages/pkg_dev_tools.sh" | |
| 112 | + | prompt_style "Select Development Tools" | |
| 113 | + | gum_to_array DEV_PKGS < <(choose_packages pkg_dev_tools) | |
| 60 | 114 | ||
| 61 | 115 | ||
| 62 | − | ## Install aur packages | |
| 63 | − | read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg | |
| 64 | − | if [[ $install_aur_pkg == y ]]; then | |
| 65 | − | ## Install paru if it isn't already installed | |
| 66 | − | if ! command -v paru >/dev/null 2>&1; then | |
| 67 | − | log INFO "Installing Paru (AUR package manager)" | |
| 68 | − | git clone https://aur.archlinux.org/paru.git | |
| 69 | − | cd paru | |
| 70 | − | makepkg -sri | |
| 71 | − | cd .. | |
| 72 | − | rm -rf paru | |
| 73 | − | else | |
| 74 | − | log INFO "Skipping paru (already in PATH)" | |
| 75 | − | fi | |
| 76 | − | ## Install aur packages | |
| 77 | − | source "$currentDir/packages/pkg_aur.sh" | |
| 78 | − | paru -S --needed "${pkg_aur[@]}" | |
| 79 | − | fi | |
| 116 | + | ####################### | |
| 117 | + | ## OPTIONAL PACKAGES ## | |
| 118 | + | ####################### | |
| 119 | + | source "$currentDir/packages/pkg_optional.sh" | |
| 120 | + | prompt_style "Select Optional Desktop Packages" | |
| 121 | + | gum_to_array OPTIONAL_PKGS < <(choose_packages pkg_optional) | |
| 122 | + | ||
| 80 | 123 | ||
| 124 | + | ################# | |
| 125 | + | ## GPU DRIVERS ## | |
| 126 | + | ################# | |
| 127 | + | source "$currentDir/packages/pkg_gpu.sh" | |
| 128 | + | prompt_style "Select GPU drivers" | |
| 129 | + | gum_to_array GPU_PKGS < <(choose_packages pkg_gpu) | |
| 81 | 130 | ||
| 82 | − | ## Setup dotfiles | |
| 83 | − | log WARN "This will DELETE any conflicting files and replace them with symlinks from this repo." | |
| 84 | − | log WARN "Make sure you have already backed up all your existing config files (~/.config)" | |
| 85 | − | read -rp "Continue with stow (y/N): " confirm | |
| 86 | − | if [[ "$confirm" =~ ^[Yy]$ ]]; then | |
| 131 | + | ########################## | |
| 132 | + | ## Configure Everything ## | |
| 133 | + | ########################## | |
| 134 | + | WARNING=$(gum style \ | |
| 135 | + | --border double \ | |
| 136 | + | --border-foreground 196 \ | |
| 137 | + | --padding "1 2" \ | |
| 138 | + | --bold \ | |
| 139 | + | "⚠️ This will DELETE any conflicting files and replace them with symlinks from this repo. | |
| 140 | + | Make sure you have already backed up all your existing config files (~/.config)") | |
| 141 | + | ||
| 142 | + | if gum confirm --default=false "$WARNING | |
| 143 | + | ||
| 144 | + | Proceed with system configuration (stow, nvim, shell, keyd)?"; then | |
| 145 | + | ################### | |
| 146 | + | ## Stow dotfiles ## | |
| 147 | + | ################### | |
| 87 | 148 | log INFO "Detecting conflicts..." | |
| 88 | 149 | conflicts=$(stow . --no-folding -nv 2>&1 | \ | |
| 89 | 150 | sed -n 's/.*existing target \(.*\) since neither.*/\1/p') | |
| @@ -111,48 +172,104 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then | |||
| 111 | 172 | && log INFO "✅ Dotfiles stowed with overwrite." \ | |
| 112 | 173 | || log ERROR "Stow failed" | |
| 113 | 174 | fi | |
| 114 | − | else | |
| 115 | − | log WARN "Aborted stow, the dotfiles are not synced" | |
| 116 | − | fi | |
| 117 | 175 | ||
| 118 | − | ||
| 119 | − | ## Setup neovim dotfiles | |
| 120 | − | read -rp "Setup neovim configuration as well? (y/N): " confirm | |
| 121 | − | if [[ "$confirm" =~ ^[Yy]$ ]]; then | |
| 176 | + | ########################### | |
| 177 | + | ## Setup neovim dotfiles ## | |
| 178 | + | ########################### | |
| 179 | + | log INFO "Setting up neovim configuration" | |
| 122 | 180 | log INFO "Taking backup of neovim config (if already exists)" | |
| 123 | 181 | mv ~/.config/nvim{,.bak} | |
| 124 | 182 | mv ~/.local/share/nvim{,.bak} | |
| 125 | 183 | mv ~/.local/state/nvim{,.bak} | |
| 126 | 184 | mv ~/.cache/nvim{,.bak} | |
| 127 | 185 | git clone --depth=1 https://github.com/krolyxon/nvim.git ~/.config/nvim | |
| 128 | − | fi | |
| 129 | 186 | ||
| 130 | − | ## Change default shell to zsh | |
| 131 | − | log INFO "Changing the default shell to ZSH" | |
| 132 | − | if [[ "$SHELL" != "$(which zsh)" ]]; then | |
| 133 | − | read -rp "Change default shell to ZSH? (y/N): " confirm | |
| 134 | − | if [[ "$confirm" =~ ^[Yy]$ ]]; then | |
| 187 | + | ################################# | |
| 188 | + | ## Change default shell to zsh ## | |
| 189 | + | ################################# | |
| 190 | + | log INFO "Changing the default shell to ZSH" | |
| 191 | + | if [[ "$SHELL" != "$(which zsh)" ]]; then | |
| 135 | 192 | chsh -s $(which zsh) \ | |
| 136 | 193 | && log SUCCESS "Default shell successfully set to zsh" \ | |
| 137 | 194 | || log ERROR "Default shell could not be set to zsh" | |
| 195 | + | else | |
| 196 | + | log INFO "Skipping: zsh is already the default shell" | |
| 138 | 197 | fi | |
| 139 | 198 | else | |
| 140 | − | log INFO "Skipping: zsh is already the default shell" | |
| 199 | + | log WARN "Aborted configuration, didn't configure anything" | |
| 200 | + | exit 1 | |
| 141 | 201 | fi | |
| 142 | 202 | ||
| 203 | + | ################## | |
| 204 | + | ## AUR PACKAGES ## | |
| 205 | + | ################## | |
| 206 | + | source "$currentDir/packages/pkg_aur.sh" | |
| 207 | + | prompt_style "Select AUR packages" | |
| 208 | + | gum_to_array AUR_PKGS < <(choose_packages pkg_aur) | |
| 209 | + | if [[ ${#AUR_PKGS[@]} -eq 0 ]]; then | |
| 210 | + | log WARN "No AUR packages selected" | |
| 211 | + | else | |
| 212 | + | if ! command -v paru >/dev/null 2>&1; then | |
| 213 | + | log INFO "Installing Paru (AUR package manager)" | |
| 214 | + | git clone https://aur.archlinux.org/paru.git | |
| 215 | + | cd paru | |
| 216 | + | makepkg -sri | |
| 217 | + | cd .. | |
| 218 | + | rm -rf paru | |
| 219 | + | else | |
| 220 | + | log INFO "Paru already in PATH, Skipping...." | |
| 221 | + | fi | |
| 143 | 222 | ||
| 144 | − | ## Install and setup Keyd | |
| 145 | − | read -rp "Configure and enable Keyd? (y/N): " confirm | |
| 146 | − | if [[ "$confirm" =~ ^[Yy]$ ]]; then | |
| 147 | − | log INFO "Copying keyd configuration to /etc/keyd/default.conf" | |
| 148 | − | sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/ | |
| 149 | − | sudo systemctl enable --now keyd.service \ | |
| 150 | − | && log SUCCESS "Successfully enabled keyd.service" \ | |
| 151 | − | || log ERROR "Couldn't enable keyd.service" | |
| 223 | + | if [[ ${#AUR_PKGS[@]} -eq 0 ]]; then | |
| 224 | + | log WARN "No AUR packages selected, Skipping...." | |
| 225 | + | else | |
| 226 | + | paru -S --needed "${AUR_PKGS[@]}" | |
| 227 | + | fi | |
| 152 | 228 | fi | |
| 153 | 229 | ||
| 154 | 230 | ||
| 231 | + | ############################ | |
| 232 | + | ## Setup Keyd ## | |
| 233 | + | ############################ | |
| 234 | + | if command -v keyd >/dev/null 2>&1; then | |
| 235 | + | if gum confirm --default=false "Configure and enable keyd? "; then | |
| 236 | + | log INFO "Copying keyd configuration to /etc/keyd/default.conf" | |
| 237 | + | sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/ | |
| 238 | + | sudo systemctl enable --now keyd.service \ | |
| 239 | + | && log SUCCESS "Successfully enabled keyd.service" \ | |
| 240 | + | || log ERROR "Couldn't enable keyd.service" | |
| 241 | + | fi | |
| 242 | + | fi | |
| 243 | + | ||
| 244 | + | ######################## | |
| 245 | + | ## Install Everything ## | |
| 246 | + | ######################## | |
| 247 | + | source "$currentDir/packages/pkg_desktop.sh" | |
| 248 | + | ALL_PKGS=( | |
| 249 | + | "${DEV_PKGS[@]}" | |
| 250 | + | "${OPTIONAL_PKGS[@]}" | |
| 251 | + | "${GPU_PKGS[@]}" | |
| 252 | + | "${UTILITY_PKGS[@]}" | |
| 253 | + | "${pkg_desktop[@]}" | |
| 254 | + | ) | |
| 255 | + | ||
| 256 | + | if [[ ${#ALL_PKGS[@]} -eq 0 ]]; then | |
| 257 | + | log WARN "No packages selected." | |
| 258 | + | else | |
| 259 | + | if gum confirm --default=false "Install all the selected packages?"; then | |
| 260 | + | log INFO "Installing selected packages..." | |
| 261 | + | sudo pacman -Sy --needed "${ALL_PKGS[@]}" | |
| 262 | + | fi | |
| 263 | + | fi | |
| 264 | + | ||
| 265 | + | ||
| 266 | + | gum style \ | |
| 267 | + | --border rounded \ | |
| 268 | + | --padding "1 2" \ | |
| 269 | + | --bold \ | |
| 270 | + | --foreground 42 \ | |
| 271 | + | "🎉 Installation Complete! | |
| 272 | + | ||
| 273 | + | Your system has been successfully configured. | |
| 155 | 274 | ||
| 156 | − | printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = | |
| 157 | − | echo "" | |
| 158 | − | log SUCCESS "Done!" | |
| 275 | + | You may now reboot the system for all the changes to apply." | |
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | export pkg_gpu=( | |
| 4 | 4 | "intel-media-driver" | |
| 5 | + | "mesa" | |
| 5 | 6 | "nvidia-open" | |
| 6 | 7 | "nvidia-utils" | |
| 7 | 8 | ) | |