Krolyxon
Commit b1341a6

Branches

Refs →

aurorainstall.sh

149 lines · 4.7 KB · Bourne Again Shell (bash)

1#!/bin/env bash
2
3log() {
4 local level="$1"
5 shift
6
7 case "$level" in
8 INFO) color='\033[0;32m' ;;
9 WARN) color='\033[0;33m' ;;
10 ERROR) color='\033[0;31m' ;;
11 *) color='\033[0m' ;;
12 esac
13
14 printf '%b[%s] [%s]%b %s\n' \
15 "$color" "$(date '+%H:%M:%S')" "$level" '\033[0m' "$*"
16}
17
18currentDir="$(dirname "$(readlink -f "$0")")"
19cd "$currentDir"
20
21## Install necessary desktop packages
22source "$currentDir/packages/pkg_desktop.sh"
23source "$currentDir/packages/pkg_utils.sh"
24log INFO "Starting Script"
25log INFO "Installing necessary packages for hyprland"
26sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}"
27
28## Install dev tools
29read -rp "Do you wish to install development tools? [y/N]" install_dev_tools
30if [[ $install_dev_tools == y ]]; then
31 log INFO "Installing development tools"
32 source "$currentDir/packages/pkg_dev_tools.sh"
33 sudo pacman -S --needed "${pkg_dev_tools[@]}"
34fi
35
36## Install optional packages
37read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg
38if [[ $install_optional_pkg == y ]]; then
39 log INFO "Installing development tools"
40 source "$currentDir/packages/pkg_optional.sh"
41 sudo pacman -S --needed "${pkg_optional[@]}"
42fi
43
44## Install nvidia drivers
45read -rp "Do you wish to install Nvidia drivers? [y/N]" install_nvidia_drivers
46if [[ $install_nvidia_drivers == y ]]; then
47 log INFO "Installing Nvidia Drivers"
48 source "$currentDir/packages/pkg_nvidia.sh"
49 sudo pacman -S --needed "${pkg_nvidia[@]}"
50fi
51
52
53## Install aur packages
54read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg
55if [[ $install_aur_pkg == y ]]; then
56 ## Install paru if it isn't already installed
57 if ! command -v paru >/dev/null 2>&1; then
58 log INFO "Installing Paru (AUR package manager)"
59 git clone https://aur.archlinux.org/paru.git
60 cd paru
61 makepkg -sri
62 cd ..
63 rm -rf paru
64 else
65 log INFO "Skipping paru (already in PATH)"
66 fi
67 ## Install aur packages
68 source "$currentDir/packages/pkg_aur.sh"
69 paru -S --needed "${pkg_aur[@]}"
70fi
71
72
73## Setup dotfiles
74log WARN "This will DELETE any conflicting files and replace them with symlinks from this repo."
75log WARN "Make sure you have already backed up all your existing config files (~/.config)"
76read -rp "Continue with stow (y/N): " confirm
77if [[ "$confirm" =~ ^[Yy]$ ]]; then
78 log INFO "Detecting conflicts..."
79 conflicts=$(stow . --no-folding -nv 2>&1 | \
80 sed -n 's/.*existing target \(.*\) since neither.*/\1/p')
81
82 if [[ -z "$conflicts" ]]; then
83 log INFO "No conflicts. Running stow normally..."
84 stow . --no-folding \
85 && log INFO "Dotfiles stowed successfully" \
86 || log ERROR "Stow failed"
87 else
88 log WARN "These paths conflict and will be removed:"
89 printf ' %s\n' $conflicts
90 read -rp "Proceed with deleting these files? (y/N): " ok
91 if [[ ! "$ok" =~ ^[Yy]$ ]]; then
92 echo "Aborted."
93 fi
94
95 # Remove conflicts relative to $HOME
96 for path in $conflicts; do
97 rm -rf "$HOME/$path" && log INFO "Removed $HOME/$path"
98 done
99
100 log INFO "Running stow..."
101 stow . --no-folding \
102 && log INFO "✅ Dotfiles stowed with overwrite." \
103 || log ERROR "Stow failed"
104 fi
105else
106 log WARN "Aborted stow, the dotfiles are not synced"
107fi
108
109
110## Setup neovim dotfiles
111read -rp "Setup neovim configuration as well? (y/N): " confirm
112if [[ "$confirm" =~ ^[Yy]$ ]]; then
113 log INFO "Taking backup of neovim config (if already exists)"
114 mv ~/.config/nvim{,.bak}
115 mv ~/.local/share/nvim{,.bak}
116 mv ~/.local/state/nvim{,.bak}
117 mv ~/.cache/nvim{,.bak}
118 git clone --depth=1 git@github.com:krolyxon/nvim.git ~/.config/nvim
119fi
120
121## Change default shell to zsh
122log INFO "Changing the default shell to ZSH"
123if [[ "$SHELL" != "$(which zsh)" ]]; then
124 read -rp "Change default shell to ZSH? (y/N): " confirm
125 if [[ "$confirm" =~ ^[Yy]$ ]]; then
126 chsh -s $(which zsh) \
127 && log INFO "Default shell successfully set to zsh" \
128 || log ERROR "Default shell could not be set to zsh"
129 fi
130else
131 log INFO "Skipping: zsh is already the default shell"
132fi
133
134
135## Install and setup Keyd
136read -rp "Configure and enable Keyd? (y/N): " confirm
137if [[ "$confirm" =~ ^[Yy]$ ]]; then
138 log INFO "Copying keyd configuration to /etc/keyd/default.conf"
139 sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/
140 sudo systemctl enable --now keyd.service \
141 && log INFO "Successfully enabled keyd.service" \
142 || log ERROR "Couldn't enable keyd.service"
143fi
144
145
146
147printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
148echo ""
149log INFO "Done!"