-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·154 lines (133 loc) · 3.92 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
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
#!/usr/bin/env sh
# DEPRECATED, use python stuff instead
# Dependencies:
# POSIX shell (bash in sh emulation, for example can be used)
# coreutils:
# printf
# realpath
# dirname
error_color() {
printf "\x1b[31m" #red for error
}
warn_color() {
printf "\x1b[33m"
}
ok_color() {
printf "\x1b[32m"
}
reset_color() {
printf "\x1b[0m"
}
debug() {
if [ -n "$DOTS_DEBUG" ]
then
echo "$1"
fi
}
setup() {
src="$1"
dest="$2"
name="$3"
# maybe we forgot to set $name
if [ -z "$name" ]
then
warn_color
echo "setup called with $src to $dest, but without $name, but we'll continue"
echo "fix it, please"
reset_color
fi
# check if arguments passed
if [ -z "$src" ]
then
error_color
echo "$name: src is undefined, skip"
reset_color
return
elif [ -z "$dest" ]
then
error_color
echo "$name: destination is undefined, skip"
reset_color
return
fi
# check if link exists
if [ -L "$dest" ]
then
if [ -e "$dest" ]
then
warn_color
echo "$name: symbolic link already set"
reset_color
return
else
error_color
echo "$name: symbolic link set, but broken, skip"
reset_color
return
fi
fi
# check if destination already exists
if [ -e "$dest" ]
then
error_color
echo "$name: config exists, skip"
reset_color
return
fi
# do set up
if ln -s "$src" "$dest"
then
ok_color
echo "$name : config set up from $src to $dest"
reset_color
else
error_color
echo "$name : something went wrong with setting config"
reset_color
fi
}
warn_color
echo "deprecated! use build.py instead"
reset_color
# set DOTFILES to default value if unset
debug "${DOTFILES="$HOME/.config/dotfiles"}"
called_with=$(dirname "$0") # get relative path
called_from=$(realpath "$called_with") # convert to absolute
if [ "$called_from" = "$DOTFILES" ]
then
# Checking variables
#
# For firefox, we may automaticaly guess profile directory, but there may
# be more than one so just set FIREFOX_PROFILE_PATH yourself
# Enter about:profiles in firefox to see needed directory
#firefox_err_msg="
# Path to firefox profile must be specified
# Read comments in setup.sh to fix it
#"
#${FIREFOX_PROFILE_PATH?"$(error_color)$firefox_err_msg$(reset_color)"}
# Run setup
echo "===== Dotfiles root in $DOTFILES ====="
setup "$DOTFILES/shells/fish/config.fish" "$HOME/.config/fish/config.fish" "fish"
setup "$DOTFILES/wm/i3" "$HOME/.config/i3" "i3"
setup "$DOTFILES/editors/nvim" "$HOME/.config/nvim" "Neovim"
setup "$DOTFILES/other/rofi" "$HOME/.config/rofi" "rofi"
setup "$DOTFILES/pagers/most/.mostrc" "$HOME/.mostrc" "most"
#setup "$DOTFILES/browser/firefox/user.js" "$FIREFOX_PROFILE_PATH/user.js" "firefox"
setup "$DOTFILES/wm/bars/polybar" "$HOME/.config/polybar" "polybar"
setup "$DOTFILES/other/mpv/mpv.conf" "$HOME/.config/mpv/mpv.conf" "mpv"
setup "$DOTFILES/other/mpv/input.conf" "$HOME/.config/mpv/input.conf" "mpv hotkeys"
setup "$DOTFILES/wm/compositors/picom" "$HOME/.config/picom" "picom"
setup "$DOTFILES/terminals/kitty" "$HOME/.config/kitty" "kitty"
setup "$DOTFILES/tmux/.tmux.conf" "$HOME/.tmux.conf" "tmux"
else
# Script is using default value for dotfiles path, which in my case is
# $HOME/.config/dotfiles. If path where script runned don't match this value,
# that means your dotfiles directory is in another place.
# You should change DOTFILES variable in script above or set DOTFILES variable.
error_color
echo "
Script runned from $called_from, but \$DOTFILES set to $DOTFILES.
Read comments in setup.sh to fix it
"
reset_color
fi