-
Notifications
You must be signed in to change notification settings - Fork 5
/
mxfb-comfort
executable file
·381 lines (263 loc) · 12.4 KB
/
mxfb-comfort
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
#!/bin/bash
#mxfb-comfort is an app to change the colors of the MX-comfort themes in MX-Linux Fluxbox
#V0.10 by Melber April 2022
#thanks to fehlix, i_ri, Girafenaine, purplemoon and Jerry3904 @forum.mxlinux.org for help, tips and encouragement
#License: GPL-3.0+
#mxcr-icon based on yad icon from papirus icon set
TEXTDOMAINDIR=/usr/share/locale
export TEXTDOMAIN="mxfb-accessories"
#define some variables
TITLE="MXFB-comfort"
CLASS="mxcr"
ICONPATH="/usr/share/pixmaps/mxcr-icon.png"
#delete stylelist and tempclr after use
trap "rm -r "~/.fluxbox/scripts/tempdir" " EXIT
# Check if colors.txt exists in MX-comfort and MX-comfort-dark, create if false
if [ ! -f ~/.fluxbox/styles/MX-comfort/mxcr.txt ]; then
printf "#0f56d9 #1d2324 #ffffff #ffffff #0f56d9 #CACDD0 #1d2324 #CACDD0 #c6c8c8 #1D2324 #EEEFF4 #ffffff #1D2324 #ffffff MX-comfort yes no" > ~/.fluxbox/styles/MX-comfort/mxcr.txt
fi
if [ ! -f ~/.fluxbox/styles/MX-comfort-dark/mxcr.txt ]; then
printf "#0f56d9 #1d2324 #ffffff #ffffff #0f56d9 #CACDD0 #1d2324 #CACDD0 #c6c8c8 #1D2324 #1D2324 #ffffff #DEDFE3 #ffffff MX-comfort-dark yes no" > ~/.fluxbox/styles/MX-comfort-dark/mxcr.txt
fi
#create tempdir
if [ ! -d ~/.fluxbox/scripts/tempdir ]; then
mkdir -p ~/.fluxbox/scripts/tempdir
fi
#read available styles
ls -d ~/.fluxbox/styles/*/mxcr.txt | cut -d '/' -f6- > ~/.fluxbox/scripts/tempdir/stylelist.txt
sed -i 's|/mxcr.txt||g' ~/.fluxbox/scripts/tempdir/stylelist.txt
#select starting style
BASESTYLE=$( yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --text="\n<b>Choose which style to use as a starting point</b>\n" --center --width=400 --height=300 --center --list --no-headers --separator=" " --column=Style < ~/.fluxbox/scripts/tempdir/stylelist.txt )
GETOUT=$(echo "$?")
if [ "$GETOUT" = 1 ]; then
exit
fi
if [ -z "$BASESTYLE" ]; then
yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --text="No starting style selected.\n\n<b>MX-comfort</b> will be used as the starting style." --button=OK --text-align=center --center --width=400 --height=200 --borders=20 \
BASESTYLE=MX-comfort
fi
#read colors
cd ~/.fluxbox/styles/$BASESTYLE
read -r -a NEWCOLORS < mxcr.txt
ACHL="${NEWCOLORS[0]}"
ACTI="${NEWCOLORS[1]}"
ACTXCOL="${NEWCOLORS[2]}"
ACSY="${NEWCOLORS[3]}"
ACGP="${NEWCOLORS[4]}"
INHL="${NEWCOLORS[5]}"
INTI="${NEWCOLORS[6]}"
INTXCOL="${NEWCOLORS[7]}"
INSY="${NEWCOLORS[8]}"
INGP="${NEWCOLORS[9]}"
MEBG="${NEWCOLORS[10]}"
METXTI="${NEWCOLORS[11]}"
METX="${NEWCOLORS[12]}"
METXHL="${NEWCOLORS[13]}"
NEWNAME="${NEWCOLORS[14]}"
MAKECUR="${NEWCOLORS[15]}"
MAKET2="${NEWCOLORS[16]}"
PLUS="${NEWCOLORS[17]}"
# function to be called with yad button
color_picker() {
local N=$1 C="$2"
local YAD=(
yad
--title="mxcr-color-selector"
--class=color-select
--window-icon=color-select
--posx=200
--posy=200
--color
--init-color="${C:=white}"
)
C=$("${YAD[@]}")
(($?==0)) && echo "$N:$C"
}
# function to be called with help button
mxcrhelp() {
yad --title="MXFB-comfort help" --window-icon=/usr/share/pixmaps/mxcr-icon.png --borders=20 --center --width=700 --height=400 --image /usr/share/doc/mxfb-comfort/help/mxcr-help.png --size=fit --button="Return to Main Window":1 \
}
export -f color_picker mxcrhelp
#color selection dialogue
MAIN=(yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --borders=20 --center --width=900 --height=400 --fixed --form --columns=7 --align=right --separator=" " --button="gtk-help":"bash -c mxcrhelp" --button="gtk-quit":1 --button="gtk-ok":0 \
--text="<b>\nEdit MX-comfort colors and create a new fluxbox style.\n\n</b>" \
--field="<b>Active Window</b>":LBL " " \
--field="Window Highlight":CLR "$ACHL" \
--field="Window Title":CLR "$ACTI" \
--field="Title Text":CLR "$ACTXCOL" \
--field="Window Symbol":CLR "$ACSY" \
--field="Window Grips":CLR "$ACGP" \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field='!color-select':BTN '@bash -c "color_picker 2 %2;"'
--field='!color-select':BTN '@bash -c "color_picker 3 %3;"'
--field='!color-select':BTN '@bash -c "color_picker 4 %4;"'
--field='!color-select':BTN '@bash -c "color_picker 5 %5;"'
--field='!color-select':BTN '@bash -c "color_picker 6 %6;"'
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field="<b>Inctive Window</b>":LBL " " \
--field="Window Highlight":CLR "$INHL" \
--field="Window Title":CLR "$INTI" \
--field="Title Text":CLR "$INTXCOL" \
--field="Window Symbol":CLR "$INSY" \
--field="Window Grips":CLR "$INGP" \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field='!color-select':BTN '@bash -c "color_picker 20 %20;"'
--field='!color-select':BTN '@bash -c "color_picker 21 %21;"'
--field='!color-select':BTN '@bash -c "color_picker 22 %22;"'
--field='!color-select':BTN '@bash -c "color_picker 23 %23;"'
--field='!color-select':BTN '@bash -c "color_picker 24 %24;"'
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field="<b>Fluxbox Menu</b>":LBL " " \
--field="Menu Background":CLR "$MEBG" \
--field="Menu Title Text":CLR "$METXTI" \
--field="Menu Text":CLR "$METX" \
--field="Menu HL Text":CLR "$METXHL" \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field='!color-select':BTN '@bash -c "color_picker 38 %38;"'
--field='!color-select':BTN '@bash -c "color_picker 39 %39;"'
--field='!color-select':BTN '@bash -c "color_picker 40 %40;"'
--field='!color-select':BTN '@bash -c "color_picker 41 %41;"'
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field=" ":LBL " " \
--field="<b> Name for new style </b>":LBL " " \
--field=" " ""$NEWNAME"" \
--field="<b> Make new style current?</b>":LBL " " \
--field=" ":CB "yes!no" \
--field="<b> Create matching panel?</b>":LBL " " \
--field=" ":CB "no!yes" \
)
COLORS=$("${MAIN[@]}")
(($?==0)) && echo "$COLORS" > ~/.fluxbox/scripts/tempdir/tempmain.txt
GETOUT=$(echo "$?")
if [ "$GETOUT" = 1 ]; then
exit
elif [ "$GETOUT" = 0 ]; then
cd ~/.fluxbox/scripts/tempdir
read -r -a NEWCOLORS < tempmain.txt
ACHL="${NEWCOLORS[0]}"
ACTI="${NEWCOLORS[1]}"
ACTXCOL="${NEWCOLORS[2]}"
ACSY="${NEWCOLORS[3]}"
ACGP="${NEWCOLORS[4]}"
INHL="${NEWCOLORS[5]}"
INTI="${NEWCOLORS[6]}"
INTXCOL="${NEWCOLORS[7]}"
INSY="${NEWCOLORS[8]}"
INGP="${NEWCOLORS[9]}"
MEBG="${NEWCOLORS[10]}"
METXTI="${NEWCOLORS[11]}"
METX="${NEWCOLORS[12]}"
METXHL="${NEWCOLORS[13]}"
NEWNAME="${NEWCOLORS[14]}"
MAKECUR="${NEWCOLORS[15]}"
MAKET2="${NEWCOLORS[16]}"
fi
#check style names yes no
if [ "$NEWNAME" = 'yes' -o "$NEWNAME" = 'no' ]; then
MAKET2="$MAKECUR"
MAKECUR="$NEWNAME"
NEWNAME=$(yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --height=200 --fixed --text="No Style name !" --form --center --borders=20 --separator="" \
--field="<b>Name for new style</b>":LBL " " \
--field=" " "New style name" )
GETOUT=$(echo "$?")
if [ "$GETOUT" != 0 ]; then
exit
fi
fi
#check new style name is not empty and forbid MX-comfort overwrite
while [ -z "$NEWNAME" -o "$NEWNAME" = 'MX-comfort' -o "$NEWNAME" = 'MX-comfort-dark' -o "$NEWNAME" = 'MX-comfort-plus' -o "$NEWNAME" = 'MX-comfort-plus-dark' ]; do
NEWNAME=$(yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --height=200 --fixed --text="Style name "$NEWNAME" is protected. Choose another name." --form --center --borders=20 --separator="" \
--field="<b>Name for new style</b>":LBL " " \
--field=" " "$NEWNAME-new" )
GETOUT=$(echo "$?")
if [ "$GETOUT" != 0 ]; then
exit
fi
done
#check if new style name exists, if yes ask if overwrite or different style name
while [ -d ~/.fluxbox/styles/$NEWNAME ]; do
yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --fixed --text="A Style with this name already exists. \n\nDo you want to overwrite <b>"$NEWNAME"</b>\nor save as a different style name\n" --button="Overwrite $NEWNAME":2 --button="Save as different style name":3 --text-align=center --center --borders=20\
case $? in
2) rm -r ~/.fluxbox/styles/$NEWNAME ;;
3) NEWNAME=$(yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --height=200 --fixed --form --center --borders=20 --separator="" \
--field="<b>Name for New Style</b>":LBL " " \
--field=" " "$NEWNAME-new" ) ;;
252) exit 0 ;;
esac
done
#tint2 warning
if [ "$MAKET2" = yes ]; then
yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --fixed --text="\nA copy of the default tint2 panel <b>tint2rc</b> will be created with a matching highlight colour.\n\nCreating a matching panel may have unexpected results if you have edited or overwritten the tint2rc file.\n\n<b>Please confirm that you want to create a matching tint2 panel</b>\n" --button="Create matching tint2 panel":2 --button="Do not create matching tint2 panel":3 --text-align=center --center --borders=20\
case $? in
2) MAKET2="yes" ;;
3) MAKET2="no" ;;
252) exit 0 ;;
esac
fi
#Copy MX-comfort to new style name
if [[ $PLUS = plus ]]; then
cp -r ~/.fluxbox/styles/MX-comfort-plus ~/.fluxbox/styles/$NEWNAME
else
cp -r ~/.fluxbox/styles/MX-comfort ~/.fluxbox/styles/$NEWNAME
fi
#move to new style directory and amend name and grips in theme config file
cd ~/.fluxbox/styles/$NEWNAME
echo ""$ACHL" "$ACTI" "$ACTXCOL" "$ACSY" "$ACGP" "$INHL" "$INTI" "$INTXCOL" "$INSY" "$INGP" "$MEBG" "$METXTI" "$METX" "$METXHL" "$NEWNAME" "$MAKECUR" "$MAKET2" "$PLUS"" > ~/.fluxbox/styles/$NEWNAME/mxcr.txt
sed -i "s/mx-comfort/$NEWNAME/g" theme.cfg
sed -i "s/menu.frame.color: #EEEFF4/menu.frame.color: $MEBG/g" theme.cfg
sed -i "s/menu.title.color: #1D2324/menu.title.color: $ACTI/g" theme.cfg
sed -i "s/menu.hilite.color: #0f56d9/menu.hilite.color: $ACHL/g" theme.cfg
sed -i "s/menu.frame.disableColor: #0f56d9/menu.frame.disableColor: $ACHL/g" theme.cfg
sed -i "s/menu.frame.textColor: #1D2324/menu.frame.textColor: $METX/g" theme.cfg
sed -i "s/menu.title.textColor: #ffffff/menu.title.textColor: $METXTI/g" theme.cfg
sed -i "s/menu.hilite.textColor: #ffffff/menu.hilite.textColor: $METXHL/g" theme.cfg
sed -i "s/window.label.focus.textColor: #ffffff/window.label.focus.textColor: $ACTXCOL/g" theme.cfg
sed -i "s/window.label.unfocus.textColor: #CACDD0/window.label.unfocus.textColor: $INTXCOL/g" theme.cfg
sed -i "s/window.grip.focus.color: #0f56d9/window.grip.focus.color: $ACGP/g" theme.cfg
sed -i "s/window.grip.unfocus.color: #1D2324/window.grip.unfocus.color: $INGP/g" theme.cfg
sed -i "s/window.handle.focus.color: #1D2324/window.handle.focus.color: $ACTI/g" theme.cfg
sed -i "s/window.handle.unfocus.color: #1D2324/window.handle.unfocus.color: $INTI/g" theme.cfg
#move to pixmap directory and amend colors
cd ~/.fluxbox/styles/$NEWNAME/pixmaps
sed -i "s/#0f56d9/$ACHL/g" *
sed -i "s/#1d2324/$ACTI/g" *
sed -i "s/#ffffff/$ACSY/g" *
sed -i "s/#CACDD0/$INHL/g" *-inactive.xpm
sed -i "s/#1D2324/$INTI/g" *-inactive.xpm
sed -i "s/#c6c8c8/$INSY/g" *-inactive.xpm
#copy and amend tint2 panel
if [ "$MAKET2" = yes ]; then
cd ~/.config/tint2
cp -r ~/.config/tint2/tint2rc ~/.config/tint2/$NEWNAME
sed -i "s/#0f56d9/$ACHL/g" $NEWNAME
rm tint2-sessionfile
echo '$HOME'"/.config/tint2/$NEWNAME" >> tint2-sessionfile
killall tint2
tint2 -c ~/.config/tint2/$NEWNAME >/dev/null 2>&1 & disown
fi
#set new style as current
if [ "$MAKECUR" = yes ]; then
sed -i -r "/^(session.styleFile:).*/s::\1 ~/.fluxbox/styles/$NEWNAME:" ~/.fluxbox/init
fluxbox-remote restart
yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --height=200 --fixed --center --borders=20 --text="All done!\n<b>"$NEWNAME"</b> has been set as the current style." --text-align=center --button="OK" \
fi
if [ "$MAKECUR" = no ]; then
yad --title="$TITLE" --class="$CLASS" --window-icon="$ICONPATH" --width=400 --height=250 --fixed --center --borders=20 --text="All done!\n<b>"$NEWNAME"</b> style has been created.\n\nYou can change styles with \n<b>Fluxbox menu > Appearance > Style</b> \n\nand refresh with \n<b>Fluxbox menu > Leave > Refresh</b> " --text-align=center --button="OK" \
fi
exit