-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply.sh
356 lines (306 loc) · 12.5 KB
/
apply.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#!/usr/bin/env bash
## Copyright (C) 2020-2022 Aditya Shakya <[email protected]>
##
## Script To Apply Themes
## Theme ------------------------------------
TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
THEME="${TDIR##*/}"
source "$HOME"/.config/openbox-themes/themes/"$THEME"/theme.bash
altbackground="`pastel color $background | pastel lighten $light_value | pastel format hex`"
altforeground="`pastel color $foreground | pastel darken $dark_value | pastel format hex`"
## Directories ------------------------------
PATH_CONF="$HOME/.config"
PATH_TERM="$PATH_CONF/alacritty"
PATH_DUNST="$PATH_CONF/dunst"
PATH_GEANY="$PATH_CONF/geany"
PATH_OBOX="$PATH_CONF/openbox"
PATH_OBTS="$PATH_CONF/openbox-themes"
PATH_PBAR="$PATH_OBTS/themes/$THEME/polybar"
PATH_ROFI="$PATH_OBTS/themes/$THEME/rofi"
PATH_XFCE="$PATH_CONF/xfce4/terminal"
## Wallpaper ---------------------------------
apply_wallpaper() {
for head in {0..10}; do
nitrogen --head=$head --save --set-zoom-fill "$wallpaper" &>/dev/null
done
}
## Polybar -----------------------------------
apply_polybar() {
# modify polybar launch script
sed -i -e "s/STYLE=.*/STYLE=\"$THEME\"/g" ${PATH_OBTS}/themes/polybar.sh
# apply default theme fonts
sed -i -e "s/font-0 = .*/font-0 = \"$polybar_font\"/g" ${PATH_PBAR}/config.ini
# rewrite colors file
cat > ${PATH_PBAR}/colors.ini <<- EOF
[color]
BACKGROUND = ${background}
FOREGROUND = ${foreground}
ALTBACKGROUND = ${altbackground}
ALTFOREGROUND = ${altforeground}
ACCENT = ${accent}
BLACK = ${color0}
RED = ${color1}
GREEN = ${color2}
YELLOW = ${color3}
BLUE = ${color4}
MAGENTA = ${color5}
CYAN = ${color6}
WHITE = ${color7}
ALTBLACK = ${color8}
ALTRED = ${color9}
ALTGREEN = ${color10}
ALTYELLOW = ${color11}
ALTBLUE = ${color12}
ALTMAGENTA = ${color13}
ALTCYAN = ${color14}
ALTWHITE = ${color15}
COLOR_R = ${color_red}
COLOR_G = ${color_green}
COLOR_Y = ${color_yellow}
EOF
# launch polybar
bash ${PATH_OBTS}/themes/polybar.sh
}
# Rofi --------------------------------------
apply_rofi() {
# modify rofi scripts
sed -i -e "s/STYLE=.*/STYLE=\"$THEME\"/g" \
${PATH_OBTS}/scripts/askpass \
${PATH_OBTS}/scripts/launcher \
${PATH_OBTS}/scripts/music \
${PATH_OBTS}/scripts/powermenu \
${PATH_OBTS}/scripts/runner \
${PATH_OBTS}/scripts/screenshot
# apply default theme fonts
sed -i -e "s/font:.*/font: \"$rofi_font\";/g" ${PATH_ROFI}/shared/fonts.rasi
# rewrite colors file
cat > ${PATH_ROFI}/shared/colors.rasi <<- EOF
* {
background: ${background};
background-alt: ${altbackground};
foreground: ${foreground};
selected: ${accent};
active: ${color_green};
urgent: ${color_red};
}
EOF
# modify icon theme
if [[ -f "$PATH_CONF"/rofi/config.rasi ]]; then
sed -i -e "s/icon-theme:.*/icon-theme: \"$rofi_icon\";/g" ${PATH_CONF}/rofi/config.rasi
fi
}
# Network Menu ------------------------------
apply_netmenu() {
if [[ -f "$PATH_CONF"/networkmanager-dmenu/config.ini ]]; then
sed -i -e "s#dmenu_command = .*#dmenu_command = rofi -dmenu -theme $PATH_ROFI/networkmenu.rasi#g" ${PATH_CONF}/networkmanager-dmenu/config.ini
fi
}
# Terminal ----------------------------------
apply_terminal() {
# alacritty : fonts
sed -i ${PATH_TERM}/fonts.yml \
-e "s/family: .*/family: \"$terminal_font_name\"/g" \
-e "s/size: .*/size: $terminal_font_size/g"
# alacritty : colors
cat > ${PATH_TERM}/colors.yml <<- _EOF_
## Colors configuration
colors:
# Default colors
primary:
background: '${background}'
foreground: '${foreground}'
# Normal colors
normal:
black: '${color0}'
red: '${color1}'
green: '${color2}'
yellow: '${color3}'
blue: '${color4}'
magenta: '${color5}'
cyan: '${color6}'
white: '${color7}'
# Bright colors
bright:
black: '${color8}'
red: '${color9}'
green: '${color10}'
yellow: '${color11}'
blue: '${color12}'
magenta: '${color13}'
cyan: '${color14}'
white: '${color15}'
_EOF_
# xfce terminal : fonts & colors
sed -i ${PATH_XFCE}/terminalrc \
-e "s/FontName=.*/FontName=$terminal_font_name $terminal_font_size/g" \
-e "s/ColorBackground=.*/ColorBackground=${background}/g" \
-e "s/ColorForeground=.*/ColorForeground=${foreground}/g" \
-e "s/ColorCursor=.*/ColorCursor=${foreground}/g" \
-e "s/ColorPalette=.*/ColorPalette=${color0};${color1};${color2};${color3};${color4};${color5};${color6};${color7};${color8};${color9};${color10};${color11};${color12};${color13};${color14};${color15}/g"
}
# Geany -------------------------------------
apply_geany() {
sed -i ${PATH_GEANY}/geany.conf \
-e "s/color_scheme=.*/color_scheme=$geany_colors/g" \
-e "s/editor_font=.*/editor_font=$geany_font/g"
}
# Appearance --------------------------------
apply_appearance() {
# apply gtk theme, icons, cursor & fonts
xfconf-query -c xsettings -p /Gtk/FontName -s "$gtk_font"
xfconf-query -c xsettings -p /Net/ThemeName -s "$gtk_theme"
xfconf-query -c xsettings -p /Net/IconThemeName -s "$icon_theme"
xfconf-query -c xsettings -p /Gtk/CursorThemeName -s "$cursor_theme"
# inherit cursor theme
if [[ -f "$HOME"/.icons/default/index.theme ]]; then
sed -i -e "s/Inherits=.*/Inherits=$cursor_theme/g" "$HOME"/.icons/default/index.theme
fi
}
# Openbox -----------------------------------
apply_obconfig () {
namespace="http://openbox.org/3.4/rc"
config="$PATH_OBOX/rc.xml"
# Theme
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:name' -v "$ob_theme" "$config"
# Title
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:titleLayout' -v "$ob_layout" "$config"
# Fonts
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuHeader"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuHeader"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuHeader"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuHeader"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuItem"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuItem"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuItem"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="MenuItem"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:name' -v "$ob_font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:size' -v "$ob_font_size" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:slant' -v Normal "$config"
# Openbox Menu Style
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:menu/a:file' -v "$ob_menu" "$config"
# Margins
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:margins/a:top' -v ${ob_margin_t} "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:margins/a:bottom' -v ${ob_margin_b} "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:margins/a:left' -v ${ob_margin_l} "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:openbox_config/a:margins/a:right' -v ${ob_margin_r} "$config"
# Reload Openbox Config
openbox --reconfigure
}
# Dunst -------------------------------------
apply_dunst() {
# modify dunst config
sed -i ${PATH_DUNST}/dunstrc \
-e "s/width = .*/width = $dunst_width/g" \
-e "s/height = .*/height = $dunst_height/g" \
-e "s/offset = .*/offset = $dunst_offset/g" \
-e "s/origin = .*/origin = $dunst_origin/g" \
-e "s/font = .*/font = $dunst_font/g" \
-e "s/frame_width = .*/frame_width = $dunst_border/g" \
-e "s/separator_height = .*/separator_height = $dunst_separator/g" \
-e "s/line_height = .*/line_height = $dunst_separator/g"
# modify colors
sed -i '/urgency_low/Q' ${PATH_DUNST}/dunstrc
cat >> ${PATH_DUNST}/dunstrc <<- _EOF_
[urgency_low]
timeout = 2
background = "${background}"
foreground = "${foreground}"
frame_color = "${accent}"
[urgency_normal]
timeout = 5
background = "${background}"
foreground = "${foreground}"
frame_color = "${accent}"
[urgency_critical]
timeout = 0
background = "${background}"
foreground = "${color_red}"
frame_color = "${color_red}"
_EOF_
# restart dunst
pkill dunst && dunst &
}
# Plank -------------------------------------
apply_plank() {
# create temporary config file
cat > "$HOME"/.cache/plank.conf <<- _EOF_
[dock1]
alignment='center'
auto-pinning=true
current-workspace-only=false
dock-items=['xfce-settings-manager.dockitem', 'Alacritty.dockitem', 'thunar.dockitem', 'firefox.dockitem', 'geany.dockitem']
hide-delay=0
hide-mode='$plank_hmode'
icon-size=$plank_icon_size
items-alignment='center'
lock-items=false
monitor=''
offset=$plank_offset
pinned-only=false
position='$plank_position'
pressure-reveal=false
show-dock-item=false
theme='$plank_theme'
tooltips-enabled=true
unhide-delay=0
zoom-enabled=true
zoom-percent=$plank_zoom_percent
_EOF_
# apply config and reload plank
cat "$HOME"/.cache/plank.conf | dconf load /net/launchpad/plank/docks/
}
# Compositor --------------------------------
apply_compositor() {
picom_cfg="$PATH_CONF/picom.conf"
# modify picom config
sed -i "$picom_cfg" \
-e "s/backend = .*/backend = \"$picom_backend\";/g" \
-e "s/corner-radius = .*/corner-radius = $picom_corner;/g" \
-e "s/shadow-radius = .*/shadow-radius = $picom_shadow_r;/g" \
-e "s/shadow-opacity = .*/shadow-opacity = $picom_shadow_o;/g" \
-e "s/shadow-offset-x = .*/shadow-offset-x = $picom_shadow_x;/g" \
-e "s/shadow-offset-y = .*/shadow-offset-y = $picom_shadow_y;/g" \
-e "s/method = .*/method = \"$picom_blur_method\";/g" \
-e "s/strength = .*/strength = $picom_blur_strength;/g"
}
# Create Theme File -------------------------
create_file() {
theme_file="$PATH_OBTS/themes/.current"
if [[ ! -f "$theme_file" ]]; then
touch ${theme_file}
fi
echo "$THEME" > ${theme_file}
}
# Notify User -------------------------------
notify_user() {
dunstify -u normal -h string:x-dunst-stack-tag:applytheme -i /usr/share/archcraft/icons/dunst/themes.png "Applying Style : $THEME"
}
## Execute Script ---------------------------
notify_user
create_file
apply_wallpaper
apply_polybar
apply_rofi
apply_netmenu
apply_terminal
apply_geany
apply_appearance
apply_obconfig
apply_dunst
apply_plank
apply_compositor
# fix cursor theme (run it in the end)
xsetroot -cursor_name left_ptr