dots/.bin/setup

207 lines
4.3 KiB
Plaintext
Raw Normal View History

2021-12-31 15:55:07 +01:00
#!/bin/bash
pac_list=(
2025-02-05 23:17:55 +01:00
alacritty
at
automake
autopep8
base
base-devel
bash-completion
bash-language-server
bc
brightnessctl
chromium
dmidecode
entr
eslint_d
feh
firefox-developer-edition
firefox-tridactyl
firefox-tridactyl-native
firefox-tridactyl-native-debug
fzf
gcc
2021-12-31 15:55:07 +01:00
git
2025-02-05 23:17:55 +01:00
haskell-language-server
haskell-ormolu
hsetroot
htop
httpie
jq
keepassxc
lua-language-server
make
man-db
man-pages
2025-02-05 20:11:42 +01:00
neovim
2025-02-05 23:17:55 +01:00
nmap
2025-02-05 20:11:42 +01:00
nodejs-lts-jod
2025-02-05 23:17:55 +01:00
pacman-contrib
pandoc-cli
pandoc-crossref
parallel
pass
pkgbuild-language-server
pnpm
sshfs
stylelint
svelte-language-server
tailwindcss-language-server
task
tldr
tmux
tmuxp
tree
tree-sitter-cli
ts-node
typescript-language-server
unzip
vim-language-server
wget
yaml-language-server
2021-12-31 15:55:07 +01:00
)
aurpac_list=(
2025-02-05 23:17:55 +01:00
hadolint-bin
2025-02-05 20:11:42 +01:00
nvm
2025-02-05 23:17:55 +01:00
nvimpager
paru
tmux-bash-completion-git
2021-12-31 15:55:07 +01:00
ttf-iosevka-term-ss08
2025-02-05 00:31:41 +01:00
vim-plug
2025-02-05 23:17:55 +01:00
vtsls
2025-02-05 00:31:41 +01:00
xbanish
2021-12-31 15:55:07 +01:00
)
2025-02-05 00:31:41 +01:00
install() {
2025-02-06 00:15:12 +01:00
local package="$1"
if pacman -Qi "$package" &> /dev/null; then
echo "$package is already installed"
2025-02-05 00:31:41 +01:00
else
2025-02-06 00:15:12 +01:00
echo "Installing " "$package"
sudo pacman -S --noconfirm --needed "$package"
2025-02-05 00:31:41 +01:00
fi
}
aurpac() {
git clone "https://aur.archlinux.org/$1.git" "$HOME/.build/$1"
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
install_packages() {
announce "Installing packages"
local count
for pac in "${pac_list[@]}" ; do
count=$((count+1))
install "$pac";
done
echo "$count packages installed"
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
install_dotfiles() {
announce "Installing dotfiles"
origin="https://git.hektormisplon.xyz/hektor/dots"
git clone "$origin" "$HOME/dots"
cp -r "$HOME/dots/.git" "$HOME/.git"
git --git-dir="$HOME/.git" config --local status.showUntrackedFiles no
git --git-dir="$HOME/.git" stash -m "[dots]"
git --git-dir="$HOME/.git" stash apply
git --git-dir="$HOME/.git" restore "$HOME"
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
install_aur_packages() {
announce "Installing AUR packages"
local count
for package in "${aurpac_list[@]}" ; do
if pacman -Qi "$1" &> /dev/null; then
echo "$1 is already installed"
else
count=$((count+1))
aurpac "$package" && makepkg -si -D "$HOME/.build/$package"
fi
done
echo "$count AUR packages installed"
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
setup_neovim() {
announce "Setting up NeoVim"
git clone --depth=1 https://github.com/savq/paq-nvim.git \
"${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/paqs/start/paq-nvim
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
setup_keyboard() {
announce "Setting up keyboard"
install "interception-tools"
install "interception-caps2esc"
udevmon_config_contents="\
- JOB: intercept -g \$DEVNODE | caps2esc -m 1 | uinput -d \$DEVNODE
DEVICE:
EVENTS:
EV_KEY: [KEY_CAPSLOCK]"
if [ -f /etc/interception/udevmon.yaml ] && diff -q <(echo "$udevmon_config_contents") /etc/interception/udevmon.yaml; then
echo "udevmon config already exists"
echo "$udevmon_config_contents"
elif [ -f /etc/interception/udevmon.yaml ]; then
echo "interception udevmon.yaml already exists"
cat /etc/interception/udevmon.yaml
echo "verify if this config matches the one below"
echo "$udevmon_config_contents"
else
echo "interception udevmon.yaml does not exist, creating one"
sudo bash -c "echo '$udevmon_config_contents' > /etc/interception/udevmon.yaml"
fi
2025-02-05 00:31:41 +01:00
2025-02-05 20:11:42 +01:00
sudo systemctl enable --now udevmon.service
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
if pgrep -x caps2esc > /dev/null; then
echo "caps2esc is already running"
2021-12-31 15:55:07 +01:00
else
2025-02-05 20:11:42 +01:00
caps2esc -m 1
2021-12-31 15:55:07 +01:00
fi
2025-02-05 20:11:42 +01:00
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:32:09 +01:00
configure_gnome() {
announce "Configuring Gnome"; setup-gnome
}
2025-02-05 23:18:10 +01:00
setup_firewall() {
announce "Configuring firewalld"
install firewalld
sudo systemctl enable --now firewalld
}
setup_docker() {
announce "Setting up Docker"
install docker
install docker-compose
sudo systemctl enable --now docker.socket
sudo usermod -aG docker "$USER"
echo "User added to docker group, please restart your session"
}
2025-02-05 20:11:42 +01:00
announce() {
2025-02-06 00:15:12 +01:00
local message="$1"
2025-02-05 20:11:42 +01:00
echo " "
2025-02-06 00:15:12 +01:00
echo "[dots] $message"
2025-02-05 20:11:42 +01:00
echo " "
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
confirm() {
2025-02-06 00:15:12 +01:00
local question="$1"
read -r -p "[dots] $question? [y/N]" -n 1
2025-02-05 20:11:42 +01:00
case "$REPLY" in y|Y ) "$2";; * ) echo "Skipping"; esac
}
2021-12-31 15:55:07 +01:00
2025-02-05 20:11:42 +01:00
printf '%s\n' "${pac_list[@]}"
confirm "Install these packages? " install_packages
printf '%s\n' "${aurpac_list[@]}"
confirm "Install these AUR packages? " install_aur_packages
confirm "Setup NeoVim? " setup_neovim
confirm "Install dotfiles? " install_dotfiles
confirm "Setup keyboard? " setup_keyboard
2025-02-05 20:32:09 +01:00
if pacman -Qi "gdm" &> /dev/null; then
confirm "Configure Gnome? " configure_gnome
fi
2025-02-05 23:18:10 +01:00
confirm "Setup firewall? " setup_firewall
confirm "Setup Docker? " setup_docker