-
Notifications
You must be signed in to change notification settings - Fork 6
/
mxfb-font
executable file
·467 lines (350 loc) · 12.8 KB
/
mxfb-font
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
#!/bin/bash
##This app was developed by MX Devs 2023 and released under GPLv3
# version 230604-01
TEXTDOMAINDIR=/usr/share/locale
export TEXTDOMAIN="mxfb-font"
source gettext.sh
# buttons
export BTN_CLOSE=$(gettext "Close") ; BTN_CLOSE+='!window-close'
export BTN_HELP=$(gettext "Help") ; BTN_HELP+='!help-contents'
export BTN_OK=$(gettext "OK") ; BTN_OK+='!object-select'
export BTN_APPLY=$(gettext "Apply") ; BTN_OK+='!object-select'
####check overlay file
CHECK_WINTITLE="$(grep "window.font: " $HOME/.fluxbox/overlay)"
if [ -z "$CHECK_WINTITLE" ]; then
echo '#window.font: Sans-11:Regular' >> "$HOME"/.fluxbox/overlay
fi
CHECK_MENUTITLE="$(grep "menu.title.font: " $HOME/.fluxbox/overlay)"
if [ -z "$CHECK_MENUTITLE" ]; then
echo '#menu.title.font: Sans-11:Regular' >> "$HOME"/.fluxbox/overlay
fi
CHECK_MENUFRAME="$(grep "menu.frame.font: " $HOME/.fluxbox/overlay)"
if [ -z "$CHECK_MENUFRAME" ]; then
echo '#menu.frame.font: Sans-10:Regular' >> "$HOME"/.fluxbox/overlay
fi
####
function choose_font() {
STYLE="$(grep 'session.styleFile:' $HOME/.fluxbox/init | sed -e "s/session\.styleFile\: //")"
STYLE_MENU_FRAME="$(grep 'menu.frame.font:' $STYLE/theme.cfg | sed -e "s/menu\.frame\.font\://")"
STYLE_MENU_TITLE="$(grep 'menu.title.font:' $STYLE/theme.cfg | sed -e "s/menu\.title\.font\://")"
STYLE_WINDOW_TITLE="$(grep 'window.font:' $STYLE/theme.cfg | sed -e "s/window\.font\://")"
WINDOW_TITLE_NOW="$(grep "#window.font" $HOME/.fluxbox/overlay)"
MENU_TITLE_NOW="$(grep "#menu.title.font" $HOME/.fluxbox/overlay)"
MENU_FRAME_NOW="$(grep "#menu.frame.font" $HOME/.fluxbox/overlay)"
if [ -z "$WINDOW_TITLE_NOW" ]; then
WINDOW_TITLE_OVERRIDE=true
else
WINDOW_TITLE_OVERRIDE=false
fi
if [ -z "$MENU_TITLE_NOW" ]; then
MENU_TITLE_OVERRIDE=true
else
MENU_TITLE_OVERRIDE=false
fi
if [ -z "$MENU_FRAME_NOW" ]; then
MENU_FRAME_OVERRIDE=true
else
MENU_FRAME_OVERRIDE=false
fi
####
WINDOW_TITLE_NOW="$(grep "window.font" $HOME/.fluxbox/overlay | sed -e "s/window\.font\://" | sed -e "s/-/ /g" | sed -e "s/\:/ /g" | sed -e "s/\#/ /g")"
window_title_now=($WINDOW_TITLE_NOW)
###
numa=0
until [ "$CHECKNUM_A" = "okay" ]
do
WINDOW_TITLE_SIZE="${window_title_now[$numa]}"
if [[ ! "$WINDOW_TITLE_SIZE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
numa=$(($numa-1))
else
CHECKNUM_A=okay
fi
done
unset 'window_title_now[$numa]'
unset 'CHECKNUM_A'
unset 'num'
WINDOW_TITLE_NOW=$(echo "${window_title_now[@]}" $WINDOW_TITLE_SIZE)
###
MENU_TITLE_NOW="$(grep "menu.title.font" $HOME/.fluxbox/overlay | sed -e "s/menu\.title\.font\://" | sed -e "s/-/ /g" | sed -e "s/\:/ /g" | sed -e "s/\#/ /g")"
menu_title_now=($MENU_TITLE_NOW)
###
numb=0
until [ "$CHECKNUM_B" = "okay" ]
do
MENU_TITLE_SIZE="${menu_title_now[$numb]}"
if [[ ! "$MENU_TITLE_SIZE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
numb=$(($numb-1))
else
CHECKNUM_B=okay
fi
done
unset 'menu_title_now[$numb]'
unset 'CHECKNUM_B'
MENU_TITLE_NOW=$(echo "${menu_title_now[@]}" $MENU_TITLE_SIZE)
###
MENU_FRAME_NOW="$(grep "menu.frame.font" $HOME/.fluxbox/overlay | sed -e "s/menu\.frame\.font\://" | sed -e "s/-/ /g" | sed -e "s/\:/ /g" | sed -e "s/\#/ /g")"
menu_frame_now=($MENU_FRAME_NOW)
###
numc=0
until [ "$CHECKNUM_C" = "okay" ]
do
MENU_FRAME_SIZE="${menu_frame_now[$numc]}"
if [[ ! "$MENU_FRAME_SIZE" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
numc=$(($numc-1))
else
CHECKNUM_C=okay
fi
done
unset 'menu_frame_now[$numc]'
unset 'CHECKNUM_C'
MENU_FRAME_NOW=$(echo "${menu_frame_now[@]}" $MENU_FRAME_SIZE)
###
####
GTK_FONT_NOW="$(grep "gtk-font-name" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-font-name\=//" )"
#gtk-xft-antialias=1 true 0 false
GTK_ANTI_NOW="$(grep "gtk-xft-antialias" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-xft-antialias\=//" )"
if [ "$GTK_ANTI_NOW" = "1" ]; then
GTK_ANTI_NOW=TRUE
else
GTK_ANTI_NOW=FALSE
fi
GTK_HINT_NOW="$(grep "gtk-xft-hinting" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-xft-hinting\=//" )"
if [ "$GTK_HINT_NOW" = "1" ]; then
GTK_HINT_NOW=TRUE
else
GTK_HINT_NOW=FALSE
fi
GTK_HINTSTYLE_NOW="$(grep "gtk-xft-hintstyle" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-xft-hintstyle\=//" )"
GTK_HINTSTYLE_NOW="$(echo $GTK_HINTSTYLE_NOW | sed -e "s/hint//" )"
#gtk-xft-rgba=none!rgb!bgr!vrgb!vbgr
#GTK_RGBA_NOW="$(grep "gtk-xft-rgba" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-xft-rgba\=//" )"
####
TITLE="$(gettext 'Font')"
CLASS="mxfb-font"
ICONPATH="/usr/share/pixmaps/mxfb-font.svg"
#helpfile=/usr/share/mxflux/HELP_Windowoverlay
TEXT1="Default fonts are defined in the current fluxbox style."
TEXT2="Gtk-font is independent of fluxbox style settings"
MAINPOS=$(yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" \
--borders=20 --center --width=500 --form --columns=2 --output-by-row \
--align=left --separator="_" --button="${BTN_CLOSE}":7 --button="${BTN_APPLY}":6 \
--text="<i>$TEXT1\n$TEXT2\n</i>" \
--field="<b>$(gettext 'Window Title Default'):</b>":LBL "" \
--field="$(gettext 'Override with') ":CHK "$WINDOW_TITLE_OVERRIDE" \
--field=" ":LBL "|" \
--field="<b>$(gettext 'Menu Title Default'):</b>":LBL "" \
--field="$(gettext 'Override with') ":CHK "$MENU_TITLE_OVERRIDE" \
--field=" ":LBL "|" \
--field="<b>$(gettext 'Menu Text Default'):</b>":LBL "" \
--field="$(gettext 'Override with') ":CHK "$MENU_FRAME_OVERRIDE" \
--field=" ":LBL "|" \
--field="<b>$(gettext 'Gtk Font'): </b>":LBL "|" \
--field=" ":LBL "|" \
--field="$(gettext 'Hinting')":CHK "$GTK_HINT_NOW" \
--field="$(gettext 'Antialising')":CHK "$GTK_ANTI_NOW" \
--field="<b>$STYLE_WINDOW_TITLE</b>":LBL "|" \
--field=" ":FN "$WINDOW_TITLE_NOW" \
--field=" ":LBL "|" \
--field="<b>$STYLE_MENU_TITLE</b>":LBL "|" \
--field=" ":FN "$MENU_TITLE_NOW" \
--field=" ":LBL "|" \
--field="<b>$STYLE_MENU_FRAME</b>":LBL "|" \
--field=" ":FN "$MENU_FRAME_NOW" \
--field=" ":LBL "|" \
--field=" ":FN "$GTK_FONT_NOW" \
--field=" ":LBL "|" \
--field="$(gettext 'Hinting Style')":CB "$GTK_HINTSTYLE_NOW!none!slight!medium!full"
)
ret=$?
case $ret in
7 | 252 )
ENDLOOP=getouttahere
;;
6 )
RES=$(echo "$MAINPOS" | sed -e "s/ /-/g" | sed -e "s/_/ /g" | sed -e "s/__/ /g" | sed -e "s/___/ /g" | sed -e "s/____/ /g")
override=($RES)
####function fb_font
fb_font() {
for i in $( eval echo "${new_font[@]}" )
do
if [ $i = 'Italic' ]; then
local ITALIC=' Italic'
elif [ $i = 'Bold' ]; then
local BOLD=' Bold'
elif [ $i = 'Oblique' ]; then
local OBLIQUE=' Oblique'
elif [ $i = 'Condensed' ]; then
local COND1=' Condensed'
elif [ $i = 'Condensed,' ]; then
local COND2=' Condensed,'
elif [ $i = 'Light' ]; then
local LIGHT=' Light'
elif [ $i = 'Medium' ]; then
local MEDIUM=' Medium'
elif [ $i = 'Extrabold' ]; then
local EXTRABOLD=' Extrabold'
fi
done
if [ "$OBLIQUE" = " Oblique" ]; then
if [ "$BOLD" = " Bold" ]; then
NEWTYPE=$BOLD:$OBLIQUE
OBLIQUE=""
BOLD=""
else
NEWTYPE=$OBLIQUE
OBLIQUE=""
fi
elif [ "$ITALIC" = " Italic" ]; then
if [ "$BOLD" = " Bold" ]; then
NEWTYPE=$BOLD:$ITALIC
ITALIC=""
BOLD=""
else
NEWTYPE=$ITALIC
ITALIC=""
fi
elif [ "$BOLD" = " Bold" ]; then
NEWTYPE=$BOLD
BOLD=""
else NEWTYPE=Regular
fi
NEWTYPE=$(echo $NEWTYPE | sed -e "s/ //g")
if [ "$COND2" = " Condensed," ]; then
COND1=""
fi
NEWFONT=$(echo "${new_font[@]}" | sed -e "s/ Italic//" | sed -e "s/ Bold//" | sed -e "s/ Oblique//" | sed -e "s/ Light//" | sed -e "s/\,//" | sed -e "s/ Condensed//g")
NEWFONT=$(echo "$NEWFONT$COND1$LIGHT$MEDIUM$EXTRABOLD$COND2$BOLD-$NEWSIZE:$NEWTYPE")
}
export fb_font
####
WINDOW_TITLE_OVERRIDE="${override[0]}"
if [ "$WINDOW_TITLE_OVERRIDE" = FALSE ]; then
WINDOW_TITLE_NOW="$(grep "#window.font" $HOME/.fluxbox/overlay)"
if [ -z "$WINDOW_TITLE_NOW" ]; then
sed -i 's/^window.font:/#&/' $HOME/.fluxbox/overlay
fi
fi
if [ "$WINDOW_TITLE_OVERRIDE" = TRUE ]; then
WINDOW_TITLE_NEW=$(echo "${override[1]}" | sed -e "s/-/ /g")
window_title_new=($WINDOW_TITLE_NEW)
NEWSIZE="${window_title_new[-1]}"
unset 'window_title_new[-1]'
new_font="${window_title_new[@]}"
###
fb_font
###
unset new_font
WINDOW_TITLE_NEW="window.font: $NEWFONT"
WINDOW_TITLE_NOW="$(grep "window.font: " $HOME/.fluxbox/overlay)"
if [ "$WINDOW_TITLE_NEW" != "$WINDOW_TITLE_NOW" ]; then
sed -i "s/$WINDOW_TITLE_NOW/$WINDOW_TITLE_NEW/" $HOME/.fluxbox/overlay
fi
fi
####
MENU_TITLE_OVERRIDE="${override[2]}"
if [ "$MENU_TITLE_OVERRIDE" = FALSE ]; then
MENU_TITLE_NOW="$(grep "#menu.title.font" $HOME/.fluxbox/overlay)"
if [ -z "$MENU_TITLE_NOW" ]; then
sed -i 's/^menu.title.font:/#&/' $HOME/.fluxbox/overlay
fi
fi
if [ "$MENU_TITLE_OVERRIDE" = TRUE ]; then
MENU_TITLE_NEW=$(echo "${override[3]}" | sed -e "s/-/ /g")
menu_title_new=($MENU_TITLE_NEW)
NEWSIZE="${menu_title_new[-1]}"
unset 'menu_title_new[-1]'
new_font="${menu_title_new[@]}"
###
fb_font
###
MENU_TITLE_NEW="menu.title.font: $NEWFONT"
MENU_TITLE_NOW="$(grep "menu.title.font: " $HOME/.fluxbox/overlay)"
if [ "$MENU_FRAME_NEW" != "$MENU_FRAME_NOW" ]; then
sed -i "s/$MENU_TITLE_NOW/$MENU_TITLE_NEW/" $HOME/.fluxbox/overlay
fi
fi
####
MENU_FRAME_OVERRIDE="${override[4]}"
if [ "$MENU_FRAME_OVERRIDE" = FALSE ]; then
MENU_FRAME_NOW="$(grep "#menu.frame.font" $HOME/.fluxbox/overlay)"
if [ -z "$MENU_FRAME_NOW" ]; then
sed -i 's/^menu.frame.font:/#&/' $HOME/.fluxbox/overlay
fi
fi
if [ "$MENU_FRAME_OVERRIDE" = TRUE ]; then
MENU_FRAME_NEW=$(echo "${override[5]}" | sed -e "s/-/ /g")
menu_frame_new=($MENU_FRAME_NEW)
NEWSIZE="${menu_frame_new[-1]}"
unset 'menu_frame_new[-1]'
new_font="${menu_frame_new[@]}"
###
fb_font
###
MENU_FRAME_NEW="menu.frame.font: $NEWFONT"
MENU_FRAME_NOW="$(grep "menu.frame.font: " $HOME/.fluxbox/overlay)"
if [ "$MENU_FRAME_NEW" != "$MENU_FRAME_NOW" ]; then
sed -i "s/$MENU_FRAME_NOW/$MENU_FRAME_NEW/" $HOME/.fluxbox/overlay
fi
fi
####
GTK_FONT_NOW="$(grep "gtk-font-name" $HOME/.config/gtk-3.0/settings.ini | sed -e "s/gtk-font-name\=//" )"
GTK_FONT_NEW=$(echo "${override[6]}" | sed -e "s/-/ /g")
if [ "$GTK_FONT_NOW" != "$GTK_FONT_NEW" ]; then
sed -i "s/$GTK_FONT_NOW/$GTK_FONT_NEW/" $HOME/.config/gtk-3.0/settings.ini
sed -i "s/\"$GTK_FONT_NOW\"/\"$GTK_FONT_NEW\"/" $HOME/.gtkrc-2.0
fi
#gtk-xft-antialias
GTK_ANTI_NOW="$(grep "gtk-xft-antialias" $HOME/.config/gtk-3.0/settings.ini)"
GTK_ANTI_NEW=$(echo "${override[9]}")
if [ "$GTK_ANTI_NEW" = TRUE ]; then
GTK_ANTI_NEW=1
elif [ "$GTK_ANTI_NEW" = FALSE ]; then
GTK_ANTI_NEW=0
fi
GTK_ANTI_NEW="gtk-xft-antialias=$GTK_ANTI_NEW"
if [ "$GTK_ANTI_NOW" != "$GTK_ANTI_NEW" ]; then
sed -i "s/$GTK_ANTI_NOW/$GTK_ANTI_NEW/" $HOME/.config/gtk-3.0/settings.ini
sed -i "s/$GTK_ANTI_NOW/$GTK_ANTI_NEW/" $HOME/.gtkrc-2.0
RELOAD_GTK=TRUE
fi
#gtk-xft-hinting
GTK_HINT_NOW="$(grep "gtk-xft-hinting" $HOME/.config/gtk-3.0/settings.ini)"
GTK_HINT_NEW=$(echo "${override[7]}")
if [ "$GTK_HINT_NEW" = TRUE ]; then
GTK_HINT_NEW=1
elif [ "$GTK_HINT_NEW" = FALSE ]; then
GTK_HINT_NEW=0
fi
GTK_HINT_NEW=gtk-xft-hinting=$GTK_HINT_NEW
if [ "$GTK_HINT_NOW" != "$GTK_HINT_NEW" ]; then
sed -i "s/$GTK_HINT_NOW/$GTK_HINT_NEW/" $HOME/.config/gtk-3.0/settings.ini
sed -i "s/$GTK_HINT_NOW/$GTK_HINT_NEW/" $HOME/.gtkrc-2.0
RELOAD_GTK=TRUE
fi
GTK_HINTSTYLE_NOW="$(grep "gtk-xft-hintstyle" $HOME/.config/gtk-3.0/settings.ini)"
GTK_HINTSTYLE_NOW2="$(grep "gtk-xft-hintstyle" $HOME/.gtkrc-2.0)"
GTK_HINTSTYLE_NEW=$(echo "${override[8]}" | sed -e "s/-/ /g")
GTK_HINTSTYLE_NEW1=gtk-xft-hintstyle=hint$GTK_HINTSTYLE_NEW
GTK_HINTSTYLE_NEW2=gtk-xft-hintstyle='"'hint$GTK_HINTSTYLE_NEW'"'
if [ "$GTK_HINTSTYLE_NOW" != "$GTK_HINTSTYLE_NEW" ]; then
sed -i "s/$GTK_HINTSTYLE_NOW/$GTK_HINTSTYLE_NEW1/" $HOME/.config/gtk-3.0/settings.ini
sed -i "s/$GTK_HINTSTYLE_NOW2/$GTK_HINTSTYLE_NEW2/" $HOME/.gtkrc-2.0
RELOAD_GTK=TRUE
fi
####
if [ "$RELOAD_GTK" = TRUE ]; then
theme=$(gsettings get org.gnome.desktop.interface gtk-theme)
gsettings set org.gnome.desktop.interface gtk-theme ''
sleep 1
gsettings set org.gnome.desktop.interface gtk-theme $theme
fi
fluxbox-remote reloadstyle ; fluxbox-remote reconfigure
;;
esac
}
export choose_font
####
until [ "$ENDLOOP" = "getouttahere" ]; do
choose_font
done
exit