forked from f0xb17/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·410 lines (349 loc) · 14.5 KB
/
install.sh
File metadata and controls
executable file
·410 lines (349 loc) · 14.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
#!/bin/bash
# -----------------------------------------------#
# Config Section #
# -----------------------------------------------#
enable_aur=0
flatpak=1
tmux=0
ghostty=1
kitty=0
gaming=0
# -----------------------------------------------#
# Debug #
# You may want to let it as it is! #
# -----------------------------------------------#
# You may want to change this, when you installed
# your system, but forgot to install gaming.
# You can skip initial set up and jump to gaming
debug_skip=0
# -----------------------------------------------#
# Design #
# You may want to let it as it is! #
# -----------------------------------------------#
function warning() {
message=$1
echo -e "\033[33m -- "$1"\033[0m"
}
function error() {
message=$1
echo -e "\033[31m !! ERROR: "$1"\033[0m"
}
function message() {
message=$1
echo -e "\033[32m-- "$1"\033[0m"
}
function drawLine() {
printf '\e[35m%.0s=\e[0m' {1..80}
echo
}
draw_section() {
local title="$1"
local color_code=33
local line_length=$(tput cols)
local padding=$(( (line_length - ${#title} - 2) / 2 ))
local line
printf -v line '%*s' "$padding" ''
line=${line// /=}
local total_length=$(( ${#line} + ${#title} + ${#line} + 1 ))
if (( total_length < line_length )); then
echo -e "\e[${color_code}m${line} ${title^^} ${line}\e[0m"
else
echo -e "\e[${color_code}m${title^^}\e[0m"
fi
}
section_end() {
local line_length=$(tput cols)
printf '\e[90m%.0s-\e[0m' $(seq 1 "$line_length")
echo
}
drawLine() {
local line_length=$(tput cols)
printf '\e[35m%.0s=\e[0m' $(seq 1 "$line_length")
echo
}
# -----------------------------------------------#
# Methods #
# You may want to let it as it is! #
# -----------------------------------------------#
function installPackages() {
filePath=$1
command=$2
if [ ! -s "$filePath" ]; then
echo "Error: The file $filePath is empty. Please add at least one App to install."
exit 1
fi
while IFS= read -r app_id || [ -n "$app_id" ]; do
message "Installing: $app_id"
if [ -n "$app_id" ]; then
if ! $command "$app_id"; then
error "Installing App $app_id"
else
if [[ $command == *"flatpak"* ]]; then
warning "Activate Socket Wayland: $app_id"
flatpak override --user --socket=wayland "$app_id"
warning "Deactivate Socket X11: $app_id"
flatpak override --user --nosocket=x11 "$app_id"
fi
fi
fi
drawLine
done < "$filePath"
}
function copyFilesAsAdmin() {
command=$1
target=$2
destination=$3
sudo $command "$PWD/$target" "$destination"
}
function copyFiles() {
command=$1
target=$2
destination=$3
$command "$PWD/$target" "$destination"
}
function enableService() {
serviceName=$1
sudo systemctl enable "$serviceName"
}
function startService() {
serviceName=$1
sudo systemctl start "$serviceName"
}
# -----------------------------------------------#
# The Fun Part! #
# You may want to let it as it is! #
# -----------------------------------------------#
cat << "EOF"
███████╗ ██████╗ ██╗ ██╗███████╗██╗██╗ ███████╗███████╗
██╔════╝██╔═══██╗╚██╗██╔╝██╔════╝██║██║ ██╔════╝██╔════╝
█████╗ ██║ ██║ ╚███╔╝ █████╗ ██║██║ █████╗ ███████╗
██╔══╝ ██║ ██║ ██╔██╗ ██╔══╝ ██║██║ ██╔══╝ ╚════██║
██║ ╚██████╔╝██╔╝ ██╗██║ ██║███████╗███████╗███████║
╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
EOF
message "Welcome to FoxFiles."
draw_section "Update Services"
sudo pacman -Syyu --noconfirm
section_end
if [[ $debug_skip == 0 ]]; then
DESKTOP_ENV=$(echo "$XDG_CURRENT_DESKTOP" | tr '[:upper:]' '[:lower:]')
if [[ "$DESKTOP_ENV" == *"gnome"* ]]; then
draw_section "Gnome: Fractional Scaling"
gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer', 'xwayland-native-scaling']"
warning "Gnome: Fractional Scaling Enabled"
section_end
draw_section "Gnome: Removing Apps"
for app in vim gnome-music totem yelp gnome-contacts gnome-clocks gnome-maps gnome-weather epiphany malcontent gnome-tour htop; do
sudo pacman -Rncs --noconfirm "$app"
warning "Removed App: $app"
done
for app in flatpak libportal-gtk3; do
sudo pacman -S --needed --noconfirm "$app"
warning "Reinstalling App: $app"
done
section_end
elif [[ "$DESKTOP_ENV" == *"kde"* || "$DESKTOP_ENV" == *"plasma"* ]]; then
draw_section "KDE: Installing Apps"
for app in spectacle partitionmanager okular; do
sudo pacman -S --needed --noconfirm "$app"
warning "Installed App: $app"
done
section_end
fi
if [[ $flatpak == 1 ]]; then
if ! type flatpak &> /dev/null; then
sudo pacman -Sy --needed --noconfirm flatpak
fi
draw_section "Installing Flatpaks"
installPackages "flatpak.txt" "flatpak install -y flathub"
section_end
fi
if type pacman &> /dev/null; then
draw_section "Installing Basic Packages"
installPackages "pacman.txt" "sudo pacman -Sy --needed --noconfirm"
if [[ $enable_aur == 1 ]]; then
draw_section "Installing PARU"
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si
cd .. && rm -rf paru
if type paru &> /dev/null; then
warning "Paru installed successfully!"
fi
section_end
draw_section "Installing AUR Packages"
installPackages "aur.txt" "paru -S --needed --noconfirm"
section_end
fi
if [[ $enable_aur == 0 ]]; then
draw_section "Installing Firmware"
error "At this point, you will have to enter your password several times."
error "Press enter to continue..."
read
for pkg in aic94xx-firmware wd719x-firmware ast-firmware; do
git clone "https://aur.archlinux.org/$pkg.git"
cd "$pkg" || exit
makepkg -si
cd .. && rm -rf "$pkg"
drawLine
done
section_end
fi
fi
if lspci | grep -i nvidia &> /dev/null || lsmod | grep -i nvidia &> /dev/null; then
draw_section "Nvidia Setup"
if [ ! -e "/etc/modprobe.d/nvidia_drm.conf" ]; then
sudo touch /etc/modprobe.d/nvidia.conf
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp/ NVreg_EnableGpuFirmware=0" | sudo tee -a /etc/modprobe.d/nvidia.conf > /dev/null
warning "Created: nvidia.conf"
fi
if [ ! -e "/etc/modprobe.d/nvidia_drm.conf" ]; then
sudo touch /etc/modprobe.d/nvidia_drm.conf
echo "options nvidia_drm modeset=1 fbdev=1" | sudo tee -a /etc/modprobe.d/nvidia_drm.conf > /dev/null
warning "Created: nvidia_drm.conf"
fi
echo "LIBVA_DRIVER_NAME=nvidia" | sudo tee -a /etc/environment > /dev/null
warning "Set: LIBVA_DRIVER_NAME=nvidia"
echo "__GLX_VENDOR_LIBRARY_NAME=nvidia" | sudo tee -a /etc/environment > /dev/null
warning "Set: __GLX_VENDOR_LIBRARY_NAME=nvidia"
echo "NVD_BACKEND=direct" | sudo tee -a /etc/environment > /dev/null
warning "Set: NVD_BACKEND=direct"
enableService "nvidia-suspend"
warning "Enabled nvidia-suspend.service"
enableService "nvidia-hibernate"
warning "Enabled nvidia-hibernate.service"
enableService "nvidia-resume"
warning "Enabled nvidia-resume.service"
sudo systemctl daemon-reload
sudo mkinitcpio -P
section_end
fi
draw_section "Electron: Ozone Wayland Flag"
echo "ELECTRON_OZONE_PLATFORM_HINT=wayland" | sudo tee -a /etc/environment > /dev/null
warning "Set: ELECTRON_OZONE_PLATFORM_HINT=wayland"
warning "If you encounter Problems, set: ELECTRON_OZONE_PLATFORM_HINT=auto"
section_end
draw_section "Mozilla: Wayland Flag"
echo "MOZ_ENABLE_WAYLAND=1" | sudo tee -a /etc/environment > /dev/null
warning "Set: MOZ_ENABLE_WAYLAND=1"
section_end
draw_section "Starting Services"
modprobe btusb
enableService "bluetooth"
startService "bluetooth"
warning "Bluetooth Service started"
enableService "cups"
startService "cups"
enableService "cups.socket"
warning "Cups Service started"
section_end
draw_section "Starting Firewall"
sudo ufw default reject
sudo ufw enable
enableService "ufw"
warning "Firewall started!"
section_end
draw_section "Starting AppArmor"
enableService "apparmor"
warning "Apparmor started!"
section_end
draw_section "Setting Shell"
chsh -s $(which zsh)
copyFiles "ln -sf" "config/.zshrc" "/home/$(echo $USER)/"
warning "Setting ZShell as default shell!"
section_end
draw_section "Setting Starship"
copyFiles "ln -sf" "config/starship.toml" "/home/$(echo $USER)/.config/"
warning "Setting Starship custom theme!"
section_end
draw_section "Configure systemd-oomd"
if [[ "$DESKTOP_ENV" == *"gnome"* ]]; then
if [ ! -e "/etc/systemd/system/gnome-shell.oomd" ]; then
sudo touch /etc/systemd/system/gnome-shell.oomd
echo -e "[Unit]\nDescription=GNOME Shell OOMD Configuration\n\n[OOMD]\nDefaultAction=none" | sudo tee /etc/systemd/system/gnome-shell.oomd > /dev/null
warning "Created exception for Gnome Shell"
fi
elif [[ "$DESKTOP_ENV" == *"kde"* || "$DESKTOP_ENV" == *"plasma"* ]]; then
if [ ! -e "/etc/systemd/system/plasma-desktop.oomd" ]; then
sudo touch /etc/systemd/system/plasma-desktop.oomd
echo -e "[Unit]\nDescription=KDE Plasma OOMD Configuration\n\n[OOMD]\nDefaultAction=none" | sudo tee /etc/systemd/system/plasma-desktop.oomd > /dev/null
warning "Created exception for KDE Plasma"
fi
fi
echo "DefaultMemoryPressureLimit=70%" | sudo tee -a /etc/systemd/oomd.conf > /dev/null
warning "Set: DefaultMemoryPressureLimit to 70%"
echo "SwapUsedLimit=80%" | sudo tee -a /etc/systemd/oomd.conf > /dev/null
warning "Set: SwapUsedLimit to 70%"
echo "DefaultMemoryPressureDurationSec=30s" | sudo tee -a /etc/systemd/oomd.conf > /dev/null
warning "Set: DefaultMemoryPressureDurationSec tot 30s"
enableService "systemd-oomd"
warning "Enabled systemd-oomd"
startService "systemd-oomd"
warning "Start systemd-oomd"
section_end
if [[ $tmux == 1 ]]; then
draw_section "Installing tmux"
sudo pacman -S --needed --noconfirm tmux
warning "Installing: tmux"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
warning "Installing: tmux Plugin Manager"
copyFiles "ln -sf" "config/tmux/.tmux.conf" "/home/$(echo $USER)/"
warning "Copying: tmux config"
section_end
fi
if [[ $ghostty == 1 ]]; then
draw_section "Installing ghostty"
sudo pacman -S --needed --noconfirm ghostty
warning "Installing: ghostty"
mkdir -p /home/$(echo $USER)/.config/ghostty/
copyFiles "ln -sf" "config/ghostty/config" "/home/$(echo $USER)/.config/ghostty/"
warning "Copying: ghostty config"
section_end
fi
if [[ $kitty == 1 ]]; then
draw_section "Installing ghostty"
sudo pacman -S --needed --noconfirm kitty
warning "Installing: kitty"
mkdir -p /home/$(echo $USER)/.config/kitty/
copyFiles "ln -sf" "config/kitty/kitty.conf" "/home/$(echo $USER)/.config/kitty/"
copyFiles "ln -sf" "config/kitty/current-theme.conf" "/home/$(echo $USER)/.config/kitty/"
warning "Copying: kitty config"
section_end
fi
fi
if [[ $debug_skip == 1 ]]; then
error "Installation skipped...!"
fi
if [[ $gaming == 1 ]]; then
draw_section "Configuring Gaming"
if lspci | grep -i "nvidia" > /dev/null; then
sudo pacman -S --needed --noconfirm lib32-nvidia-utils
warning "Installed App: lib32-nvidia-utils"
drawline
fi
for pkg in steam wine winetricks wine-mono lutris lib32-libxcomposite cabextract; do
sudo pacman -S --needed --noconfirm "$pkg"
warning "Installed App: $pkg"
drawLine
done
# This will install the XBOX controller driver from the AUR.
# You Can use that for any XBOX and PlayStation Controller.
# I tested it with a PS3 Controller in Cyberpunk 2077.
git clone https://aur.archlinux.org/xboxdrv.git
cd xboxdrv
makepkg -si
warning "Installed AUR App: xboxdrv"
cd .. && rm -rf xboxdrv
drawLine
section_end
fi
draw_section "Cleaning"
sudo pacman -Scc --noconfirm
section_end
sudo mkinitcpio -P
error "To Finish Apparmor configuration, add Kernel Parameters manually!"
error "-> https://wiki.archlinux.org/title/AppArmor"
warning "Installation Finished"
warning "Press enter to continue"
read
reboot