-
Notifications
You must be signed in to change notification settings - Fork 2
/
change-colors-sh
executable file
·588 lines (440 loc) · 19.6 KB
/
change-colors-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
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#!/bin/bash
ROOT="$(readlink -f $(dirname "$0"))"
COLORDIR=$ROOT/"$1"
print_usage() {
echo "Usage: $0 [options] ColorFlder"
echo
echo "Options:"
echo " -h --help Display this message"
echo " -t skip termite colors"
echo " -e skip elokab-teminal colors"
echo " -g skip Gtk theme"
echo " -i skip Icons theme"
echo " -m skip tint2"
echo " -k skip Conky "
echo
echo "Examples:"
echo " $0 -g -i Sky"
exit 1
}
while [[ $# > 0 ]]
do
case ${1} in
-h|--help)
print_usage
;;
-t)
#echo "skip termite $#"
SKIPTERMITE="true"
;;
-e)
#echo "skip elokab $#"
SKIPELOKAB="true"
;;
-g)
#echo "skip gtk $#"
SKIPGTKTHEME="true"
;;
-i)
#echo "skip icons $#"
SKIPICONSTHEME="true"
;;
-m)
#echo "skip tint2 $#"
SKIPTINT2="true"
;;
-k)
#echo "skip conky $#"
SKIPCONKY="true"
;;
*)
#echo ${1}
COLORDIR=${1}
;;
esac
shift
done
if [[ ! -f "$COLORDIR/.Xresources" ]]; then
echo "color dir $COLORDIR/.Xresources not found. Exiting."
print_usage
exit 1
fi
#-------------------------------------------------------------------------------------------------------------------
function set_config(){
sed -i "s/^\($1\s*=\s*\).*\$/\1$2/" "$3"
}
function set_config_conky(){
sed -i "s/^\($1\s*=\s*\).*\$/\1'$2',/" "$3"
}
function set_config_i3power(){
sed -i "s/^\($1\s*=\s*\).*\$/\1'$2'/" "$3"
}
function set_msg(){
BOLD="\e[1;34m"
COLORED="\e[1;33m"
NORMAL="\e[1;0m"
printf "${COLORED}------------------------------------------------${NORMAL}\n"
printf "${BOLD} $1${NORMAL}\n"
printf "${COLORED}------------------------------------------------${NORMAL}\n"
}
#set_msg "Backup i3."
#"$ROOT/scripts/sync-config-sh"
#[1]----------------------------------------------------------------------------------------------------------------
function termite_config(){
TERMITEFILE="$HOME/.config/termite/config"
if [[ ! -f $TERMITEFILE ]]; then
set_msg "$TERMITEFILE no found."
else
set_msg "Termite Colors scheme..."
echo "[+] copy config config-back"
cp $TERMITEFILE "$HOME/.config/termite/config-back"
set_config "background" $XCOLORBG "$TERMITEFILE"
set_config "foreground" $XCOLORFG "$TERMITEFILE"
for (( i = 0 ; i <= 15; i++ ))
do
XCOLOR=$( xrdb -query | egrep -m1 "^\*\.?color$i:" | cut -d ":" -f 2-)
set_config "color$i" $XCOLOR "$TERMITEFILE"
done
echo "[+] termite Colors Scheme genirated"
fi
}
#[2]---------------------------------------------------------------------------------------------------------------
function elokab_config(){
ELOKABFILE="$HOME/.config/elokab/elokab-terminal.conf"
if [[ ! -f $ELOKABFILE ]]; then
set_msg "$ELOKABFILE no found."
else
set_msg "Elokab-terminl Colors Scheme ..."
echo "[+] copy elokab-terminal.conf elokab-terminal.conf-back"
cp $ELOKABFILE "$HOME/.config/elokab/elokab-terminal.conf-back"
set_config "background" $XCOLORBG "$ELOKABFILE"
set_config "foreground" $XCOLORFG "$ELOKABFILE"
set_config "color0" $XCOLOR0 "$ELOKABFILE"
set_config "color1" $XCOLOR1 "$ELOKABFILE"
set_config "color2" $XCOLOR2 "$ELOKABFILE"
set_config "color3" $XCOLOR3 "$ELOKABFILE"
set_config "color4" $XCOLOR4 "$ELOKABFILE"
set_config "color5" $XCOLOR5 "$ELOKABFILE"
set_config "color6" $XCOLOR6 "$ELOKABFILE"
set_config "color7" $XCOLOR7 "$ELOKABFILE"
set_config "color8" $XCOLOR8 "$ELOKABFILE"
set_config "color9" $XCOLOR9 "$ELOKABFILE"
set_config "color10" $XCOLOR10 "$ELOKABFILE"
set_config "color11" $XCOLOR11 "$ELOKABFILE"
set_config "color12" $XCOLOR12 "$ELOKABFILE"
set_config "color13" $XCOLOR13 "$ELOKABFILE"
set_config "color14" $XCOLOR14 "$ELOKABFILE"
set_config "color15" $XCOLOR15 "$ELOKABFILE"
echo "[+] elokab-terminal Colors Scheme genirated"
fi
}
#[3---------------------------------------------------------------------------------------------------------------
function mlterm_config(){
MLTERMFILE="$HOME/.mlterm/color"
MLTERMMAINFILE="$HOME/.mlterm/main"
if [[ ! -f $MLTERMFILE ]]; then
set_msg "$MLTERMFILE no found."
else
set_msg "mlterm Colors Scheme ..."
echo "[+] copy color color-back"
cp $MLTERMFILE "$HOME/.mlterm/color-back"
echo "[+] copy main main-back"
cp $MLTERMMAINFILE "$HOME/.mlterm/main-back"
set_config "bg_color" $XCOLORBG "$MLTERMMAINFILE"
set_config "fg_color" $XCOLORFG "$MLTERMMAINFILE"
for (( i = 0 ; i <= 15; i++ ))
do
XCOLOR=$( xrdb -query | egrep -m1 "^\*\.?color$i:" | cut -d ":" -f 2-)
set_config "$i" $XCOLOR "$MLTERMFILE"
done
echo "[+] mlterm Colors Scheme genirated"
fi
}
#[3]---------------------------------------------------------------------------------------------------------------
function gtktheme_config(){
if [[ -f $THEMEFILE ]]; then
set_msg " creating gtk theme ..."
THEMNAME=$(cat "$THEMEFILE" | grep "gtk-theme-name"| cut -d "=" -f 2-)
WAllTILED=$(cat "$THEMEFILE" | grep "wallteled"| cut -d "=" -f 2-)
echo "[+] Theme name=" $THEMNAME
if [[ -f "$HOME/.gtkrc-2.0" ]]; then
echo "[+] $HOME/.gtkrc-2.0"
set_config "gtk-theme-name" "\"$THEMNAME\"" "$HOME/.gtkrc-2.0"
fi
if [[ -f "$HOME/.config/gtk-3.0/settings.ini" ]]; then
echo "[+] $HOME/.config/gtk-3.0/settings.ini"
set_config "gtk-theme-name" $THEMNAME "$HOME/.config/gtk-3.0/settings.ini"
fi
WAL="wal"
if [ "$THEMNAME" == "$WAL" ]; then
echo "[+] generating gtk theme wal..."
"$ROOT/scripts/gtk-theme/change_color.sh" -o "wal" "$COLORDIR/gtk-color"
fi
cp $HOME/.config/gtk-3.0/settings.ini $HOME/.config/gtk-3.0/settings.ini-i3
cp $HOME/.gtkrc-2.0 $HOME/.gtkrc-2.0-i3
fi
}
#[4]---------------------------------------------------------------------------------------------------------------
function iconstheme_config(){
if [[ -f $THEMEFILE ]]; then
set_msg " creating icons themes..."
ICONNAME=$(cat "$THEMEFILE" | grep "gtk-icon-theme-name"| cut -d "=" -f 2-)
WAllTILED=$(cat "$THEMEFILE" | grep "wallteled"| cut -d "=" -f 2-)
echo "[+] Icon theme=" $ICONNAME
if [[ -f "$HOME/.gtkrc-2.0" ]]; then
echo "[+] $HOME/.gtkrc-2.0"
set_config "gtk-icon-theme-name" "\"$ICONNAME\"" "$HOME/.gtkrc-2.0"
fi
if [[ -f "$HOME/.config/gtk-3.0/settings.ini" ]]; then
echo "[+] $HOME/.config/gtk-3.0/settings.ini"
set_config "gtk-icon-theme-name" $ICONNAME "$HOME/.config/gtk-3.0/settings.ini"
fi
if [[ -f "$HOME/.config/qt5ct/qt5ct.conf" ]]; then
echo "[+] $HOME/.config/qt5ct/qt5ct.conf"
set_config "icon_theme" $ICONNAME "$HOME/.config/qt5ct/qt5ct.conf"
fi
WAL="wal"
if [ "$ICONNAME" == "$WAL" ]; then
echo "[+] generating icons themes wal..."
COLORNAME=$(cat "$THEMEFILE" | grep "color-name"| cut -d "=" -f 2-)
"$ROOT/scripts/archdroid-icon-theme/change_color.sh" -o "wal" -c $COLORNAME
fi
fi
}
#[5]---------------------------------------------------------------------------------------------------------------
function tint2_config(){
#last or lastpowerline
set_msg "tint2 colors"
"$ROOT/scripts/tint2/generat-sh" -p "lastpowerline" -r
}
#[6---------------------------------------------------------------------------------------------------------------
function conky_config(){
set_msg "Conky Colors"
CONKYFILE=$HOME/.config/conky/conkyrc
set_config_conky "color1" $XCOLORFG "$CONKYFILE"
set_config_conky "color2" $XCOLOR11 "$CONKYFILE"
set_config_conky "color3" $XCOLOR12 "$CONKYFILE"
#echo "[+] color3 =" $XCOLOR3
}
#[2]---------------------------------------------------------------------------------------------------------------
function i3powerline_config(){
I3POWERFILE="$HOME/.config/i3/i3powerline.conf"
if [[ ! -f $I3POWERFILE ]]; then
set_msg "$I3POWERFILE no found."
else
set_msg "i3powerline Colors Scheme ..."
echo "[+] copy ../i3/i3powerline.conf ../i3/i3powerline.conf-back"
cp -f $I3POWERFILE "$HOME/.config/i3/i3powerline.conf-back"
set_config_i3power "backColor" $XCOLORBG "$I3POWERFILE"
set_config_i3power "forColor" $XCOLORFG "$I3POWERFILE"
set_config_i3power "greenColor" $XCOLOR2 "$I3POWERFILE"
set_config_i3power "greenColor2" $XCOLOR10 "$I3POWERFILE"
set_config_i3power "bleuColor" $XCOLOR4 "$I3POWERFILE"
set_config_i3power "bleuColor2" $XCOLOR12 "$I3POWERFILE"
set_config_i3power "magentaColor" $XCOLOR5 "$I3POWERFILE"
set_config_i3power "magentaColor2" $XCOLOR13 "$I3POWERFILE"
set_config_i3power "whiteColor" $XCOLOR7 "$I3POWERFILE"
echo "[+] i3powerline Colors Scheme genirated"
fi
}
#[2]---------------------------------------------------------------------------------------------------------------
function py3status_config(){
PY3STATUS="$HOME/.config/i3/py3status.conf"
if [[ ! -f $PY3STATUS ]]; then
set_msg "$PY3STATUS no found."
else
set_msg "py3status Colors Scheme ..."
echo "[+] copy ..i3/py3status.conf ..i3/py3status.conf-back"
cp -f $PY3STATUS "$HOME/.config/i3/py3status.conf-back"
# color_good = '#33FFBD'
# color_degraded = '#ccdc90'
# color_prebad = '#C45500'
# color_bad = '#C40000'
set_config_i3power "color_good" $XCOLOR4 "$PY3STATUS"
set_config_i3power "color_degraded" $XCOLOR3 "$PY3STATUS"
set_config_i3power "color_bad" $XCOLOR1 "$PY3STATUS"
set_config_i3power "color_color0" $XCOLOR0 "$PY3STATUS"
set_config_i3power "color_color1" $XCOLOR1 "$PY3STATUS"
set_config_i3power "color_color2" $XCOLOR2 "$PY3STATUS"
set_config_i3power "color_color3" $XCOLOR3 "$PY3STATUS"
set_config_i3power "color_color4" $XCOLOR4 "$PY3STATUS"
set_config_i3power "color_color5" $XCOLOR5 "$PY3STATUS"
set_config_i3power "color_color6" $XCOLOR6 "$PY3STATUS"
set_config_i3power "color_color7" $XCOLOR7 "$PY3STATUS"
set_config_i3power "color_color8" $XCOLOR8 "$PY3STATUS"
set_config_i3power "color_color9" $XCOLOR9 "$PY3STATUS"
set_config_i3power "color_color10" $XCOLOR10 "$PY3STATUS"
set_config_i3power "color_color11" $XCOLOR11 "$PY3STATUS"
set_config_i3power "color_color12" $XCOLOR12 "$PY3STATUS"
set_config_i3power "color_color13" $XCOLOR13 "$PY3STATUS"
set_config_i3power "color_color14" $XCOLOR14 "$PY3STATUS"
set_config_i3power "color_color15" $XCOLOR15 "$PY3STATUS"
# for (( i = 0 ; i <= 15; i++ ))
# do
# XCOLOR=$( xrdb -query | egrep -m1 "^\*\.?color$i:" | cut -d ":" -f 2-)
# set_config_i3power "color_color$i" $XCOLOR "$PY3STATUS"
# echo "[+] color_color$i =" $XCOLOR
# done
echo "[+] py3status Colors Scheme genirated"
fi
}
#-------------------------------------------------BEGIN----------------------------------------------------
#-----------------------------------------------Generating----------------------------------------------------
set_msg "Color $COLORDIR found. Generating..."
#------------------------------------------------------------------------------------------------------------------------#
# 0- XRESOURCE #
#------------------------------------------------------------------------------------------------------------------------#
set_msg "Xresource "
echo "[+] creating Xresource backup"
mv $HOME/.Xresources $HOME/.Xresources-back
sleep 1s
echo "[+] cp $COLORDIR/.Xresources $HOME/.Xresources"
cp -f "$COLORDIR/.Xresources" $HOME/
sleep 1s
echo "[+] xrdb -merge $HOME/.Xresources"
xrdb -merge $HOME/.Xresources
sleep 1s
#------------------------------------------------------------------------------------------------------------------------#
# 0-0 VARIABLES XRESOURCE #
#------------------------------------------------------------------------------------------------------------------------#
XCOLORBG=$( xrdb -query | egrep -m1 "^\*\.?background:" | cut -d ":" -f 2-)
echo "[+] background =" $XCOLORBG
XCOLORFG=$( xrdb -query | egrep -m1 "^\*\.?foreground:" | cut -d ":" -f 2-)
echo "[+] foreground =" $XCOLORFG
XCOLOR0=$( xrdb -query | egrep -m1 "^\*\.?color0:" | cut -d ":" -f 2-)
echo "[+] color0 =" $XCOLOR0
XCOLOR1=$( xrdb -query | egrep -m1 "^\*\.?color1:" | cut -d ":" -f 2-)
echo "[+] color1 =" $XCOLOR1
XCOLOR2=$( xrdb -query | egrep -m1 "^\*\.?color2:" | cut -d ":" -f 2-)
echo "[+] color2 =" $XCOLOR2
XCOLOR3=$( xrdb -query | egrep -m1 "^\*\.?color3:" | cut -d ":" -f 2-)
echo "[+] color3 =" $XCOLOR3
XCOLOR4=$( xrdb -query | egrep -m1 "^\*\.?color4:" | cut -d ":" -f 2-)
echo "[+] color4 =" $XCOLOR4
XCOLOR5=$( xrdb -query | egrep -m1 "^\*\.?color5:" | cut -d ":" -f 2-)
echo "[+] color5 =" $XCOLOR5
XCOLOR6=$( xrdb -query | egrep -m1 "^\*\.?color6:" | cut -d ":" -f 2-)
echo "[+] color6 =" $XCOLOR6
XCOLOR7=$( xrdb -query | egrep -m1 "^\*\.?color7:" | cut -d ":" -f 2-)
echo "[+] color7 =" $XCOLOR7
XCOLOR8=$( xrdb -query | egrep -m1 "^\*\.?color8:" | cut -d ":" -f 2-)
echo "[+] color8 =" $XCOLOR8
XCOLOR9=$( xrdb -query | egrep -m1 "^\*\.?color9:" | cut -d ":" -f 2-)
echo "[+] color9 =" $XCOLOR9
XCOLOR10=$( xrdb -query | egrep -m1 "^\*\.?color10:" | cut -d ":" -f 2-)
echo "[+] color10 =" $XCOLOR10
XCOLOR11=$( xrdb -query | egrep -m1 "^\*\.?color11:" | cut -d ":" -f 2-)
echo "[+] color11 =" $XCOLOR11
XCOLOR12=$( xrdb -query | egrep -m1 "^\*\.?color12:" | cut -d ":" -f 2-)
echo "[+] color12 =" $XCOLOR12
XCOLOR13=$( xrdb -query | egrep -m1 "^\*\.?color13:" | cut -d ":" -f 2-)
echo "[+] color13 =" $XCOLOR13
XCOLOR14=$( xrdb -query | egrep -m1 "^\*\.?color14:" | cut -d ":" -f 2-)
echo "[+] color14 =" $XCOLOR14
XCOLOR15=$( xrdb -query | egrep -m1 "^\*\.?color15:" | cut -d ":" -f 2-)
echo "[+] color15 =" $XCOLOR15
#------------------------------------------------------------------------------------------------------------------------#
# 1- Termite colors #
#------------------------------------------------------------------------------------------------------------------------#
if [[ -n "$SKIPTERMITE" ]];then
set_msg "skiping termite !"
else
termite_config
fi
#------------------------------------------------------------------------------------------------------------------------#
# 2- elokab-terminal colors #
#------------------------------------------------------------------------------------------------------------------------#
if [[ -n "$SKIPELOKAB" ]];then
set_msg "skiping elokab-terminal !"
else
elokab_config
fi
#------------------------------------------------------------------------------------------------------------------------#
#3- i3powerline.conf #
#------------------------------------------------------------------------------------------------------------------------#
i3powerline_config
#------------------------------------------------------------------------------------------------------------------------#
#3- py3status.conf #
#------------------------------------------------------------------------------------------------------------------------#
py3status_config
#------------------------------------------------------------------------------------------------------------------------#
#4- gtk-theme #
#------------------------------------------------------------------------------------------------------------------------#
THEMEFILE="$COLORDIR/theme"
if [[ ! -f $THEMEFILE ]]; then
#TODO : change icons colorize
set_msg "$THEMEFILE no found."
else
set_msg "$THEMEFILE found....."
echo "[+] creating backub files....gtkrc-2.0-back settings.ini-back qt5ct.conf-back"
cp "$HOME/.gtkrc-2.0" "$HOME/.gtkrc-2.0-back"
cp "$HOME/.config/gtk-3.0/settings.ini" "$HOME/.config/gtk-3.0/settings.ini-back"
cp "$HOME/.config/qt5ct/qt5ct.conf" "$HOME/.config/qt5ct/qt5ct.conf-back"
fi
#[3]Gtk-theme
if [[ -n "$SKIPGTKTHEME" ]];then
set_msg "skiping Gtk-theme !"
else
gtktheme_config
fi
#[4]Icons-theme
if [[ -n "$SKIPICONSTHEME" ]];then
set_msg "skiping Icons-theme !"
else
iconstheme_config
fi
#------------------------------------------------------------------------------------------------------------------------#
#5- TINT2 #
#------------------------------------------------------------------------------------------------------------------------#
if [[ -n "$SKIPTINT2" ]];then
set_msg "skiping tint2 !"
else
tint2_config
fi
#------------------------------------------------------------------------------------------------------------------------#
#6- Conky #
#------------------------------------------------------------------------------------------------------------------------#
if [[ -n "$SKIPCONKY" ]];then
set_msg "skiping conky !"
else
conky_config
fi
#------------------------------------------------------------------------------------------------------------------------#
#7- Wallpaper #
#------------------------------------------------------------------------------------------------------------------------#
Wallpaper="$COLORDIR/wall.jpg"
if [[ -f $Wallpaper ]]; then
set_msg "walppaper"
cp -f $Wallpaper ~/.config/
tile="true"
if [ "$WAllTILED" == "$tile" ]; then
feh --bg-tile ~/.config/wall.jpg
else
feh --bg-scale ~/.config/wall.jpg
fi
echo "[+] Walppaper Changed"
fi
#------------------------------------------------------------------------------------------------------------------------#
#8- Zathura #
#------------------------------------------------------------------------------------------------------------------------#
ZATHURA="$COLORDIR/zathurarc"
if [[ -f $ZATHURA ]]; then
set_msg "Zathura"
cp -f $ZATHURA ~/.config/zathura/
echo "[+] Zathura theme Changed"
fi
#------------------------------------------------------------------------------------------------------------------------#
# Apply #
#------------------------------------------------------------------------------------------------------------------------#
set_msg "Apply Colors..."
python2 "$ROOT/scripts/gtk_reload.py"
SESSIONNAME=$(cat "$HOME/.dmrc" | grep "Session"| cut -d "=" -f 2-)
if [ "$SESSIONNAME" == "openbox" ]; then
echo "[+] openbox --restart"
openbox --restart
else
echo "[+] i3-msg restart"
i3-msg restart
fi
set_msg "Done."
exit 0