blob: 35fce4d2bd9271d11cadac16467a70082cf97600 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="https://github.com/x2p3lnk7tq9z/dotfiles.git"
DOTFILES_DIR="${DOTFILES_DIR:-$HOME/.dotfiles}"
PACMAN_PKGS=(
hyprland
hyprlock
xdg-desktop-portal-hyprland
kitty
rofi
git
base-devel
)
AUR_PKGS=()
HOME_DOTFILES=()
INSTALL_PKGS=false
for arg in "$@"; do
case "$arg" in
--packages|-p) INSTALL_PKGS=true ;;
--help|-h)
echo "usage: $0 [--packages]"
exit 0 ;;
esac
done
[[ $EUID -eq 0 ]] && { echo "do not run as root"; exit 1; }
command -v git &>/dev/null || { echo "git required"; exit 1; }
if $INSTALL_PKGS; then
sudo pacman -Syu --needed --noconfirm "${PACMAN_PKGS[@]}"
if ! command -v yay &>/dev/null; then
tmp=$(mktemp -d)
git clone --depth=1 https://aur.archlinux.org/yay.git "$tmp/yay"
(cd "$tmp/yay" && makepkg -si --noconfirm)
rm -rf "$tmp"
fi
if [[ ${#AUR_PKGS[@]} -gt 0 ]]; then
yay -S --needed --noconfirm "${AUR_PKGS[@]}"
fi
fi
if [[ -d "$DOTFILES_DIR/.git" ]]; then
git -C "$DOTFILES_DIR" pull --ff-only &>/dev/null
else
git clone --depth=1 "$REPO_URL" "$DOTFILES_DIR" &>/dev/null
fi
mkdir -p "$HOME/.config"
for src in "$DOTFILES_DIR/.config"/*/; do
name="$(basename "$src")"
dst="$HOME/.config/$name"
[[ -e "$dst" || -L "$dst" ]] && rm -rf "$dst"
cp -r "$src" "$dst"
done
for f in "${HOME_DOTFILES[@]}"; do
[[ -e "$DOTFILES_DIR/$f" ]] && cp -r "$DOTFILES_DIR/$f" "$HOME/$f"
done
if [[ -d "$DOTFILES_DIR/.config/scripts" ]]; then
find "$DOTFILES_DIR/.config/scripts" -type f | xargs chmod +x
fi
echo "dotfiles installed"
|