Krolyxon
Commit 884fda0

Branches

Refs →

aurorainstall.sh

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