-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·64 lines (49 loc) · 1.71 KB
/
setup.sh
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
#!/bin/bash
#
# Ensures that all files in `common/` are symlinked to directory named $HOSTNAME.
# Symlinks $HOSTNAME dir to ~/.config/hypr
# TODO: Add files to exclude (e.g. hypridle, hyprlock, hyprpaper)
hyprland::symlink-common() {
local src_dir="$(realpath $(dirname "${BASH_SOURCE}"))/dots/common"
local dst_dir="$(realpath $(dirname "${BASH_SOURCE}"))/dots/$HOSTNAME"
# echo "src_dir: $src_dir"
# echo "dst_dir: $dst_dir"
for src_file in "$src_dir"/*; do
local src="$src_dir/$(basename $src_file)"
# echo "src: $src"
for dst_file in "$dst_dir"/*; do
local old_dst="$dst_dir/$(basename $dst_file)"
local new_dst="$dst_dir/$(basename $src_file)"
# echo "old_dst: $old_dst"
# echo "new_dst: $new_dst"
# Delete the old symlinks.
if [[ "$(basename $src)" == "$(basename $old_dst)" ]] && [[ -L "$old_dst" ]]; then
# echo "These match:"
# echo "$src"
# echo "$old_dst"
# echo "Deleting $old_dst"
# echo ""
rm -i "$old_dst"
fi
if [[ ! -L "$new_dst" ]]; then
ln -s "$src" "$new_dst"
echo "Symlinked $src to $new_dst!"
fi
done
done
}
hyprland::symlink-dirs() {
local src="$(realpath $(dirname "${BASH_SOURCE}"))/dots/$HOSTNAME"
local dst="$HOME/.config/hypr"
if [[ ! -d "$(dirname "$dst")" ]]; then
mkdir "$(dirname "$dst")"
fi
if [[ -d "$dst" ]] || [[ -L "$dst" ]]; then
rm -rf "$dst"
fi
if [[ ! -L "$dst" ]]; then
ln -s "$src" "$dst"
fi
}
hyprland::symlink-dirs
hyprland::symlink-common