-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild
executable file
·162 lines (117 loc) · 4.24 KB
/
build
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
#!/usr/bin/env zsh
# -- Setup ----------------------------------------------------------------------
set -e
local -a help clean force
zparseopts -D --\
h=help -help=help\
c=clean -clean=clean\
f=force -force=force\
t:=theme -theme:=theme
# installation target
ILOC=$HOME/.xmonad/xmonad-x86_64-linux
# find all files newer than the compiled xmonad
OLD=$(find . -newer $ILOC | grep -Ev 'dist*|.git' | wc -l)
# -- Functions ------------------------------------------------------------------
help () {
echo "
Configuration script for compiling Aloysius' XMonad setup
Usage:
./build [FLAGS]
Flags:
-h --help prints this message
-c --clean compile then remove build content
-C --tidy only remove previous build content
-a --all get all of the supplementary content
-t --theme [nord|dracula|ephemeral|laserwave]
sets a theme and recompiles xmonad with that theme
No flag causes a standard compile with no cleaning
"
}
compile () {
printf " Configuring\r"
[[ -a cabal.project.local ]] ||\
nix-shell --command \
"cabal configure --enable-optimisation --enable-library-stripping" >\
install.log
echo " Configured "
printf " Building\r"
nix-shell --command "cabal build" >> install.log 2>&1
echo " Built "
printf " Installing\r"
fd -tf 'xmonad' dist* -x mv -u {} $ILOC
echo " Installed "
}
clean () {
printf " Cleaning\r"
find . \( -name '*.hi'\
-or -name '*.o'\
-or -name '*.errors'\
-or -name '*.log'\
-or -name 'cabal.project.local*'\
\) -type f -delete
rm -rf dist-newstyle/
rm -rf dist/
echo " Cleaned "
}
build () {
echo " Building Aloysius, sit tight"
[[ -n $clean ]] && compile && clean && xmonad --restart && exit
[[ $# -eq 0 ]] && compile && echo " Restarting XMonad " &&\
xmonad --restart && exit
}
all () {
printf " Fetching scripts\r"
git clone https://github.com/karetsu/scripts $HOME/.scripts 1>install.log
echo " Scripts installed "
printf " Fetching nix-overlay\r"
[[ -d $HOME/.config/nixpkgs ]] &&\
echo "Overlay exists, skipping" >> install.log ||\
git clone https://github.com/karetsu/ $HOME/.config/nixpkgs 1>install.log
(( $+commands[home-manager] )) &&\
home-manager switch ||\
echo "home-manager does not exist" >> install.log
echo " Overlay installed "
}
themeCompile () {
theme=("${(@)theme:#-t}")
echo " Setting new theme: $theme[@]"
case $theme[@] in
nord | laserwave | ephemeral | horizon | dracula | lovelace | nature )
setTheme $theme[@];;
*)
echo " You have incorrectly specified a theme, please see the help"
;;
esac
}
setTheme () {
THEME=$theme[@]
PROPER=$(echo $theme[@] | sed 's/^\s*./\U&\E/g')
sed "s/import qualified Theme.*/import qualified Theme.$PROPER as T/" \
-i lib/Theme/ChosenTheme.hs
# kitty
[[ -a ~/.config/kitty/themes/$THEME.conf ]] &&
sed "s/include themes\/.*/include themes\/$THEME.conf/" \
-i ~/.config/kitty/kitty.conf
# everything under home-manager
[[ -a ~/.config/nixpkgs/etc/dunst.nix ]] && \
sed "s/\(let colours = import .\/themes\/\).*;/\1$THEME.nix;/" \
-i ~/.config/nixpkgs/etc/dunst.nix
[[ -a ~/.config/nixpkgs/etc/dunst.nix ]] && \
sed "s/\(let colours = import .\/themes\/\).*;/\1$THEME.nix;/" \
-i ~/.config/nixpkgs/etc/dunst.nix
[[ -a ~/.config/nixpkgs/etc/polybar-xmonad.nix ]] && \
sed "s/\(colours = import .\/themes\/\).*;/\1$THEME.nix;/" \
-i ~/.config/nixpkgs/etc/polybar-xmonad.nix
[[ -a ~/.config/nixpkgs/etc/xresources.nix ]] && \
sed "s/\(colours = import .\/themes\/\).*;/\1$THEME.nix;/" \
-i ~/.config/nixpkgs/etc/xresources.nix
home-manager switch 2>> install.log 1>/dev/null
pkill -USR1 polybar
echo " Additional theme elements applied"
}
# Runtime --------------------------------------------------------------------
[[ -n $help ]] && help && exit
[[ -n $clean ]] && clean && exit
[[ -n $force ]] && build && exit
[[ -n $theme ]] && themeCompile && build && ~/.scripts/caffeine && exit
[[ $OLD > 1 ]] && build || echo " No compilation required"