-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_packages.sh
More file actions
executable file
·413 lines (359 loc) · 10.5 KB
/
install_packages.sh
File metadata and controls
executable file
·413 lines (359 loc) · 10.5 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
#!/bin/bash
function check_root() {
# Checking for root access and proceed if it is present
ROOT_UID=0
if [[ "${UID}" -eq "${ROOT_UID}" ]]; then
# Error message
echo 'Do not run me as root.'
echo 'Try ./install_packages.sh'
exit 1
fi
}
check_root
# Run this command if both Gnome and Hyprland are installed together (fix video rendering issue and firefox crash
# Check portal processes: ps aux | grep -E "(xdg-desktop-portal|portal)" | grep -v grep
# systemctl --user mask xdg-desktop-portal-gnome.service
# systemctl --user mask xdg-desktop-portal-gtk.service
# systemctl --user restart xdg-desktop-portal.service
# Define a list of packages to install
pacman_packages=(
"vim"
"htop"
"curl"
"wget"
"tar"
"git"
"libreoffice-fresh"
"vlc"
"discord"
"thunderbird"
"firefox"
"torbrowser-launcher"
"thunderbird"
"grub-customizer"
"flatpak"
"bitwarden"
"solaar"
"networkmanager-openvpn"
"zip"
"gimp"
"qbittorrent"
"zed"
"lazygit"
"adobe-source-han-sans-otc-fonts"
"adobe-source-han-serif-otc-fonts"
"noto-fonts-cjk"
"obsidian"
"yazi"
"neovim"
"fd"
"ripgrep"
"alsa-utils"
"pavucontrol"
"fastfetch"
"btop"
"wl-clipboard"
"earlyoom"
"bun"
"bind"
)
aur_packages=(
"pamac-aur"
"timeshift"
"slack-desktop-wayland"
"spotify"
"google-chrome"
"valent"
"nwg-look"
"zen-browser-bin"
"localsend-bin"
)
flatpak_packages=()
read -p "Do you want to enable bluetooth? default(n) (y/n): " enable_bluetooth
if [[ $enable_bluetooth == "y" || $enable_bluetooth == "Y" ]]; then
pacman_packages+=(
"bluez"
"blueman"
"bluez-utils"
)
fi
# Prompt to install GNOME packages
read -p "Do you want to install GNOME packages? default(n) (y/n) :" install_gnome
if [[ $install_gnome == "y" || $install_gnome == "Y" ]]; then
pacman_packages+=(
"gnome-browser-connector"
)
flatpak_packages+=(
"flathub"
"com.mattjakeman.ExtensionManager"
)
fi
# Prompt to install Wayland packages
read -p "Do you want to install Dev packages? default(n) (y/n): " install_dev
if [[ $install_dev == "y" || $install_dev == "Y" ]]; then
pacman_packages+=(
"docker"
"docker-compose"
"dotnet-sdk"
"aspnet-runtime"
"sdkman-bin"
"aws-cli"
"uv"
"azure-cli"
)
aur_packages+=(
"rider"
"datagrip"
"supabase-bin"
"cursor-bin"
"visual-studio-code-bin"
"insomnia-bin"
"claude-code"
)
fi
read -p "Do you want to setup security? default(n) (y/n): " setup_security
if [[ $setup_security == "y" || $setup_security == "Y" ]]; then
pacman_packages+=(
"ufw"
)
fi
read -p "Do you want to install Hyprland? default(n) (y/n): " install_hyprland
read -p "Do you want to setup Kanata (Caps Lock + vim keys = arrow keys)? default(n) (y/n): " setup_kanata
if [[ $install_hyprland == "y" || $install_hyprland == "Y" ]]; then
pacman_packages+=(
"hyprland"
"kitty"
"wofi"
"waybar"
"ttf-font-awesome"
"polkit-gnome" # used to authenticate to use gnome apps
"brightnessctl"
"cliphist"
"wf-recorder"
"rofi"
"swayosd"
# used to fix screen sharing BEGIN
"wireplumber"
"xdg-desktop-portal-hyprland"
"grim"
"slurp"
"pipewire"
# used to fix screen sharing END
"power-profiles-daemon"
"yad"
)
aur_packages+=(
"hyprshot"
"swaync"
"hyprlock"
"hypridle"
"stow"
"hyprpaper"
"starship"
"ttf-cascadia-code-nerd"
"nwg-look"
"wlogout"
"hyprswitch"
"catppuccin-cursors-frappe"
"ant-dracula-theme-git"
"lazydocker"
"hyprwat-bin"
)
fi
if [[ $setup_kanata == "y" || $setup_kanata == "Y" ]]; then
aur_packages+=("kanata-bin")
fi
read -p "Do you want to install Chinese keyboard input support? default(n) (y/n): " enable_chinese_input
if [[ $enable_chinese_input == "y" || $enable_chinese_input == "Y" ]]; then
pacman_packages+=(
"fcitx5"
"fcitx5-rime"
"fcitx5-configtool"
"fcitx5-gtk"
"fcitx5-qt"
"rime-luna-pinyin"
"rime-terra-pinyin"
)
fi
# Update system package database
echo "Updating system package database..."
sudo pacman -Sy
# Check which pacman packages are missing
missing_pacman=()
for package in "${pacman_packages[@]}"; do
if ! pacman -Qi "$package" &>/dev/null; then
missing_pacman+=("$package")
fi
done
# Check which AUR packages are missing (requires yay)
missing_aur=()
if yay --version &>/dev/null; then
for package in "${aur_packages[@]}"; do
if ! yay -Q "$package" &>/dev/null; then
missing_aur+=("$package")
fi
done
fi
# Show missing packages and prompt
if [[ ${#missing_pacman[@]} -gt 0 || ${#missing_aur[@]} -gt 0 ]]; then
echo ""
echo "The following packages will be installed:"
if [[ ${#missing_pacman[@]} -gt 0 ]]; then
echo ""
echo " [pacman]"
for p in "${missing_pacman[@]}"; do
echo " - $p"
done
fi
if [[ ${#missing_aur[@]} -gt 0 ]]; then
echo ""
echo " [AUR]"
for p in "${missing_aur[@]}"; do
echo " - $p"
done
fi
echo ""
read -p "Do you want to continue with the installation? (y/n): " confirm_install
if [[ $confirm_install != "y" && $confirm_install != "Y" ]]; then
echo "Installation aborted."
exit 0
fi
else
echo "All packages are already installed."
fi
echo "Installing Pacman packages..."
# Loop through the list of packages and install if not already installed
for package in "${pacman_packages[@]}"; do
if ! pacman -Qi "$package" &>/dev/null; then
echo "Installing package: $package"
sudo pacman -S "$package" --noconfirm
else
echo "Package $package is already installed."
fi
done
# Install Yay
if ! yay --version &>/dev/null; then
echo "yay is not installed, proceeding with installation..."
# Install base-devel and git if they are not already installed
sudo pacman -S --needed base-devel git
# Temporarily change to a temporary directory for yay installation
pushd "$(mktemp -d)" || exit 1
# Clone yay from AUR
git clone https://aur.archlinux.org/yay.git
cd yay || exit 1
# Build and install yay
makepkg -si
# Return to the original directory
popd
fi
echo "Installing AUR packages..."
# Loop through the list and install each package if it is not already installed
for package in "${aur_packages[@]}"; do
# Check if the package is already installed
if yay -Q $package &>/dev/null; then
echo "Package $package is already installed."
else
echo "Installing $package..."
yay -S "$package" --noconfirm
fi
done
for package in "${flatpak_packages[@]}"; do
# Check if the package is already installed
if flatpak list | grep $package &>/dev/null; then
echo "Package $package is already installed."
else
echo "Installing $package..."
flatpak install $package
fi
done
if [[ $enable_bluetooth == "y" || $enable_bluetooth == "Y" ]]; then
sudo systemctl enable bluetooth
sudo systemctl start bluetooth
fi
# Function to setup kanata keyboard remapping
setup_kanata_config() {
echo "Setting up kanata keyboard remapping..."
# Create uinput group as a system group if it doesn't exist
# Must be a system group so udev can resolve it
if ! getent group uinput >/dev/null; then
sudo groupadd --system uinput
fi
# Add user to input and uinput groups
sudo usermod -aG input $USER
sudo usermod -aG uinput $USER
# Load uinput module now and ensure it loads on every boot
sudo modprobe uinput
echo "uinput" | sudo tee /etc/modules-load.d/uinput.conf
# Create udev rule for kanata.
# The RUN line uses setfacl to explicitly grant the uinput group rw access,
# overriding brltty's udev rule (90-brltty-uinput.rules) which sets group::--- via ACL.
echo 'KERNEL=="uinput", MODE="0660", GROUP="uinput", RUN+="/usr/bin/setfacl -m g:uinput:rw /dev/%k"' \
| sudo tee /etc/udev/rules.d/99-kanata.rules
# Reload udev rules and retrigger the uinput device
sudo udevadm control --reload-rules && sudo udevadm trigger --subsystem-match=misc --action=add
echo "Kanata setup complete. You'll need to log out and back in for group changes to take effect."
}
if [[ $install_hyprland == "y" || $install_hyprland == "Y" ]]; then
# Fix screen sharing
exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
echo 'eval "$(starship init bash)"' >>~/.bashrc
systemctl enable --now power-profiles-daemon.service
sudo systemctl start power-profiles-daemon.service
fi
if [[ $setup_kanata == "y" || $setup_kanata == "Y" ]]; then
setup_kanata_config
fi
# Function to add alias if not present
add_alias_if_not_present() {
local alias_cmd="$1"
local alias_name=$(echo "$alias_cmd" | cut -d'=' -f1 | sed 's/alias //')
if ! grep -q "^alias $alias_name=" ~/.bashrc; then
echo "$alias_cmd" >>~/.bashrc
echo "Added alias: $alias_name"
else
echo "Alias $alias_name already exists"
fi
}
# Add useful aliases
add_alias_if_not_present 'alias grep="grep --color=auto"'
add_alias_if_not_present 'alias df="df -h"'
add_alias_if_not_present 'alias du="du -h -c"'
add_alias_if_not_present 'alias free="free -h"'
add_alias_if_not_present 'alias ls="ls --color=auto"'
add_alias_if_not_present 'alias ll="ls -lh"'
add_alias_if_not_present 'alias la="ls -A"'
add_alias_if_not_present 'alias l="ls -CF"'
add_alias_if_not_present 'alias lla="ls -lha"'
add_alias_if_not_present 'alias c="clear"'
add_alias_if_not_present 'alias q="exit"'
add_alias_if_not_present 'alias ..="cd .."'
add_alias_if_not_present 'alias ...="cd ../.."'
add_alias_if_not_present 'alias neofetch="fastfetch"'
add_alias_if_not_present 'alias pwdc="pwd | wl-copy"'
add_alias_if_not_present 'alias cdo="pwd | xargs -I{} echo \"cd {} && opencode\" | wl-copy"'
add_alias_if_not_present 'alias cdc="pwd | xargs -I{} echo \"cd {} && claude\" | wl-copy"'
# Enable earlyoom (prevents system freeze on out-of-memory)
sudo systemctl enable --now earlyoom
# Enable SysRq (emergency OOM kill with Alt+SysRq+F when system is frozen)
echo "kernel.sysrq = 1" | sudo tee /etc/sysctl.d/99-sysrq.conf
sudo sysctl --system
if [[ $setup_security == "y" ]]; then
# Setup firewall rules
sudo ufw limit 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
fi
if [[ $enable_chinese_input == "y" || $enable_chinese_input == "Y" ]]; then
# Add Chinese input environment variables
echo "export GTK_IM_MODULE=fcitx" >>~/.bashrc
echo "export XMODIFIERS=@im=fcitx" >>~/.bashrc
echo "export QT_IM_MODULE=fcitx" >>~/.bashrc
# Enable and start fcitx5 service
systemctl --user enable fcitx5
systemctl --user start fcitx5
fi
source ~/.bashrc
echo "Installation process complete."