Repository navigation
Expand file tree
/
Copy pathdev-env
More file actions
executable file
·114 lines (99 loc) · 2.87 KB
/
Copy pathdev-env
File metadata and controls
executable file
·114 lines (99 loc) · 2.87 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
#!/usr/bin/env bash
script_dir="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
dry="0"
while [[ $# > 0 ]]; do
if [[ $1 == "--dry" ]]; then
dry="1"
fi
shift
done
log() {
if [[ $dry == "1" ]]; then
echo "[DRY_RUN]: $@"
else
echo "$@"
fi
}
execute() {
log "execute $@"
if [[ $dry == "1" ]]; then
return
fi
"$@"
}
cd "$script_dir"
copy_dir() {
src=$1
dest=$2
for dir in "$src"/*; do
if [ -d "$dir" ]; then
target=$(basename "$dir")
if [ "$target" == "systemd" ]; then
continue
fi
execute rm -rf -- "$dest/$target"
execute cp -r "$dir" "$dest/"
fi
done
}
copy_file() {
from=$1
dest_dir=$2
execute rm -f "$dest_dir/$(basename "$from")"
execute cp "$from" "$dest_dir/"
}
reload_hyprland() {
if command -v hyprctl >/dev/null 2>&1 && pgrep -x Hyprland >/dev/null 2>&1; then
# Find active socket dir in /run/user/$UID/hypr/ that contains .socket.sock
active_socket_dir=$(find "/run/user/$UID/hypr" -maxdepth 2 -name ".socket.sock" 2>/dev/null | head -n 1 | xargs dirname 2>/dev/null)
if [ -n "$active_socket_dir" ]; then
instance_sig=$(basename "$active_socket_dir")
log "Reloading Hyprland instance ($instance_sig)..."
if [[ $dry == "0" ]]; then
HYPRLAND_INSTANCE_SIGNATURE="$instance_sig" hyprctl reload >/dev/null 2>&1
fi
else
log "Reloading Hyprland..."
if [[ $dry == "0" ]]; then
hyprctl reload >/dev/null 2>&1
fi
fi
fi
}
log "----------------- dev-env ---------------"
copy_dir .config "$HOME/.config"
# additional configs
copy_file .config/google-chrome-flags.conf "$HOME/.config"
copy_file .config/chrome-flags.conf "$HOME/.config"
copy_file .config/microsoft-edge-stable-flags.conf "$HOME/.config"
copy_file .config/kwalletrc "$HOME/.config"
# Systemd user services
execute mkdir -p "$HOME/.config/systemd/user"
for s in .config/systemd/user/*.service; do
if [ -f "$s" ]; then
copy_file "$s" "$HOME/.config/systemd/user"
fi
done
# Local bin scripts
execute mkdir -p "$HOME/.local/bin"
for b in bin/*; do
if [ -f "$b" ]; then
copy_file "$b" "$HOME/.local/bin"
fi
done
# Home Dir configs
copy_file robbyrussell.omp.json "$HOME"
copy_file .config/tmux/.tmux.conf "$HOME"
copy_file .config/tmux/.tmux-cht-command "$HOME"
copy_file .config/tmux/.tmux-cht-languages "$HOME"
copy_file .zshrc "$HOME"
copy_file .bashrc "$HOME"
copy_file .gitconfig "$HOME"
copy_file .gitexcludes "$HOME"
copy_file .gtkrc-2.0 "$HOME"
copy_file kanata.kbd "$HOME"
copy_file .config/mimeapps.list "$HOME/.config"
copy_file .config/QtProject.conf "$HOME/.config"
copy_file .config/pavucontrol.ini "$HOME/.config"
# Auto reload Hyprland if running
reload_hyprland