-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·441 lines (350 loc) · 13.2 KB
/
setup.sh
File metadata and controls
executable file
·441 lines (350 loc) · 13.2 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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#!/bin/bash
# Advanced Hyprland Installation Script by
# Shell Ninja ( https://github.com/shell-ninja )
# color defination
red="\e[1;31m"
green="\e[1;32m"
yellow="\e[1;33m"
blue="\e[1;34m"
magenta="\e[1;1;35m"
cyan="\e[1;36m"
orange="\x1b[38;5;214m"
end="\e[1;0m"
if command -v gum &> /dev/null; then
display_text() {
gum style \
--border rounded \
--align center \
--width 60 \
--margin "1" \
--padding "1" \
'
__ __ ___
/ // /_ _____ ___________ ___ / _/
/ _ / // / _ \/ __/ __/ _ \/ _ \/ _/
/_//_/\_, / .__/_/ \__/\___/_//_/_/
/___/_/
'
}
else
display_text() {
cat << "EOF"
__ __ ___
/ // /_ _____ ___________ ___ / _/
/ _ / // / _ \/ __/ __/ _ \/ _ \/ _/
/_//_/\_, / .__/_/ \__/\___/_//_/_/
/___/_/
EOF
}
fi
clear && display_text
printf " \n \n"
###------ Startup ------###
# finding the presend directory and log file
dir="$(dirname "$(realpath "$0")")"
# log directory
log_dir="$dir/Logs"
log="$log_dir"/dotfiles.log
mkdir -p "$log_dir"
touch "$log"
# message prompts
msg() {
local actn=$1
local msg=$2
case $actn in
act)
printf "${green}=>${end} $msg\n"
;;
ask)
printf "${orange}??${end} $msg\n"
;;
dn)
printf "${cyan}::${end} $msg\n\n"
;;
att)
printf "${yellow}!!${end} $msg\n"
;;
nt)
printf "${blue}\$\$${end} $msg\n"
;;
skp)
printf "${magenta}[ SKIP ]${end} $msg\n"
;;
err)
printf "${red}>< Ohh sheet! an error..${end}\n $msg\n"
sleep 1
;;
*)
printf "$msg\n"
;;
esac
}
# Directories ----------------------------
hypr_dir="$HOME/.hyprconf/hypr"
scripts_dir="$hypr_dir/scripts"
fonts_dir="$HOME/.local/share/fonts"
msg act "Now setting up the pre installed Hyprland configuration..." && sleep 1
mkdir -p ~/.config
dirs=(
btop
fastfetch
fish
gtk-3.0
gtk-4.0
hypr
kitty
Kvantum
menus
nvim
nwg-look
qt5ct
qt6ct
rofi
satty
swaync
waybar
wlogout
xfce4
xsettingsd
yazi
dolphinrc
kwalletmanagerrc
kwalletrc
)
# Paths
backup_dir="$HOME/.temp-back"
wallpapers_backup="$backup_dir/Wallpaper"
hypr_cache_backup="$backup_dir/.cache"
hypr_config_backup="$backup_dir/configs.conf"
wallpapers="$HOME/.hyprconf/hypr/Wallpaper"
hypr_cache="$HOME/.hyprconf/hypr/.cache"
hypr_config="$HOME/.hyprconf/hypr/configs/configs.conf"
# Ensure backup directory exists
mkdir -p "$backup_dir"
# Function to handle backup/restore
backup_or_restore() {
local file_path="$1"
local file_type="$2"
if [[ -e "$file_path" ]]; then
echo
msg att "A $file_type has been found."
if command -v gum &> /dev/null; then
gum confirm "Would you Restore it or put it into the Backup?" \
--affirmative "Restore it.." \
--negative "Backup it..."
echo
if [[ $? -eq 0 ]]; then
action="r"
else
action="b"
fi
else
msg ask "Would you like to Restore it or put it into the Backup? [ r/b ]"
read -r -p "$(echo -e '\e[1;32mSelect: \e[0m')" action
fi
if [[ "$action" =~ ^[Rr]$ ]]; then
cp -r "$file_path" "$backup_dir/"
else
msg att "$file_type will be backed up..."
fi
fi
}
# Backing wallpapers
backup_or_restore "$wallpapers" "wallpaper directory"
backup_or_restore "$hypr_config" "hyprland config file"
[[ -e "$hypr_cache" ]] && cp -r "$hypr_cache" "$backup_dir/"
# if some main directories exists, backing them up.
if [[ -d "$HOME/.backup_hyprconf-${USER}" ]]; then
msg att "a .backup_hyprconf-${USER} directory was there. Archiving it..."
cd
mkdir -p ".archive_hyprconf-${USER}"
tar -czf ".archive_hyprconf-${USER}/backup_hyprconf-$(date +%d-%m-%Y_%I-%M-%p)-${USER}.tar.gz" ".backup_hyprconf-${USER}" &> /dev/null
# mv "HyprBackup-${USER}.zip" "HyprArchive-${USER}/"
rm -rf ".backup_hyprconf-${USER}"
msg dn "~/.backup_hyprconf-${USER} was archived inside ~/.archive_hyprconf-${USER} directory..." && sleep 1
fi
mkdir -p "$HOME/.backup_hyprconf-${USER}"
if [[ -d "$HOME/.hyprconf" ]]; then
mv "$HOME/.hyprconf" "$HOME/.backup_hyprconf-${USER}/"
else
for confs in "${dirs[@]}"; do
conf_path="$HOME/.config/$confs"
# If the config exists and is NOT a symlink → backup it
if [[ -e "$conf_path" && ! -L "$conf_path" ]]; then
mv "$conf_path" "$HOME/.backup_hyprconf-${USER}/" 2>&1 | tee -a "$log"
fi
done
msg dn "Backed up $confs config to ~/.backup_hyprconf-${USER}/"
fi
[[ -d "$HOME/.backup_hyprconf-${USER}/hypr" ]] && msg dn "Everything has been backuped in $HOME/.backup_hyprconf-${USER}..."
sleep 1
####################################################################
#_____ if OpenBangla Keyboard is installed
keyboard_path="/usr/share/openbangla-keyboard"
if [[ -d "$keyboard_path" ]]; then
msg act "Setting up things for OpenBangla-Keyboard..."
# Add fcitx5 environment variables to /etc/environment if not already present
if ! grep -q "GTK_IM_MODULE=fcitx" /etc/environment; then
printf "\nGTK_IM_MODULE=fcitx\n" | sudo tee -a /etc/environment 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") &> /dev/null
fi
if ! grep -q "QT_IM_MODULE=fcitx" /etc/environment; then
printf "QT_IM_MODULE=fcitx\n" | sudo tee -a /etc/environment 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") &> /dev/null
fi
if ! grep -q "XMODIFIERS=@im=fcitx" /etc/environment; then
printf "XMODIFIERS=@im=fcitx\n" | sudo tee -a /etc/environment 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") &> /dev/null
fi
fi
####################################################################
#_____ for virtual machine
# Check if the configuration is in a virtual box
if hostnamectl | grep -q 'Chassis: vm'; then
msg att "You are using this script in a Virtual Machine..."
msg act "Setting up things for you..."
sed -i '/env = WLR_NO_HARDWARE_CURSORS,1/s/^#//' "$dir/config/hypr/configs/environment.conf"
sed -i '/env = WLR_RENDERER_ALLOW_SOFTWARE,1/s/^#//' "$dir/config/hypr/configs/environment.conf"
echo -e '#Monitor\nmonitor=Virtual-1, 1920x1080@60,auto,1' > "$dir/config/hypr/configs/monitor.conf"
fi
#_____ for nvidia gpu. I don't know if it's gonna work or not. Because I don't have any gpu.
# uncommenting WLR_NO_HARDWARE_CURSORS if nvidia is detected
if lspci -k | grep -A 2 -E "(VGA|3D)" | grep -iq nvidia; then
msg act "Nvidia GPU detected. Setting up proper env's" 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") || true
sed -i '/env = WLR_NO_HARDWARE_CURSORS,1/s/^#//' config/hypr/configs/environment.conf
sed -i '/env = LIBVA_DRIVER_NAME,nvidia/s/^#//' config/hypr/configs/environment.conf
sed -i '/env = __GLX_VENDOR_LIBRARY_NAME,nvidia/s/^# //' config/hypr/configs/environment.conf
fi
sleep 1
# creating symlinks
cp -a "$dir/config" "$HOME/.hyprconf"
mv "$HOME/.hyprconf/fastfetch" "$HOME/.local/share/"
for dotfilesDir in "$HOME/.hyprconf"/*; do
configDirName=$(basename "$dotfilesDir")
configDirPath="$HOME/.config/$configDirName"
ln -sfn "$dotfilesDir" "$configDirPath"
done
sleep 1
if [[ -d "$scripts_dir" ]]; then
# make all the scripts executable...
chmod +x "$scripts_dir"/* 2>&1 | tee -a "$log"
chmod +x "$HOME/.hyprconf/fish/functions"/* 2>&1 | tee -a "$log"
msg dn "All the necessary scripts have been executable..."
sleep 1
else
msg err "Could not find necessary scripts.."
fi
# Install Fonts
msg act "Installing some fonts..."
if [[ ! -d "$fonts_dir" ]]; then
mkdir -p "$fonts_dir"
fi
cp -r "$dir/extras/fonts" "$fonts_dir"
msg act "Updating font cache..."
sudo fc-cache -fv 2>&1 | tee -a "$log" &> /dev/null
### Setup extra files and dirs
# dolphinstaterc
if [[ -f "$HOME/.local/state/dolphinstaterc" ]]; then
mv "$HOME/.local/state/dolphinstaterc" "$HOME/.local/state/dolphinstaterc.back"
fi
# konsole
if [[ -d "$HOME/.local/share/konsole" ]]; then
mv "$HOME/.local/share/konsole" "$HOME/.local/share/konsole.back"
fi
cp -r "$dir/local/state/dolphinstaterc" "$HOME/.local/state/"
cp -r "$dir/local/share/konsole" "$HOME/.local/share/"
# wayland session dir
wayland_session_dir=/usr/share/wayland-sessions
if [ -d "$wayland_session_dir" ]; then
msg att "$wayland_session_dir found..."
else
msg att "$wayland_session_dir NOT found, creating..."
sudo mkdir $wayland_session_dir 2>&1 | tee -a "$log"
fi
sudo cp "$dir/extras/hyprland.desktop" /usr/share/wayland-sessions/ 2>&1 | tee -a "$log"
# restore the backuped items into the original location
restore_backup() {
local backup_path="$1" # Path to the backup file/directory
local original_path="$2" # Original file/directory path
local file_type="$3" # Description of the file/directory
if [[ -e "$backup_path" ]]; then
# Create a backup of the current file/directory if it exists
if [[ -e "$original_path" ]]; then
mv "$original_path" "${original_path}.backup"
fi
# Restore the file/directory from the backup
if cp -r "$backup_path" "$original_path"; then
msg dn "$file_type restored to its original location: $original_path."
else
msg err "Could not restore defaults."
fi
if [[ -e "${original_path}.backup" ]]; then
rm -rf "${original_path}.backup"
fi
fi
}
# Restore files
restore_backup "$wallpapers_backup" "$wallpapers" "wallpaper directory"
restore_backup "$hypr_config_backup" "$hypr_config" "hyprland config file"
# restoring hyprland cache
[[ -e "$HOME/.hyprconf/hypr/.cache" ]] && rm -rf "$HOME/.hyprconf/hypr/.cache"
[[ -e "$hypr_cache_backup" ]] && cp -r "$hypr_cache_backup" "$hypr_cache"
rm -rf "$backup_dir"
clear && sleep 1
# Asking if the user wants to download more wallpapers
msg ask "Would you like to add more ${green}Wallpapers${end}? ${blue}[ y/n ]${end}..."
read -r -p "$(echo -e '\e[1;32mSelect: \e[0m')" wallpaper
printf " \n"
# ========= wallpaper section ========= #
if [[ "$wallpaper" =~ ^[Y|y]$ ]]; then
url="https://github.com/shell-ninja/Wallpapers/archive/refs/heads/main.zip"
target_dir="$HOME/.cache/wallpaper-cache"
zip_path="$target_dir.zip"
msg act "Downloading some wallpapers..."
# Download the ZIP silently with a progress bar
curl -L "$url" -o "$zip_path"
if [[ -f "$zip_path" ]]; then
mkdir -p "$target_dir"
unzip "$zip_path" "wallpaper-cache-main/*" -d "$target_dir" > /dev/null
mv "$target_dir/wallpaper-cache-main/"* "$target_dir" && rmdir "$target_dir/wallpaper-cache-main"
rm "$zip_path"
fi
# copying the wallpaper to the main directory
if [[ -d "$HOME/.cache/wallpaper-cache" ]]; then
cp -r "$HOME/.cache/wallpaper-cache"/* ~/.hyprconf/hypr/Wallpaper/ &> /dev/null
rm -rf "$HOME/.cache/wallpaper-cache" &> /dev/null
msg dn "Wallpapers were downloaded successfully..." 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") & sleep 0.5
else
msg err "Sorry, could not download more wallpapers. Going forward with the limited wallpapers..." 2>&1 | tee -a >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$log") && sleep 0.5
fi
fi
# ========= wallpaper section ========= #
if [[ -d "$HOME/.hyprconf/hypr/Wallpaper" ]]; then
if [[ -d "$HOME/.hyprconf/hypr/.cache" ]]; then
wallName=$(cat "$HOME/.hyprconf/hypr/.cache/.wallpaper")
wallpaper=$(find "$HOME/.hyprconf/hypr/Wallpaper" -type f -name "$wallName.*" | head -n 1)
else
mkdir -p "$HOME/.hyprconf/hypr/.cache"
wallCache="$HOME/.hyprconf/hypr/.cache/.wallpaper"
touch "$wallCache"
if [ -f "$HOME/.hyprconf/hypr/Wallpaper/linux.jpg" ]; then
echo "linux" > "$wallCache"
wallpaper="$HOME/.hyprconf/hypr/Wallpaper/linux.jpg"
fi
fi
# setting the default wallpaper
ln -sf "$wallpaper" "$HOME/.hyprconf/hypr/.cache/current_wallpaper.png"
fi
# setting up the waybar
ln -sf "$HOME/.hyprconf/waybar/configs/full-top" "$HOME/.hyprconf/waybar/config"
ln -sf "$HOME/.hyprconf/waybar/style/full-top.css" "$HOME/.hyprconf/waybar/style.css"
# setting up hyprlock theme
ln -sf "$HOME/.hyprconf/hypr/lockscreens/hyprlock-1.conf" "$HOME/.hyprconf/hypr/hyprlock.conf"
msg act "Generating colors and other necessary things..."
"$HOME/.hyprconf/hypr/scripts/wallcache.sh" &> /dev/null
"$HOME/.hyprconf/hypr/scripts/pywal.sh" &> /dev/null
# setting default themes, icon and cursor
gsettings set org.gnome.desktop.interface gtk-theme 'TokyoNight'
gsettings set org.gnome.desktop.interface icon-theme 'TokyoNight'
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Ice'
crudini --set ~/.config/Kvantum/kvantum.kvconfig General theme "Dracula"
crudini --set ~/.config/kdeglobals Icons Theme "TokyoNight"
msg dn "Script execution was successful! Now logout and log back in and enjoy your customization..." && sleep 1
# === ___ Script Ends Here ___ === #