forked from FruitieX/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·57 lines (45 loc) · 1.48 KB
/
compile.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
#!/bin/zsh
# compiles configuration files by swapping out variables with values from
# .theme.cfg
#
# also generate a wallpaper from bg.png with colors from .theme.cfg
# cd to root of git repo
cd "$(dirname $0)"
DOTFILES=$(pwd)
rm -r .compiled
mkdir .compiled
touch .compiled/DO_NOT_EDIT_FILES_IN_THIS_DIRECTORY
variables=$(cat .theme.cfg | cut -d' ' -f1 | sed '/^$/d')
# arguments: filename
function find_and_replace() {
if [[ ! -f ".compiled/$1" ]]; then
mkdir -p $(dirname ".compiled/$1")
cp "$1" ".compiled/$1"
fi
echo $variables | while read -r var; do
sed -i -e "s|\$$var|$($HOME/bin/theme.sh $var)|g" .compiled/$1
done
}
# arguments: filename
function symlink() {
rm "$HOME/$1"
ln -s "$DOTFILES/.compiled/$1" "$HOME/$1"
}
find_and_replace ".Xdefaults"
symlink ".Xdefaults"
find_and_replace ".tmux.conf"
symlink ".tmux.conf"
find_and_replace ".config/dunst/dunstrc"
symlink ".config/dunst/dunstrc"
find_and_replace ".colors/base16.sh"
symlink ".colors/base16.sh"
find_and_replace ".conkyrc"
symlink ".conkyrc"
screen_width=$(xrandr | head -n1 | cut -d' ' -f8)
echo "\
minimum_size $(($screen_width - 50))
maximum_width $(($screen_width - 50))
$(cat ~/.conkyrc)" > ~/.conkyrc
# generate wallpaper for color theme
convert "$DOTFILES/bg.png" -fill "#$($DOTFILES/bin/theme.sh inactive_bg)" -opaque black "$DOTFILES/.compiled/bg.png"
convert "$DOTFILES/.compiled/bg.png" -fill "#$($DOTFILES/bin/theme.sh active_bg)" -opaque white "$DOTFILES/.compiled/bg.png"