Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
137 lines (118 loc) · 3.92 KB
/
Copy pathinstall.sh
File metadata and controls
137 lines (118 loc) · 3.92 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
set -euo pipefail
# Variables - adapt these!
DOTFILES_REPO="https://github.com/ethanj78900-glitch/dotfiles.git"
DOTFILES_DIR="$HOME/.dotfiles"
BACKUP_DIR="$HOME/dotfiles_backup_$(date +%Y%m%d%H%M%S)"
AUR_HELPER="yay" # Change to paru or other if you prefer
# Programs to install from official repos
OFFICIAL_PKGS=(
i3-wm i3status i3lock
google-chrome
ranger
rofi
mousepad
git
base-devel
wget
curl
xorg-server
xorg-xinit
firefox # Optional, add more popular packages here
)
# AUR Packages (if any)
AUR_PKGS=(
google-chrome
# Add other AUR-only packages here
)
# Function: Check if running as regular user (not root)
function check_user() {
if [[ "$EUID" -eq 0 ]]; then
echo "Please run this script as a normal user, not root."
exit 1
fi
}
# Function: Check if on Arch Linux
function check_arch_linux() {
if ! grep -qi arch /etc/os-release; then
echo "This script only supports Arch Linux."
exit 1
fi
}
# Function: check and install package from pacman
function install_official_packages() {
echo "Installing official packages..."
sudo pacman -Sy --needed --noconfirm "${OFFICIAL_PKGS[@]}"
}
# Function: Install AUR packages using yay
function install_aur_packages() {
if ! command -v "$AUR_HELPER" &>/dev/null; then
echo "$AUR_HELPER not found. Installing yay..."
git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay || exit
makepkg -si --noconfirm
cd - || exit
rm -rf /tmp/yay
fi
echo "Installing AUR packages..."
$AUR_HELPER -Sy --needed --noconfirm "${AUR_PKGS[@]}"
}
# Function: Backup existing configs
function backup_dotfiles() {
echo "Backing up existing dotfiles to $BACKUP_DIR ..."
mkdir -p "$BACKUP_DIR"
for file in .bashrc .xinitrc .config/i3/config .config/rofi/config.rasi .config/ranger/; do
if [[ -e "$HOME/$file" ]]; then
mv "$HOME/$file" "$BACKUP_DIR/"
echo "Moved $file to backup."
fi
done
}
# Function: Clone dotfiles repo
function clone_dotfiles() {
if [[ -d "$DOTFILES_DIR" ]]; then
echo "Dotfiles directory already exists at $DOTFILES_DIR, pulling latest changes..."
git -C "$DOTFILES_DIR" pull
else
echo "Cloning dotfiles repo..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
}
# Function: Symlink dotfiles
function link_dotfiles() {
echo "Linking dotfiles..."
ln -sf "$DOTFILES_DIR/.bashrc" "$HOME/.bashrc"
ln -sf "$DOTFILES_DIR/.xinitrc" "$HOME/.xinitrc"
mkdir -p "$HOME/.config"
mkdir -p "$HOME/.config/i3"
mkdir -p "$HOME/.config/rofi"
mkdir -p "$HOME/.config/ranger"
ln -sf "$DOTFILES_DIR/.config/i3/config" "$HOME/.config/i3/config"
ln -sf "$DOTFILES_DIR/.config/rofi/config.rasi" "$HOME/.config/rofi/config.rasi"
ln -sf "$DOTFILES_DIR/.config/ranger/rc.conf" "$HOME/.config/ranger/rc.conf"
echo "Dotfiles linked."
}
# Function: Enable i3wm as default session (for display manager like LightDM)
function enable_i3_session() {
echo "Enabling i3 session (if display manager is used)..."
if command -v systemctl &>/dev/null && systemctl is-enabled lightdm &>/dev/null; then
echo "LightDM detected."
if ! grep -q "^user-session=i3" /etc/lightdm/lightdm.conf; then
sudo sed -i 's/^#*user-session=.*/user-session=i3/' /etc/lightdm/lightdm.conf
echo "Set i3 as default session in LightDM."
fi
fi
}
# MAIN
check_user
check_arch_linux
echo "Starting personal dotfiles environment installation..."
install_official_packages
install_aur_packages
backup_dotfiles
clone_dotfiles
link_dotfiles
enable_i3_session
echo "Installation complete!"
echo "You can now start X with 'startx' or reboot to login with your desktop environment."
exit 0