use gum for pretty prompts
This commit is contained in:
parent
627d496fb6
commit
37a6873ac3
249
install.sh
249
install.sh
|
|
@ -17,73 +17,134 @@ log() {
|
||||||
"$color" "$(date '+%H:%M:%S')" "$level" "$reset" "$*" >&2
|
"$color" "$(date '+%H:%M:%S')" "$level" "$reset" "$*" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prevent user from running this script as root
|
|
||||||
|
## Prevent user from running this script as root
|
||||||
if [[ "$EUID" -eq 0 ]]; then
|
if [[ "$EUID" -eq 0 ]]; then
|
||||||
log ERROR "This script must NOT be run as root."
|
log ERROR "This script must NOT be run as root."
|
||||||
log INFO "If you need elevated privileges, the script will ask for sudo when required."
|
log INFO "If you need elevated privileges, the script will ask for sudo when required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
## Check if gum is installed
|
||||||
|
if ! command -v gum >/dev/null 2>&1; then
|
||||||
|
echo "gum is required. Install it first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Check if git is installed
|
||||||
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
|
echo "git is required. Install it first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
currentDir="$(dirname "$(readlink -f "$0")")"
|
currentDir="$(dirname "$(readlink -f "$0")")"
|
||||||
cd "$currentDir"
|
cd "$currentDir"
|
||||||
|
|
||||||
## Install necessary desktop packages
|
|
||||||
source "$currentDir/packages/pkg_desktop.sh"
|
choose_packages() {
|
||||||
|
local -n arr=$1
|
||||||
|
gum choose --no-limit \
|
||||||
|
--selected "$(IFS=,; echo "${arr[*]}")" \
|
||||||
|
"${arr[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_style() {
|
||||||
|
gum style --border rounded \
|
||||||
|
--border double \
|
||||||
|
--padding "0 1" \
|
||||||
|
"$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
gum_warn(){
|
||||||
|
gum style --bold --foreground 196 "⚠ $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
gum_to_array() {
|
||||||
|
mapfile -t "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
#################
|
||||||
|
## GATEKEEPING ##
|
||||||
|
#################
|
||||||
|
|
||||||
|
DISCLAIMER=$(gum style \
|
||||||
|
--border double \
|
||||||
|
--border-foreground 196 \
|
||||||
|
--padding "1 2" \
|
||||||
|
--bold \
|
||||||
|
"⚠️ DISCLAIMER
|
||||||
|
|
||||||
|
This script is provided AS IS, WITHOUT ANY WARRANTY.
|
||||||
|
There is NO guarantee that it will work on your system.
|
||||||
|
|
||||||
|
It may:
|
||||||
|
• Modify system files
|
||||||
|
• Overwrite or DELETE existing configuration
|
||||||
|
• Potentially break your setup
|
||||||
|
|
||||||
|
You are STRONGLY ADVISED to back up:
|
||||||
|
• ~/.config
|
||||||
|
• ~/.local
|
||||||
|
• /etc (if modified)
|
||||||
|
|
||||||
|
Proceed at your OWN RISK."
|
||||||
|
)
|
||||||
|
|
||||||
|
gum confirm --default=false "$DISCLAIMER
|
||||||
|
|
||||||
|
Do you understand the risks and want to continue?" || exit 1
|
||||||
|
|
||||||
|
|
||||||
|
###########
|
||||||
|
## UTILS ##
|
||||||
|
###########
|
||||||
source "$currentDir/packages/pkg_utils.sh"
|
source "$currentDir/packages/pkg_utils.sh"
|
||||||
log INFO "Starting Script"
|
prompt_style "Important utilities (Most likely go with defaults)"
|
||||||
log INFO "Installing necessary packages for hyprland"
|
gum_to_array UTILITY_PKGS < <(choose_packages pkg_utils)
|
||||||
sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}"
|
|
||||||
|
|
||||||
## Install dev tools
|
|
||||||
read -rp "Do you wish to install development tools? [y/N]" install_dev_tools
|
###############
|
||||||
if [[ $install_dev_tools == y ]]; then
|
## DEV TOOLS ##
|
||||||
log INFO "Installing development tools"
|
###############
|
||||||
source "$currentDir/packages/pkg_dev_tools.sh"
|
source "$currentDir/packages/pkg_dev_tools.sh"
|
||||||
sudo pacman -S --needed "${pkg_dev_tools[@]}"
|
prompt_style "Select Development Tools"
|
||||||
fi
|
gum_to_array DEV_PKGS < <(choose_packages pkg_dev_tools)
|
||||||
|
|
||||||
## Install optional packages
|
|
||||||
read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg
|
#######################
|
||||||
if [[ $install_optional_pkg == y ]]; then
|
## OPTIONAL PACKAGES ##
|
||||||
log INFO "Installing development tools"
|
#######################
|
||||||
source "$currentDir/packages/pkg_optional.sh"
|
source "$currentDir/packages/pkg_optional.sh"
|
||||||
sudo pacman -S --needed "${pkg_optional[@]}"
|
prompt_style "Select Optional Desktop Packages"
|
||||||
fi
|
gum_to_array OPTIONAL_PKGS < <(choose_packages pkg_optional)
|
||||||
|
|
||||||
## Install nvidia drivers
|
|
||||||
read -rp "Do you wish to install GPU drivers? (Intel & Nvidia) [y/N]" install_gpu_drivers
|
#################
|
||||||
if [[ $install_gpu_drivers == y ]]; then
|
## GPU DRIVERS ##
|
||||||
log INFO "Installing GPU Drivers"
|
#################
|
||||||
source "$currentDir/packages/pkg_gpu.sh"
|
source "$currentDir/packages/pkg_gpu.sh"
|
||||||
sudo pacman -S --needed "${pkg_gpu[@]}"
|
prompt_style "Select GPU drivers"
|
||||||
fi
|
gum_to_array GPU_PKGS < <(choose_packages pkg_gpu)
|
||||||
|
|
||||||
|
##########################
|
||||||
|
## Configure Everything ##
|
||||||
|
##########################
|
||||||
|
WARNING=$(gum style \
|
||||||
|
--border double \
|
||||||
|
--border-foreground 196 \
|
||||||
|
--padding "1 2" \
|
||||||
|
--bold \
|
||||||
|
"⚠️ This will DELETE any conflicting files and replace them with symlinks from this repo.
|
||||||
|
Make sure you have already backed up all your existing config files (~/.config)")
|
||||||
|
|
||||||
## Install aur packages
|
if gum confirm --default=false "$WARNING
|
||||||
read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg
|
|
||||||
if [[ $install_aur_pkg == y ]]; then
|
|
||||||
## Install paru if it isn't already installed
|
|
||||||
if ! command -v paru >/dev/null 2>&1; then
|
|
||||||
log INFO "Installing Paru (AUR package manager)"
|
|
||||||
git clone https://aur.archlinux.org/paru.git
|
|
||||||
cd paru
|
|
||||||
makepkg -sri
|
|
||||||
cd ..
|
|
||||||
rm -rf paru
|
|
||||||
else
|
|
||||||
log INFO "Skipping paru (already in PATH)"
|
|
||||||
fi
|
|
||||||
## Install aur packages
|
|
||||||
source "$currentDir/packages/pkg_aur.sh"
|
|
||||||
paru -S --needed "${pkg_aur[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
Proceed with system configuration (stow, nvim, shell, keyd)?"; then
|
||||||
## Setup dotfiles
|
###################
|
||||||
log WARN "This will DELETE any conflicting files and replace them with symlinks from this repo."
|
## Stow dotfiles ##
|
||||||
log WARN "Make sure you have already backed up all your existing config files (~/.config)"
|
###################
|
||||||
read -rp "Continue with stow (y/N): " confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log INFO "Detecting conflicts..."
|
log INFO "Detecting conflicts..."
|
||||||
conflicts=$(stow . --no-folding -nv 2>&1 | \
|
conflicts=$(stow . --no-folding -nv 2>&1 | \
|
||||||
sed -n 's/.*existing target \(.*\) since neither.*/\1/p')
|
sed -n 's/.*existing target \(.*\) since neither.*/\1/p')
|
||||||
|
|
@ -111,48 +172,104 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||||
&& log INFO "✅ Dotfiles stowed with overwrite." \
|
&& log INFO "✅ Dotfiles stowed with overwrite." \
|
||||||
|| log ERROR "Stow failed"
|
|| log ERROR "Stow failed"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
log WARN "Aborted stow, the dotfiles are not synced"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
###########################
|
||||||
## Setup neovim dotfiles
|
## Setup neovim dotfiles ##
|
||||||
read -rp "Setup neovim configuration as well? (y/N): " confirm
|
###########################
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
log INFO "Setting up neovim configuration"
|
||||||
log INFO "Taking backup of neovim config (if already exists)"
|
log INFO "Taking backup of neovim config (if already exists)"
|
||||||
mv ~/.config/nvim{,.bak}
|
mv ~/.config/nvim{,.bak}
|
||||||
mv ~/.local/share/nvim{,.bak}
|
mv ~/.local/share/nvim{,.bak}
|
||||||
mv ~/.local/state/nvim{,.bak}
|
mv ~/.local/state/nvim{,.bak}
|
||||||
mv ~/.cache/nvim{,.bak}
|
mv ~/.cache/nvim{,.bak}
|
||||||
git clone --depth=1 https://github.com/krolyxon/nvim.git ~/.config/nvim
|
git clone --depth=1 https://github.com/krolyxon/nvim.git ~/.config/nvim
|
||||||
fi
|
|
||||||
|
|
||||||
## Change default shell to zsh
|
#################################
|
||||||
|
## Change default shell to zsh ##
|
||||||
|
#################################
|
||||||
log INFO "Changing the default shell to ZSH"
|
log INFO "Changing the default shell to ZSH"
|
||||||
if [[ "$SHELL" != "$(which zsh)" ]]; then
|
if [[ "$SHELL" != "$(which zsh)" ]]; then
|
||||||
read -rp "Change default shell to ZSH? (y/N): " confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
chsh -s $(which zsh) \
|
chsh -s $(which zsh) \
|
||||||
&& log SUCCESS "Default shell successfully set to zsh" \
|
&& log SUCCESS "Default shell successfully set to zsh" \
|
||||||
|| log ERROR "Default shell could not be set to zsh"
|
|| log ERROR "Default shell could not be set to zsh"
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
log INFO "Skipping: zsh is already the default shell"
|
log INFO "Skipping: zsh is already the default shell"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
log WARN "Aborted configuration, didn't configure anything"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
##################
|
||||||
|
## AUR PACKAGES ##
|
||||||
|
##################
|
||||||
|
source "$currentDir/packages/pkg_aur.sh"
|
||||||
|
prompt_style "Select AUR packages"
|
||||||
|
gum_to_array AUR_PKGS < <(choose_packages pkg_aur)
|
||||||
|
if [[ ${#AUR_PKGS[@]} -eq 0 ]]; then
|
||||||
|
log WARN "No AUR packages selected"
|
||||||
|
else
|
||||||
|
if ! command -v paru >/dev/null 2>&1; then
|
||||||
|
log INFO "Installing Paru (AUR package manager)"
|
||||||
|
git clone https://aur.archlinux.org/paru.git
|
||||||
|
cd paru
|
||||||
|
makepkg -sri
|
||||||
|
cd ..
|
||||||
|
rm -rf paru
|
||||||
|
else
|
||||||
|
log INFO "Paru already in PATH, Skipping...."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${#AUR_PKGS[@]} -eq 0 ]]; then
|
||||||
|
log WARN "No AUR packages selected, Skipping...."
|
||||||
|
else
|
||||||
|
paru -S --needed "${AUR_PKGS[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Install and setup Keyd
|
############################
|
||||||
read -rp "Configure and enable Keyd? (y/N): " confirm
|
## Setup Keyd ##
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
############################
|
||||||
|
if command -v keyd >/dev/null 2>&1; then
|
||||||
|
if gum confirm --default=false "Configure and enable keyd? "; then
|
||||||
log INFO "Copying keyd configuration to /etc/keyd/default.conf"
|
log INFO "Copying keyd configuration to /etc/keyd/default.conf"
|
||||||
sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/
|
sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/
|
||||||
sudo systemctl enable --now keyd.service \
|
sudo systemctl enable --now keyd.service \
|
||||||
&& log SUCCESS "Successfully enabled keyd.service" \
|
&& log SUCCESS "Successfully enabled keyd.service" \
|
||||||
|| log ERROR "Couldn't enable keyd.service"
|
|| log ERROR "Couldn't enable keyd.service"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################
|
||||||
|
## Install Everything ##
|
||||||
|
########################
|
||||||
|
source "$currentDir/packages/pkg_desktop.sh"
|
||||||
|
ALL_PKGS=(
|
||||||
|
"${DEV_PKGS[@]}"
|
||||||
|
"${OPTIONAL_PKGS[@]}"
|
||||||
|
"${GPU_PKGS[@]}"
|
||||||
|
"${UTILITY_PKGS[@]}"
|
||||||
|
"${pkg_desktop[@]}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ ${#ALL_PKGS[@]} -eq 0 ]]; then
|
||||||
|
log WARN "No packages selected."
|
||||||
|
else
|
||||||
|
if gum confirm --default=false "Install all the selected packages?"; then
|
||||||
|
log INFO "Installing selected packages..."
|
||||||
|
sudo pacman -Sy --needed "${ALL_PKGS[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
gum style \
|
||||||
|
--border rounded \
|
||||||
|
--padding "1 2" \
|
||||||
|
--bold \
|
||||||
|
--foreground 42 \
|
||||||
|
"🎉 Installation Complete!
|
||||||
|
|
||||||
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
|
Your system has been successfully configured.
|
||||||
echo ""
|
|
||||||
log SUCCESS "Done!"
|
You may now reboot the system for all the changes to apply."
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
export pkg_gpu=(
|
export pkg_gpu=(
|
||||||
"intel-media-driver"
|
"intel-media-driver"
|
||||||
|
"mesa"
|
||||||
"nvidia-open"
|
"nvidia-open"
|
||||||
"nvidia-utils"
|
"nvidia-utils"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue