-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·176 lines (146 loc) · 3.97 KB
/
install.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
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
#!/usr/bin/env bash
# colored output
function colored {
local color
local end
case "$1" in
"red") color="\e[0;31m";;
"green") color="\e[0;32m";;
"magenta") color="\e[0;35m";;
"yellow") color="\e[1;33m";;
esac
end="\e[0m"
printf "$color$2$end"
}
# directory remove
# if directory is link, delete link file
# (linked directory will be fine)
function ddir {
if [ -d "$1" ]; then
if [ -L "$1" ]; then
rm "$1"
else
rm -rf "$1"
fi
colored "red" "# "
printf "Remove %s\n" "$1"
fi
}
# copy file
function cfile {
# $1 - src, $2 - dst
if [ ! -f "$2" ]; then
cp "$1" "$2"
fi
}
# link file
function lfile {
# $1 - src, $2 - dst
if [ ! -f "$2" ] && [ ! -L "$2" ]; then
ln -s "$1" "$2"
fi
}
# directory installation with backup if already exist
function dinstall {
# $1 - src, $2 - dst, $3 - back
if [ -d "$2" ]; then
if [ -d "$3" ]; then
ddir "$3"
fi
mv "$2" "$3"
colored "yellow" "* "
printf "Move %s to %s\n" "$2" "$3"
fi
colored "green" "+ "
printf "Link %s to %s\n\n" "$1" "$2"
ln -s "$1" "$2"
}
# file installation with backup if already exist
function finstall {
# $1 - src, $2 - dst, $3 - back
if [ -f "$2" ] || [ -L "$2" ]; then
if [ -f "$3" ] || [ -L "$3" ]; then
rm "$3"
colored "red" "# "
printf "Remove %s\n" "$3"
fi
mv "$2" "$3"
colored "yellow" "* "
printf "Move %s to %s\n" "$2" "$3"
fi
colored "green" "+ "
printf "Link %s to %s\n\n" "$1" "$2"
ln -s "$1" "$2"
}
# user specific files installation
function uinstall {
local dotfiles
dotfiles="$(dirname "$(readlink -f "$0")")"
mkdir -p "$HOME"/.config/hypr/user
cfile "$dotfiles"/.samples/user-options.js \
"$HOME"/.config/ags/user-options.js
cfile "$dotfiles"/.samples/user-config.conf \
"$HOME"/.config/hypr/user/user-config.conf
cfile "$dotfiles"/.samples/user-variables.conf \
"$HOME"/.config/hypr/user/user-variables.conf
}
# pywal links setup
function pinstall {
local cache
local config
cache="$HOME"/.cache/wal
config="$HOME"/.config
mkdir -p "$config"/hypr/user
lfile "$cache"/colors-dunst.conf \
"$config"/dunst/dunstrc.d/00-colors.conf
lfile "$cache"/colors-ags.css \
"$config"/ags/style/colors.css
lfile "$cache"/colors-hyprland.conf \
"$config"/hypr/user/colors.conf
lfile "$cache"/colors-fuzzel.ini \
"$config"/fuzzel/colors.ini
}
# main function
function install {
colored "magenta" "\n[ "
colored "red" "Installing dangooddd dotfiles"
colored "magenta" " ]\n\n"
local dotfiles
dotfiles="$(dirname "$(readlink -f "$0")")"
mkdir -p "$dotfiles"/.backup/.config
mkdir -p "$HOME"/Pictures/Screenshots
shopt -s dotglob
for src in "$dotfiles"/.config/*
do
local name
name="$(basename "$src")"
if [ -d "$src" ]; then
dinstall "$src" \
"$HOME"/.config/"$name" \
"$dotfiles"/.backup/.config/"$name"
fi
if [ -f "$src" ] || [ -L "$src" ]; then
finstall "$src" \
"$HOME"/.config/"$name" \
"$dotfiles"/.backup/.config/"$name"
fi
done
dinstall "$dotfiles"/.scripts \
"$HOME"/.scripts \
"$dotfiles"/.backup/.scripts
dinstall "$dotfiles"/.wallpapers \
"$HOME"/.wallpapers \
"$dotfiles"/.backup/.wallpapers
dinstall "$dotfiles"/.zsh \
"$HOME"/.zsh \
"$dotfiles"/.backup/.zsh
finstall "$dotfiles"/.home/.zshenv \
"$HOME"/.zshenv \
"$dotfiles"/.backup/.zshenv
uinstall
pinstall
colored "magenta" "[ "
colored "red" "Dotfiles installed!"
colored "magenta" " ]\n"
}
install