-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kfrgb.sh
2367 lines (2174 loc) · 108 KB
/
kfrgb.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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# kfrgb
# Version: 0.9.11
# Author: KeyofBlueS
# Repository: https://github.com/KeyofBlueS/kfrgb
# License: GNU General Public License v3.0, https://opensource.org/licenses/GPL-3.0
function initialize_modes() {
### DO NOT EDIT THE VALUES BELOW UNTIL YOU REALLY KNOW WHAT YOU ARE DOING!!! ###
#rainbow
mode_hex_rainbow='01' # DO NOT EDIT AT ALL!
speeds_hex_rainbow='00 06 0c 12 18 1e 24 2a 30 36 3c' # DO NOT EDIT AT ALL!
speed_default_rainbow='7' # min 1, max 11, default 7
direction_default_rainbow='up' # up or down, default up
#prism
mode_hex_prism='11' # DO NOT EDIT AT ALL!
speeds_hex_prism='00 06 0c 12 18 1e 24 2a 30 36 3c' # DO NOT EDIT AT ALL!
speed_default_prism='4' # min 1, max 11, default 4
delays_hex_prism='02 03 04 05 06' # DO NOT EDIT AT ALL!
delay_default_prism='1' # min 1, max 5, default 1
#spectrum
mode_hex_spectrum='01' # DO NOT EDIT AT ALL!
speeds_hex_spectrum='00 06 0c 12 18 1e 24 2a 30 36 3c' # DO NOT EDIT AT ALL!
speed_default_spectrum='4' # min 1, max 11, default 4
delays_hex_spectrum='02 03 04' # DO NOT EDIT AT ALL!
delay_default_spectrum='3' # min 1, max 3, default 3
direction_default_spectrum='up' # up or down, default up
#slide
mode_hex_slide='05' # DO NOT EDIT AT ALL!
speeds_hex_slide='00 19 33 4c 66 7f 99 b2 cc e5 ff' # DO NOT EDIT AT ALL!
speed_default_slide='10' # min 1, max 11, default 10
delays_hex_slide='01 02 03 04' # DO NOT EDIT AT ALL!
delay_default_slide='3' # min 1, max 4, default 3
lengths_hex_slide='01 02 03 04 05 06 07 08 09 0a 0b 0c' # DO NOT EDIT AT ALL!
length_default_slide='4' # min 1, max 12, default 4
tencolors_default_slide='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_slide='0 0 0' # 3 comma/space separated values from 0 to 255
direction_default_slide='down' # up or down, default down
#wind
mode_hex_wind='05' # DO NOT EDIT AT ALL!
speeds_hex_wind='00 19 33 4c 66 7f 99 b2 cc e5 ff' # DO NOT EDIT AT ALL!
speed_default_wind='10' # min 1, max 11, default 10
delays_hex_wind='00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14' # DO NOT EDIT AT ALL!
delay_default_wind='1' # min 1, max 20, default 1
lengths_hex_wind='01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20' # DO NOT EDIT AT ALL!
length_default_wind='12' # min 1, max 32, default 12
tencolors_default_wind='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_wind='0 0 0' # 3 comma/space separated values from 0 to 255
direction_default_wind='up' # up or down, default up
#static
mode_hex_static='00' # DO NOT EDIT AT ALL!
color_default_static='255 0 0' # 3 comma/space separated values from 0 to 255
#static_byledcolor
mode_hex_static_byledcolor='10' # DO NOT EDIT AT ALL!
byledcolors_default_static_byledcolor='255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255' # 36 comma/space separated values from 0 to 255
#lightspeed
mode_hex_lightspeed='06' # DO NOT EDIT AT ALL!
speeds_hex_lightspeed='00 19 33 4c 66 7f 99 b2 cc e5 ff' # DO NOT EDIT AT ALL!
speed_default_lightspeed='9' # min 1, max 11, default 9
delays_hex_lightspeed='00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14' # DO NOT EDIT AT ALL!
delay_default_lightspeed='1' # min 1, max 20, default 1
lengths_hex_lightspeed='01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12' # DO NOT EDIT AT ALL!
length_default_lightspeed='7' # min 1, max 18, default 7
tencolors_default_lightspeed='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
direction_default_lightspeed='up' # up or down, default up
#rain
mode_hex_rain='06' # DO NOT EDIT AT ALL!
speeds_hex_rain='13 15 17 19 1b 1d 1f 21 23 25 27' # DO NOT EDIT AT ALL!
speed_default_rain='11' # min 1, max 11, default 11
tencolors_default_rain='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
direction_default_rain='down' # up or down, default down
#firework
mode_hex_firework='06' # DO NOT EDIT AT ALL!
speeds_hex_firework='30 35 3a 3f 44 49 4e 53 58 5d 62' # DO NOT EDIT AT ALL!
speed_default_firework='11' # min 1, max 11, default 11
tencolors_default_firework='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
direction_default_firework='up' # up or down, default up
#breath
mode_hex_breath='03' # DO NOT EDIT AT ALL!
speeds_hex_breath='' # DO NOT EDIT AT ALL! Need to find actual hex values set by official app.
speed_default_breath='6' # min 1, max 11, default 6
tencolors_default_breath='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 36 comma/space separated values from 0 to 255
#breath_byledcolor
mode_hex_breath_byledcolor='13' # DO NOT EDIT AT ALL!
speeds_hex_breath_byledcolor='' # DO NOT EDIT AT ALL! Need to find actual hex values set by official app.
speed_default_breath_byledcolor='6' # min 1, max 11, default 6
byledcolors_default_breath_byledcolor='255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255,255 0 0,0 255 0,0 0 255'
#dynamic
mode_hex_dynamic='04' # DO NOT EDIT AT ALL!
speeds_hex_dynamic='' # DO NOT EDIT AT ALL! Need to find actual hex values set by official app.
speed_default_dynamic='9' # min 1, max 11, default 9
tencolors_default_dynamic='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
#twilight
mode_hex_twilight='0a' # DO NOT EDIT AT ALL!
speeds_hex_twilight='00 19 33 4c 66 7f 99 b2 cc e5 ff' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_twilight='9' # min 1, max 11, default 9
#teleport
mode_hex_teleport='05' # DO NOT EDIT AT ALL!
speeds_hex_teleport='13 15 17 19 1b 1d 1f 21 23 25 27' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_teleport='10' # min 1, max 11, default 10
lengths_hex_teleport='01 02 03 04 05 06 07 08 09 0a 0b 0c' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
length_default_teleport='3' # min 1, max 12, default 3
tencolors_default_teleport='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_teleport='0 0 0' # 3 comma/space separated values from 0 to 255
direction_default_teleport='up' # up or down, default up (NOT AVAILABLE IN THE OFFICIAL APP)
#flame
mode_hex_flame='09' # DO NOT EDIT AT ALL!
speeds_hex_flame='30 35 3a 3f 44 49 4e 53 58 5d 62' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_flame='1' # min 1, max 11, default 1
direction_default_flame='up' # up or down, default up. This is a guess, need to find actual default value in the official app.
#voltage
mode_hex_voltage='07' # DO NOT EDIT AT ALL!
speeds_hex_voltage='30 35 3a 3f 44 49 4e 53 58 5d 62' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_voltage='3' # min 1, max 11, default 3
tencolors_default_voltage='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_voltage='0 0 0' # 3 comma/space separated values from 0 to 255
#countdown
mode_hex_countdown='08' # DO NOT EDIT AT ALL!
speeds_hex_countdown='13 15 17 19 1b 1d 1f 21 23 25 27' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_countdown='1' # min 1, max 11, default 1
tencolors_default_countdown='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_countdown='0 0 0' # 3 comma/space separated values from 0 to 255
direction_default_countdown='up' # up or down, default up. This is a guess, need to find actual default value in the official app.
#rhythm
mode_hex_rhythm='02' # DO NOT EDIT AT ALL!
speeds_hex_rhythm='00 06 0c 12 18 1e 24 2a 30 36 3c' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
speed_default_rhythm='11' # min 1, max 11, default 11
delays_hex_rhythm='01 02 03 04' # DO NOT EDIT AT ALL! This is a guess, need to find actual hex values set by official app.
delay_default_rhythm='2' # min 1, max 4, default 2
tencolors_default_rhythm='255 0 0,0 255 0,255 100 0,0 0 255,238 238 0,128 0 128,0 109 119,255 200 0,255 85 255,60 125 255' # 30 comma/space separated values from 0 to 255
backcolor_default_rhythm='0 0 0' # 3 comma/space separated values from 0 to 255
direction_default_rhythm='down' # up or down, default down (NOT AVAILABLE IN THE OFFICIAL APP)
#slither
mode_hex_slither='' # DO NOT EDIT AT ALL!
#common
brightness_default='80' # DO NOT EDIT AT ALL!
direction_hex_up='01' # DO NOT EDIT AT ALL!
direction_hex_down='02' # DO NOT EDIT AT ALL!
#ramslots
ramslot_one_hex='60' # DO NOT EDIT AT ALL!
ramslot_one_value_one_check_hex='48' # DO NOT EDIT AT ALL!
ramslot_one_value_two_check_hex='50' # DO NOT EDIT AT ALL!
ramslot_two_hex='61' # DO NOT EDIT AT ALL!
ramslot_two_value_one_check_hex='49' # DO NOT EDIT AT ALL!
ramslot_two_value_two_check_hex='51' # DO NOT EDIT AT ALL!
ramslot_three_hex='62' # DO NOT EDIT AT ALL!
ramslot_three_value_one_check_hex='4a' # DO NOT EDIT AT ALL!
ramslot_three_value_two_check_hex='52' # DO NOT EDIT AT ALL!
ramslot_four_hex='63' # DO NOT EDIT AT ALL!
ramslot_four_value_one_check_hex='4b' # DO NOT EDIT AT ALL!
ramslot_four_value_two_check_hex='53' # DO NOT EDIT AT ALL!
ramslot_five_hex='64' # DO NOT EDIT AT ALL!
ramslot_five_value_one_check_hex='4c' # DO NOT EDIT AT ALL!
ramslot_five_value_two_check_hex='54' # DO NOT EDIT AT ALL!
ramslot_six_hex='65' # DO NOT EDIT AT ALL!
ramslot_six_value_one_check_hex='4d' # DO NOT EDIT AT ALL!
ramslot_six_value_two_check_hex='55' # DO NOT EDIT AT ALL!
ramslot_seven_hex='66' # DO NOT EDIT AT ALL!
ramslot_seven_value_one_check_hex='4e' # DO NOT EDIT AT ALL!
ramslot_seven_value_two_check_hex='56' # DO NOT EDIT AT ALL!
ramslot_eight_hex='67' # DO NOT EDIT AT ALL!
ramslot_eight_value_one_check_hex='4f' # DO NOT EDIT AT ALL!
ramslot_eight_value_two_check_hex='57' # DO NOT EDIT AT ALL!
#ramslot_register_one_expected_hex='78' # DO NOT EDIT AT ALL!
#ramslot_register_two_expected_hex='b4' # DO NOT EDIT AT ALL!
ramslot_block_1_expected_hex='46' # DO NOT EDIT AT ALL!
ramslot_block_2_expected_hex='55' # DO NOT EDIT AT ALL!
ramslot_block_3_expected_hex='52' # DO NOT EDIT AT ALL!
ramslot_block_4_expected_hex='59' # DO NOT EDIT AT ALL!
ramslot_block_5_one_expected_hex='10' # DO NOT EDIT AT ALL!
ramslot_block_5_two_expected_hex='11' # DO NOT EDIT AT ALL!
ramslot_block_5_three_expected_hex='12' # DO NOT EDIT AT ALL!
#initialize mode
fury_begin_trnsfer='53' # DO NOT EDIT AT ALL!
fury_reg_apply='08' # DO NOT EDIT AT ALL!
set_mode_to='09' # DO NOT EDIT AT ALL!
#speed
set_speed_to='0e' # DO NOT EDIT AT ALL!
#delay
set_delay_to='0d' # DO NOT EDIT AT ALL!
#length
set_length_to='26' # DO NOT EDIT AT ALL!
#tencolors
set_tencolorsnumber_to='30' # DO NOT EDIT AT ALL!
set_tencolor_1_red_to='31' # DO NOT EDIT AT ALL!
set_tencolor_1_green_to='32' # DO NOT EDIT AT ALL!
set_tencolor_1_blue_to='33' # DO NOT EDIT AT ALL!
set_tencolor_2_red_to='34' # DO NOT EDIT AT ALL!
set_tencolor_2_green_to='35' # DO NOT EDIT AT ALL!
set_tencolor_2_blue_to='36' # DO NOT EDIT AT ALL!
set_tencolor_3_red_to='37' # DO NOT EDIT AT ALL!
set_tencolor_3_green_to='38' # DO NOT EDIT AT ALL!
set_tencolor_3_blue_to='39' # DO NOT EDIT AT ALL!
set_tencolor_4_red_to='3a' # DO NOT EDIT AT ALL!
set_tencolor_4_green_to='3b' # DO NOT EDIT AT ALL!
set_tencolor_4_blue_to='3c' # DO NOT EDIT AT ALL!
set_tencolor_5_red_to='3d' # DO NOT EDIT AT ALL!
set_tencolor_5_green_to='3e' # DO NOT EDIT AT ALL!
set_tencolor_5_blue_to='3f' # DO NOT EDIT AT ALL!
set_tencolor_6_red_to='40' # DO NOT EDIT AT ALL!
set_tencolor_6_green_to='41' # DO NOT EDIT AT ALL!
set_tencolor_6_blue_to='42' # DO NOT EDIT AT ALL!
set_tencolor_7_red_to='43' # DO NOT EDIT AT ALL!
set_tencolor_7_green_to='44' # DO NOT EDIT AT ALL!
set_tencolor_7_blue_to='45' # DO NOT EDIT AT ALL!
set_tencolor_8_red_to='46' # DO NOT EDIT AT ALL!
set_tencolor_8_green_to='47' # DO NOT EDIT AT ALL!
set_tencolor_8_blue_to='48' # DO NOT EDIT AT ALL!
set_tencolor_9_red_to='49' # DO NOT EDIT AT ALL!
set_tencolor_9_green_to='4a' # DO NOT EDIT AT ALL!
set_tencolor_9_blue_to='4b' # DO NOT EDIT AT ALL!
set_tencolor_10_red_to='4c' # DO NOT EDIT AT ALL!
set_tencolor_10_green_to='4d' # DO NOT EDIT AT ALL!
set_tencolor_10_blue_to='4e' # DO NOT EDIT AT ALL!
#backcolor
set_backcolor_red_to='23' # DO NOT EDIT AT ALL!
set_backcolor_green_to='24' # DO NOT EDIT AT ALL!
set_backcolor_blue_to='25' # DO NOT EDIT AT ALL!
#allcolor
set_allcolor_red_to='31' # DO NOT EDIT AT ALL!
set_allcolor_green_to='32' # DO NOT EDIT AT ALL!
set_allcolor_blue_to='33' # DO NOT EDIT AT ALL!
#byledcolor
set_byledcolor_1_red_to='50' # DO NOT EDIT AT ALL!
set_byledcolor_1_green_to='51' # DO NOT EDIT AT ALL!
set_byledcolor_1_blue_to='52' # DO NOT EDIT AT ALL!
set_byledcolor_2_red_to='53' # DO NOT EDIT AT ALL!
set_byledcolor_2_green_to='54' # DO NOT EDIT AT ALL!
set_byledcolor_2_blue_to='55' # DO NOT EDIT AT ALL!
set_byledcolor_3_red_to='56' # DO NOT EDIT AT ALL!
set_byledcolor_3_green_to='57' # DO NOT EDIT AT ALL!
set_byledcolor_3_blue_to='58' # DO NOT EDIT AT ALL!
set_byledcolor_4_red_to='59' # DO NOT EDIT AT ALL!
set_byledcolor_4_green_to='5a' # DO NOT EDIT AT ALL!
set_byledcolor_4_blue_to='5b' # DO NOT EDIT AT ALL!
set_byledcolor_5_red_to='5c' # DO NOT EDIT AT ALL!
set_byledcolor_5_green_to='5d' # DO NOT EDIT AT ALL!
set_byledcolor_5_blue_to='5e' # DO NOT EDIT AT ALL!
set_byledcolor_6_red_to='5f' # DO NOT EDIT AT ALL!
set_byledcolor_6_green_to='60' # DO NOT EDIT AT ALL!
set_byledcolor_6_blue_to='61' # DO NOT EDIT AT ALL!
set_byledcolor_7_red_to='62' # DO NOT EDIT AT ALL!
set_byledcolor_7_green_to='63' # DO NOT EDIT AT ALL!
set_byledcolor_7_blue_to='64' # DO NOT EDIT AT ALL!
set_byledcolor_8_red_to='65' # DO NOT EDIT AT ALL!
set_byledcolor_8_green_to='66' # DO NOT EDIT AT ALL!
set_byledcolor_8_blue_to='67' # DO NOT EDIT AT ALL!
set_byledcolor_9_red_to='68' # DO NOT EDIT AT ALL!
set_byledcolor_9_green_to='69' # DO NOT EDIT AT ALL!
set_byledcolor_9_blue_to='6a' # DO NOT EDIT AT ALL!
set_byledcolor_10_red_to='6b' # DO NOT EDIT AT ALL!
set_byledcolor_10_green_to='6c' # DO NOT EDIT AT ALL!
set_byledcolor_10_blue_to='6d' # DO NOT EDIT AT ALL!
set_byledcolor_11_red_to='6e' # DO NOT EDIT AT ALL!
set_byledcolor_11_green_to='6f' # DO NOT EDIT AT ALL!
set_byledcolor_11_blue_to='70' # DO NOT EDIT AT ALL!
set_byledcolor_12_red_to='71' # DO NOT EDIT AT ALL!
set_byledcolor_12_green_to='72' # DO NOT EDIT AT ALL!
set_byledcolor_12_blue_to='73' # DO NOT EDIT AT ALL!
#direction
set_direction_to='0c' # DO NOT EDIT AT ALL!
#brightness
set_brightness_to='20' # DO NOT EDIT AT ALL!
#finalize mode
fury_end_trnsfer='44' # DO NOT EDIT AT ALL!
}
function check_hex_values() {
hex_values="${1}"
for hex_value in ${hex_values//,/$' '}; do
if ! [[ "${hex_value}" =~ ^[0-9a-fA-F]{2}$ ]]; then
echo -e "\e[1;31m - ${hex_value} is not a valid octet hex value!\e[0m"
error_hex_values='true'
fi
done
}
function check_ramsticks() {
unset ramslot_one_go
unset ramslot_two_go
unset ramslot_three_go
unset ramslot_four_go
unset ramslot_five_go
unset ramslot_six_go
unset ramslot_seven_go
unset ramslot_eight_go
for ramstick in ${ramsticks//,/$' '}; do
if ! [[ "${ramstick}" =~ ^[[:digit:]]$ ]] || [[ "${ramstick}" -lt '1' ]] || [[ "${ramstick}" -gt '8' ]]; then
echo -e "\e[1;31m- option --ramslots: ${ramstick} not valid!\e[0m"
else
if [[ "${ramstick}" = '1' ]]; then
if [[ "${ramslot_one_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_one_hex}"
ramslot_one_go='true'
fi
elif [[ "${ramstick}" = '2' ]]; then
if [[ "${ramslot_two_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_two_hex}"
ramslot_two_go='true'
fi
elif [[ "${ramstick}" = '3' ]]; then
if [[ "${ramslot_three_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_three_hex}"
ramslot_three_go='true'
fi
elif [[ "${ramstick}" = '4' ]]; then
if [[ "${ramslot_four_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_four_hex}"
ramslot_four_go='true'
fi
elif [[ "${ramstick}" = '5' ]]; then
if [[ "${ramslot_five_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_five_hex}"
ramslot_five_go='true'
fi
elif [[ "${ramstick}" = '6' ]]; then
if [[ "${ramslot_six_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_six_hex}"
ramslot_six_go='true'
fi
elif [[ "${ramstick}" = '7' ]]; then
if [[ "${ramslot_seven_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_seven_hex}"
ramslot_seven_go='true'
fi
elif [[ "${ramstick}" = '8' ]]; then
if [[ "${ramslot_eight_go}" = 'true' ]]; then
continue
else
ramstick_hex_conf="${ramslot_eight_hex}"
ramslot_eight_go='true'
fi
fi
if [[ -z "${ramsticks_hex_conf}" ]]; then
ramsticks_hex_conf="${ramstick_hex_conf}"
else
ramsticks_hex_conf+=",${ramstick_hex_conf}"
fi
fi
done
if [[ -z "${ramsticks_hex_conf}" ]]; then
error_ramstick='true'
else
ramsticks_hex="${ramsticks_hex_conf}"
fi
}
function about_detection() {
echo "### ABOUT DETECTION ###
Setting register &0x0b to 0x04 on addresses 0x5[0-7] allows to read the DIMM model name, but
very often address 0x5 is write protected (as in my system), which makes this method useless.
${kfrgb_name} will:
- lshw: check for 'vendor: Kingston' and 'product: KF5*'.
- i2cdetect: check if addresses 0x6[0-7], 0x5[0-7] and 0x4[8-f] exist on an smbus that support Quick Command.
- i2cdump (mode i): on address 0x6[0-7] check if blocks 0x02=0x46, 0x03=0x55, 0x04=0x52, 0x05=0x59,
0x07=0x10/0x12 (for BEAST) OR =0x11 (for RENEGADE).
The detection passes if all checks are true.
The detection fails at the first error in the chain."
}
function check_ramsticks_on_smbus() {
for smbus_number_check in ${smbus_numbers}; do
risk="${risk_stored}"
unset remember_risk
smbus_functionalities="$(i2cdetect -F "${smbus_number_check}")"
if ! echo "${i2cbuses}" | grep -q "^i2c-${smbus_number_check}[[:space:]]" || [[ "$(echo "${i2cbuses}" | grep "^i2c-${smbus_number_check}[[:space:]]" | awk '{print $2}')" != 'smbus' ]] || [[ "$(echo "${smbus_functionalities}" | grep "^SMBus Quick Command" | rev | awk '{print $1}' | rev)" = 'no' ]]; then
echo
if ! echo "${i2cbuses}" | grep -q "^i2c-${smbus_number_check}[[:space:]]"; then
echo -e "\e[1;31m- bus i2c-${smbus_number_check}: not found!\e[0m"
elif [[ "$(echo "${i2cbuses}" | grep "^i2c-${smbus_number_check}[[:space:]]" | awk '{print $2}')" != 'smbus' ]]; then
echo -e "\e[1;31m- bus i2c-${smbus_number_check}: is not an SMBus!\e[0m"
elif [[ "$(echo "${smbus_functionalities}" | grep "^SMBus Quick Command" | rev | awk '{print $1}' | rev)" = 'no' ]]; then
echo -e "\e[1;31m- bus i2c-${smbus_number_check}: do not support SMBus Quick Command!\e[0m"
fi
unset smbus_number
smbus_menu='true'
else
echo
set_ramstick_hex_deployed='false'
smbus_detect="$(i2cdetect -y "${smbus_number_check}")"
if [[ "${debug}" = 'true' ]]; then
print_large_separator
echo -e "\e[1;32m- i2cdetect -y ${smbus_number_check} (check SMBus i2c-${smbus_number_check}):\e[0m"
echo "${smbus_detect}"
echo
fi
for ramstick_hex in ${ramsticks_hex//,/$' '}; do
if [[ "${ramstick_hex}" = "${ramslot_one_hex}" ]]; then
ramslot='1'
ramslot_value_one_check_hex="${ramslot_one_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_one_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_two_hex}" ]]; then
ramslot='2'
ramslot_value_one_check_hex="${ramslot_two_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_two_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_three_hex}" ]]; then
ramslot='3'
ramslot_value_one_check_hex="${ramslot_three_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_three_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_four_hex}" ]]; then
ramslot='4'
ramslot_value_one_check_hex="${ramslot_four_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_four_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_five_hex}" ]]; then
ramslot='5'
ramslot_value_one_check_hex="${ramslot_five_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_five_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_six_hex}" ]]; then
ramslot='6'
ramslot_value_one_check_hex="${ramslot_six_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_six_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_seven_hex}" ]]; then
ramslot='7'
ramslot_value_one_check_hex="${ramslot_seven_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_seven_value_two_check_hex}"
elif [[ "${ramstick_hex}" = "${ramslot_eight_hex}" ]]; then
ramslot='8'
ramslot_value_one_check_hex="${ramslot_eight_value_one_check_hex}"
ramslot_value_two_check_hex="${ramslot_eight_value_two_check_hex}"
fi
bank=$(("${ramslot}" - 1))
#unset i2cdump_registers
#unset ramslot_register_21_detected_hex
#unset ramslot_register_25_detected_hex
#unset ramslot_register_27_detected_hex
unset i2cdump_blocks
unset ramslot_block_1_detected_hex
unset ramslot_block_2_detected_hex
unset ramslot_block_3_detected_hex
unset ramslot_block_4_detected_hex
unset ramslot_block_5_detected_hex
unset ram_not_found
unset model
unset submodel
#unset detect_registers_hex_deployed
unset detect_blocks_hex_deployed
if [[ "${debug}" = 'true' ]]; then
print_small_separator
fi
#if [[ "${nowarn}" != 'true' ]] && [[ "${risk}" = 'true' ]] && [[ "${remember_risk}" != 'true' ]] && [[ "${debug}" != 'true' ]] && [[ "$(echo "${smbus_functionalities}" | grep "^I2C Block Read" | rev | awk '{print $1}' | rev)" = 'yes' ]]; then
#while true; do
#echo
#echo -e "\e[1;31m- ERROR: bus i2c-${smbus_number_check} DO SUPPORT I2C Block Read, THERE IS NO NEED TO SKIP MODEL DETECTION!\e[0m"
#echo -e "\e[1;31m- do you still want to risk and proceed to skip model detection?\e[0m"
#echo -e "\e[1;32m0) No\e[0m"
#echo -e "\e[1;31m1) Yes\e[0m"
#read -p " choose> " risk_answer
#echo
#if [[ ! "${risk_answer}" =~ ^[[:digit:]]+$ ]] || [[ "${risk_answer}" -gt '1' ]] || [[ "${risk_answer}" -lt '0' ]]; then
#echo -e "\e[1;31mInvalid choice!\e[0m"
#sleep '1'
#elif [[ "${risk_answer}" -eq '0' ]]; then
#risk='false'
#break
#elif [[ "${risk_answer}" -eq '1' ]]; then
#remember_risk='true'
#break
#fi
#done
#fi
if [[ "${risk}" = 'true' ]] && [[ "${riskforreal}" = 'false' ]] && [[ "${debug}" != 'true' ]] && [[ "$(echo "${smbus_functionalities}" | grep "^I2C Block Read" | rev | awk '{print $1}' | rev)" = 'yes' ]]; then
echo
echo -e "\e[1;31m- ERROR: bus i2c-${smbus_number_check} DO SUPPORT I2C Block Read, THERE IS NO NEED TO SKIP MODEL DETECTION!\e[0m"
echo -e "\e[1;31m MODEL DETECTION IS NOW REENABLED FOR SECURITY REASON!\e[0m"
risk='false'
echo
fi
if ! echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | grep -Eq "[ ]+vendor: Kingston" || ! echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | grep -Eq "[ ]+product: KF5" || ! echo "${smbus_detect}" | grep "^${ramstick_hex:0:1}" | awk -F':' '{print $2}'| grep -q "[ ]${ramstick_hex}[ ]" || ! echo "${smbus_detect}" | grep "^${ramslot_value_one_check_hex:0:1}" | awk -F':' '{print $2}'| grep -q "[ ]${ramslot_value_one_check_hex}[ ]" || ! echo "${smbus_detect}" | grep "^${ramslot_value_two_check_hex:0:1}" | awk -F':' '{print $2}'| grep -q "[ ]${ramslot_value_two_check_hex}[ ]"; then
echo -e "\e[1;33m- Kingston Fury DDR5 RAM in slot ${ramslot} not found on SMBus i2c-${smbus_number_check}.\e[0m"
ram_not_found='true'
debug_color='1;31'
else
if [[ "${risk}" = 'true' ]]; then
set_ramstick_hex
if [[ "${debug}" != 'true' ]]; then
echo
fi
if [[ "$(echo "${smbus_functionalities}" | grep "^I2C Block Read" | rev | awk '{print $1}' | rev)" = 'no' ]]; then
echo -e "\e[1;31m- ERROR: bus i2c-${smbus_number_check}: do not support I2C Block Read, a more precise model detection is not possible!\e[0m"
fi
model_detection_disabled_disclaimer
echo -e "\e[1;32m- A possible Kingston Fury DDR5 RAM in slot ${ramslot} found on SMBus i2c-${smbus_number_check}! \e[1;31m(Please MAKE REALLY SURE this is a Kingston Fury ${supported_submodels} DDR5 RGB!)\e[0m"
debug_color='1;32'
if [[ "${debug}" != 'true' ]]; then
echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | tail -n +2 | sed -e "s/ \+/ /g"
echo
fi
detected_submodels="${supported_submodels}"
else
#detect_registers_hex
#if [[ "${ramslot_register_21_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] && [[ "${ramslot_register_25_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] && [[ "${ramslot_register_27_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] || [[ "${ramslot_register_21_detected_hex}" = "${ramslot_register_two_expected_hex}" ]] && [[ "${ramslot_register_25_detected_hex}" = "${ramslot_register_two_expected_hex}" ]] && [[ "${ramslot_register_27_detected_hex}" = "${ramslot_register_one_expected_hex}" ]]; then
if [[ "$(echo "${smbus_functionalities}" | grep "^I2C Block Read" | rev | awk '{print $1}' | rev)" = 'no' ]]; then
if [[ "${debug}" != 'true' ]]; then
echo
fi
echo -e "\e[1;31m- ERROR: bus i2c-${smbus_number_check}: do not support I2C Block Read, a more precise model detection is not possible!\e[0m"
echo -e "\e[1;32m- A possible Kingston Fury DDR5 RAM in slot ${ramslot} found on SMBus i2c-${smbus_number_check}! \e[1;31m(Please MAKE REALLY SURE this is a Kingston Fury ${supported_submodels} DDR5 RGB!)\e[0m"
echo
else
detect_blocks_hex
if [[ "${ramslot_block_1_detected_hex}" = "${ramslot_block_1_expected_hex}" ]] && [[ "${ramslot_block_2_detected_hex}" = "${ramslot_block_2_expected_hex}" ]] && [[ "${ramslot_block_3_detected_hex}" = "${ramslot_block_3_expected_hex}" ]] && [[ "${ramslot_block_4_detected_hex}" = "${ramslot_block_4_expected_hex}" ]] && [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_two_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
if [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
submodel='BEAST'
elif [[ "${ramslot_block_5_detected_hex}" = "${ramslot_block_5_two_expected_hex}" ]]; then
submodel='RENEGADE'
fi
if [[ -z "${detected_submodels}" ]]; then
detected_submodels="${submodel}"
else
if ! echo "${detected_submodels}" | grep -q "${submodel}"; then
detected_submodels+="\${submodel}"
fi
fi
set_ramstick_hex
echo -e "\e[1;32m- Kingston Fury DDR5 RAM in slot ${ramslot} found on SMBus i2c-${smbus_number_check}! \e[1;31m(Please MAKE REALLY SURE this is a Kingston Fury ${submodel} DDR5 RGB!)\e[0m"
debug_color='1;32'
if [[ "${debug}" != 'true' ]]; then
echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | tail -n +2 | sed -e "s/ \+/ /g"
fi
else
echo -e "\e[1;31m- RAM in slot ${ramslot} on SMBus i2c-${smbus_number_check} doesn't seems to be a Kingston Fury ${supported_submodels} DDR5!\e[0m"
debug_color='1;31'
fi
fi
#else
#echo -e "\e[1;31m- RAM in slot ${ramslot} on SMBus i2c-${smbus_number_check} doesn't seems to be a Kingston Fury ${supported_submodels} DDR5!\e[0m"
#debug_color='1;31'
#fi
fi
fi
check_hex_values "${ramstick_hex} ${ramslot_value_one_check_hex} ${ramslot_value_two_check_hex} ${ramslot_value_expected_hex}"
if [[ "${debug}" = 'true' ]]; then
print_debug_info
fi
done
if [[ "${set_ramstick_hex_deployed}" = 'true' ]]; then
if [[ -z "${smbus_numbers_check}" ]]; then
smbus_numbers_check="${smbus_number_check}"
else
smbus_numbers_check+=" ${smbus_number_check}"
fi
fi
fi
done
if [[ "$(echo ${smbus_numbers_check} | wc -w)" -eq '0' ]]; then
smbus_menu='true'
elif [[ "$(echo ${smbus_numbers_check} | wc -w)" -gt '1' ]]; then
exit_one
fi
}
#function detect_registers_hex() {
#detect_registers_hex_deployed='true'
#i2cdump_registers="$(i2cdump -y "${smbus_number_check}" "0x${ramslot_value_one_check_hex}" b)"
#current_ram="$(echo "${i2cdump_registers}" | grep "^20:")"
#ramslot_register_21_detected_hex="$(echo "${current_ram}" | awk '{print $3}')"
#ramslot_register_25_detected_hex="$(echo "${current_ram}" | awk '{print $7}')"
#ramslot_register_27_detected_hex="$(echo "${current_ram}" | awk '{print $9}')"
#}
function detect_blocks_hex() {
detect_blocks_hex_deployed='true'
detection='true'
if [[ ! "${wait}" =~ ^[[:digit:]]+(.[[:digit:]]+)?$ ]]; then
wait='0.015'
fi
i2cdump_detect_blocks
if [[ "${ramslot_block_1_detected_hex}" != "${ramslot_block_1_expected_hex}" ]] || [[ "${ramslot_block_2_detected_hex}" != "${ramslot_block_2_expected_hex}" ]] || [[ "${ramslot_block_3_detected_hex}" != "${ramslot_block_3_expected_hex}" ]] || [[ "${ramslot_block_4_detected_hex}" != "${ramslot_block_4_expected_hex}" ]] || ! [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_two_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
if [[ "${ram_not_found}" != 'true' ]]; then
sleep "${wait}"
i2cset_retry -y "${smbus_number_check}" "0x${ramstick_hex}" "0x${fury_reg_apply}" "0x${fury_begin_trnsfer}"
i2cdump_detect_blocks
i2cset_retry -y "${smbus_number_check}" "0x${ramstick_hex}" "0x${fury_reg_apply}" "0x${fury_end_trnsfer}"
sleep "${wait}"
fi
fi
unset detection
}
function i2cdump_detect_blocks() {
sleep "${wait}"
i2cdump_blocks="$(i2cdump -y "${smbus_number_check}" "0x${ramstick_hex}" i 2>/dev/null)"
sleep "${wait}"
current_ram="$(echo "${i2cdump_blocks}" | grep "^00:")"
ramslot_block_1_detected_hex="$(echo "${current_ram}" | awk '{print $4}')"
ramslot_block_2_detected_hex="$(echo "${current_ram}" | awk '{print $5}')"
ramslot_block_3_detected_hex="$(echo "${current_ram}" | awk '{print $6}')"
ramslot_block_4_detected_hex="$(echo "${current_ram}" | awk '{print $7}')"
ramslot_block_5_detected_hex="$(echo "${current_ram}" | awk '{print $9}')"
}
function print_debug_info() {
if ! echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | grep -Eq "[ ]+vendor: Kingston" || ! echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1 | grep -Eq "[ ]+product: KF5"; then
debug_lshw_color='1;31'
else
debug_lshw_color='1;32'
fi
echo
echo -e "\e[${debug_lshw_color}m * lshw (check bank ${bank}):\e[0m"
echo "${lshw}" | sed -n -e "/*-bank:${bank}/,/*/p" | head -n -1
echo
if echo "${smbus_detect}" | grep "^${ramstick_hex:0:1}" | awk -F':' '{print $2}' | grep -q "[ ]${ramstick_hex}[ ]"; then
echo -e "\e[1;32m * Address 0x${ramstick_hex} found in SMBus i2c-${smbus_number_check}\e[0m"
else
echo -e "\e[1;31m * Address 0x${ramstick_hex} not found in SMBus i2c-${smbus_number_check}\e[0m"
fi
if echo "${smbus_detect}" | grep "^${ramslot_value_one_check_hex:0:1}" | awk -F':' '{print $2}' | grep -q "[ ]${ramslot_value_one_check_hex}[ ]"; then
echo -e "\e[1;32m * Address 0x${ramslot_value_one_check_hex} found in SMBus i2c-${smbus_number_check}\e[0m"
else
echo -e "\e[1;31m * Address 0x${ramslot_value_one_check_hex} not found in SMBus i2c-${smbus_number_check}\e[0m"
fi
if echo "${smbus_detect}" | grep "^${ramslot_value_two_check_hex:0:1}" | awk -F':' '{print $2}' | grep -q "[ ]${ramslot_value_two_check_hex}[ ]"; then
echo -e "\e[1;32m * Address 0x${ramslot_value_two_check_hex} found in SMBus i2c-${smbus_number_check}\e[0m"
else
echo -e "\e[1;31m * Address 0x${ramslot_value_two_check_hex} not found in SMBus i2c-${smbus_number_check}\e[0m"
fi
#if [[ "${detect_registers_hex_deployed}" != 'true' ]]; then
#detect_registers_hex
#debug_color='1;31'
#fi
#if [[ "${ramslot_register_21_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] && [[ "${ramslot_register_25_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] && [[ "${ramslot_register_27_detected_hex}" = "${ramslot_register_one_expected_hex}" ]] || [[ "${ramslot_register_21_detected_hex}" = "${ramslot_register_two_expected_hex}" ]] && [[ "${ramslot_register_25_detected_hex}" = "${ramslot_register_two_expected_hex}" ]] && [[ "${ramslot_register_27_detected_hex}" = "${ramslot_register_one_expected_hex}" ]]; then
#debug_registers_color='1;32'
#else
#debug_registers_color='1;31'
#fi
#echo -e "\e[${debug_registers_color}m * i2cdump ${smbus_number_check} 0x${ramslot_value_one_check_hex} b (check registers 0x21, 0x25, 0x27):\e[0m"
#if [[ -n "${i2cdump_registers}" ]]; then
#echo "${i2cdump_registers}"
#fi
#if [[ "${ramslot_register_21_detected_hex}" =~ ^("${ramslot_register_one_expected_hex}"|"${ramslot_register_two_expected_hex}")$ ]]; then
#debug_register_21_color='1;32'
#else
#debug_register_21_color='1;31'
#fi
#if [[ "${ramslot_register_25_detected_hex}" =~ ^("${ramslot_register_one_expected_hex}"|"${ramslot_register_two_expected_hex}")$ ]]; then
#debug_register_25_color='1;32'
#else
#debug_register_25_color='1;31'
#fi
#if [[ "${ramslot_register_27_detected_hex}" = "${ramslot_register_one_expected_hex}" ]]; then
#debug_register_27_color='1;32'
#else
#debug_register_27_color='1;31'
#fi
#echo -e "\e[${debug_register_21_color}m * register 0x21: \e[m0x${ramslot_register_21_detected_hex} \e[${debug_register_21_color}m(expected 0x${ramslot_register_one_expected_hex} or 0x${ramslot_register_two_expected_hex})\e[0m"
#echo -e "\e[${debug_register_25_color}m * register 0x25: \e[m0x${ramslot_register_25_detected_hex} \e[${debug_register_21_color}m(expected 0x${ramslot_register_one_expected_hex} or 0x${ramslot_register_two_expected_hex})\e[0m"
#echo -e "\e[${debug_register_27_color}m * register 0x27: \e[m0x${ramslot_register_27_detected_hex} \e[${debug_register_21_color}m(expected 0x${ramslot_register_one_expected_hex})\e[0m"
echo
if [[ "${risk}" = 'true' ]]; then
echo -e "\e[1;31m- WARNING: MODEL DETECTION IS DISABLED!\e[0m"
echo
fi
if [[ "${detect_blocks_hex_deployed}" != 'true' ]] && [[ "$(echo "${smbus_functionalities}" | grep "^I2C Block Read" | rev | awk '{print $1}' | rev)" = 'yes' ]]; then
detect_blocks_hex
debug_color='1;31'
fi
if [[ "${ramslot_block_1_detected_hex}" = "${ramslot_block_1_expected_hex}" ]] && [[ "${ramslot_block_2_detected_hex}" = "${ramslot_block_2_expected_hex}" ]] && [[ "${ramslot_block_3_detected_hex}" = "${ramslot_block_3_expected_hex}" ]] && [[ "${ramslot_block_4_detected_hex}" = "${ramslot_block_4_expected_hex}" ]] && [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_two_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
debug_blocks_color='1;32'
else
debug_blocks_color='1;31'
fi
#echo
echo -e "\e[${debug_blocks_color}m * i2cdump ${smbus_number_check} 0x${ramstick_hex} i (check blocks 0x02, 0x03, 0x04, 0x05, 0x07):\e[0m"
if [[ -n "${i2cdump_blocks}" ]]; then
echo "${i2cdump_blocks}"
fi
if [[ "${ramslot_block_1_detected_hex}" = "${ramslot_block_1_expected_hex}" ]]; then
debug_model_1_color='1;32'
else
debug_model_1_color='1;31'
fi
if [[ "${ramslot_block_2_detected_hex}" = "${ramslot_block_2_expected_hex}" ]]; then
debug_model_2_color='1;32'
else
debug_model_2_color='1;31'
fi
if [[ "${ramslot_block_3_detected_hex}" = "${ramslot_block_3_expected_hex}" ]]; then
debug_model_3_color='1;32'
else
debug_model_3_color='1;31'
fi
if [[ "${ramslot_block_4_detected_hex}" = "${ramslot_block_4_expected_hex}" ]]; then
debug_model_4_color='1;32'
else
debug_model_4_color='1;31'
fi
if [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_two_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
if [[ "${ramslot_block_5_detected_hex}" =~ ^("${ramslot_block_5_one_expected_hex}"|"${ramslot_block_5_three_expected_hex}")$ ]]; then
submodel='BEAST'
elif [[ "${ramslot_block_5_detected_hex}" = "${ramslot_block_5_two_expected_hex}" ]]; then
submodel='RENEGADE'
fi
debug_model_5_color='1;32'
else
debug_model_5_color='1;31'
fi
echo -e "\e[${debug_model_1_color}m * block 0x02: \e[m0x${ramslot_block_1_detected_hex} \e[${debug_model_1_color}m(expected 0x${ramslot_block_1_expected_hex})\e[0m"
echo -e "\e[${debug_model_2_color}m * block 0x03: \e[m0x${ramslot_block_2_detected_hex} \e[${debug_model_2_color}m(expected 0x${ramslot_block_2_expected_hex})\e[0m"
echo -e "\e[${debug_model_3_color}m * block 0x04: \e[m0x${ramslot_block_3_detected_hex} \e[${debug_model_3_color}m(expected 0x${ramslot_block_3_expected_hex})\e[0m"
echo -e "\e[${debug_model_4_color}m * block 0x05: \e[m0x${ramslot_block_4_detected_hex} \e[${debug_model_4_color}m(expected 0x${ramslot_block_4_expected_hex})\e[0m"
echo -e "\e[${debug_model_5_color}m * block 0x07: \e[m0x${ramslot_block_5_detected_hex} \e[${debug_model_5_color}m(expected 0x${ramslot_block_5_one_expected_hex}/0x${ramslot_block_5_three_expected_hex} for BEAST or 0x${ramslot_block_5_two_expected_hex} for RENEGADE)\e[0m"
echo
if [[ -n "${ramslot_block_1_detected_hex}" ]] && [[ -n "${ramslot_block_2_detected_hex}" ]] && [[ -n "${ramslot_block_3_detected_hex}" ]] && [[ -n "${ramslot_block_4_detected_hex}" ]] && [[ -n "${ramslot_block_5_detected_hex}" ]]; then
model="$(printf "\x${ramslot_block_1_detected_hex}\x${ramslot_block_2_detected_hex}\x${ramslot_block_3_detected_hex}\x${ramslot_block_4_detected_hex} ${submodel}")"
echo -e "\e[${debug_color}m * model: ${model}\e[0m"
else
echo -e "\e[${debug_color}m * model: UNKNOWN\e[0m"
fi
echo
}
function set_ramstick_hex() {
set_ramstick_hex_deployed='true'
if [[ -z "${ramsticks_hex_check}" ]]; then
ramsticks_hex_check="${ramstick_hex}"
else
ramsticks_hex_check+=" ${ramstick_hex}"
fi
if [[ -z "${ram_slots}" ]]; then
ram_slots="${ramslot}"
else
ram_slots+=" - ${ramslot}"
fi
}
function find_smbus() {
find_smbus_deployed='true'
unset n
unset smbus_numbers
while IFS= read -r smbus; do
if [[ "$(echo "${smbus}" | grep -E "^i2c-[[:digit:]]+" | awk '{print $2}')" = 'smbus' ]]; then
n="$(echo "${smbus}" | awk '{print $1}' | awk -F'i2c-' '{print $2}')"
if [[ "${n}" -le '9' ]]; then
sp1=" "
else
sp1=""
fi
if [[ -z "${smbuses}" ]]; then
smbuses="${sp1}${n}) ${smbus}"
else
smbuses+="\n${sp1}${n}) ${smbus}"
fi
if [[ -z "${smbus_numbers}" ]]; then
smbus_numbers="${n}"
else
smbus_numbers+=" ${n}"
fi
fi
done <<< "${i2cbuses}"
smbus_numbers_all="${smbus_numbers}"
if [[ -z "${n}" ]]; then
echo -e "\e[1;31mNo SMBus found!\e[0m"
exit_one
fi
}
function select_smbus() {
if [[ "${find_smbus_deployed}" != 'true' ]]; then
find_smbus
fi
echo
echo -e "\e[1;32m- Please select an SMBus (or type 'quit' or 'q' to exit from ${kfrgb_name}):\e[0m"
echo -e "${smbuses}" | grep -E "[ ]?[ ]i2c-(${smbus_numbers_check//' '/$'|'})"
while true; do
read -p " choose> " smbus_numbers
if [[ "${smbus_numbers,,}" =~ ^(quit|q)$ ]]; then
exit_zero
elif [[ ! "${smbus_numbers}" =~ ^[[:digit:]]+$ ]]; then
echo -e "\e[1;31mInvalid choice!\e[0m"
sleep '1'
else
unset smbus_number_selected
for smbus_number_select in ${smbus_numbers_all} ; do
if [[ "${smbus_number_select}" = "${smbus_numbers}" ]]; then
smbus_number_selected='true'
fi
done
if [[ "${smbus_number_selected}" = 'true' ]]; then
break
else
echo -e "\e[1;31mInvalid choice!\e[0m"
sleep '1'
fi
fi
done
}
function list_modes() {
local i=0
echo
echo -e "\e[1;32m- Please select a mode:\e[0m"
echo -e "\e[1;32m 0) exit\e[0m"
for exp_mode in ${supported_modes} off; do
i=$((i + 1))
if [ ${i} -le 9 ]; then
sp1=" "
else
sp1=""
fi
echo "${sp1}${i}) ${exp_mode}"
done
while true; do
read -rp " choose> " selected_mode
if [[ ! "${selected_mode}" =~ ^[[:digit:]]+$ ]] || [[ "${selected_mode}" =~ ^0[[:digit:]]+$ ]] || [[ "${selected_mode}" -gt "${i}" ]]; then
echo -e "\e[1;31mInvalid choice!\e[0m"
sleep '1'
else
break
fi
done
if [[ "${selected_mode}" -eq '0' ]]; then
exit_zero
elif [[ "${selected_mode}" -eq "${i}" ]]; then
mode='static'
color='0,0,0'
brightness='0'
unset randomcolor
else
mode="$(echo "${supported_modes}" | awk "{print $"${selected_mode}"}")"
fi
}
function check_mode() {
current_modes="${@}"
unset mode_check
for current_mode in ${current_modes}; do
if [[ "${current_mode}" = "${mode}" ]]; then
mode_check='true'
break
fi
done
if [[ "${mode_check}" = 'true' ]]; then
return 0
else
return 1
fi
}
function check_parameters() {
while true; do
if [[ "${values_for}" = '--tencolors' ]] || [[ "${values_for}" = '--backcolor' ]] || [[ "${values_for}" = '--color' ]] || [[ "${values_for}" = '--byledcolors' ]]; then
if [[ "${randomcolor}" = 'true' ]]; then
set_random_colors
parameters_check="${selected_colors}"
fi
fi
if [[ -z "${parameters_check}" ]] || [[ "${error_values}" = 'true' ]]; then
if [[ "${ask}" = 'true' ]]; then
if [[ "${values_for}" = '--tencolors' ]] || [[ "${values_for}" = '--backcolor' ]] || [[ "${values_for}" = '--color' ]] || [[ "${values_for}" = '--byledcolors' ]]; then
if [[ "${randomcolor}" != 'true' ]]; then
set_colors
fi
parameters_check="${selected_colors}"
elif [[ "${values_for}" = '--speed' ]] || [[ "${values_for}" = '--delay' ]] || [[ "${values_for}" = '--length' ]] || [[ "${values_for}" = '--tencolorsnumber' ]] || [[ "${values_for}" = '--brightness' ]]; then
set_parameters
parameters_check="${selected_parameter}"
fi
else
parameters_check="${parameters_check_default}"
fi
fi
values="${parameters_check}"
check_values
if [[ "${error_values}" = 'true' ]]; then
if [[ "${parameters_check}" = "${parameters_check_default}" ]]; then
echo -e "\e[1;31m Invalid ${values_for} ${parameters_check_default} default values!\e[0m"
echo -e "\e[1;31m Please check the ${values_for} default values for mode ${mode} inside ${kfrgb_name}\e[0m"
ask='true'
fi
else
ask="${ask_stored}"
break
fi
done
}
function set_colors() {
echo
echo -e "\e[1;32m- Please choose a color for option ${values_for} (leave empty for default ${parameters_check_default}):\e[0m"
while true; do
echo -e "\e[0;32m1) Choose a color\e[0m"
echo -e "\e[0;32m2) Set a random color\e[0m"
read -p " choose> " set_color_answer
if [[ -z "${set_color_answer}" ]]; then
selected_colors="${parameters_check_default}"
break
else
if [[ ! "${set_color_answer}" =~ ^[[:digit:]]+$ ]] || [[ "${set_color_answer}" -gt '2' ]] || [[ "${set_color_answer}" -lt '1' ]]; then
echo -e "\e[1;31mInvalid choice!\e[0m"
echo
sleep '1'
elif [[ "${set_color_answer}" -eq '1' ]]; then
set_yad_colors
break
elif [[ "${set_color_answer}" -eq '2' ]]; then
set_random_colors
break
fi
fi
done
}
function set_yad_colors() {
unset selected_colors
color_number='1'
echo
echo -e "\e[0;32m- Please select color for option ${values_for}:\e[0m"
while true; do
while true; do
color="$(yad --color --gtk-palette --init-color=#ff0000 --title='Color selection' --text="Mode: ${mode}; Please select color ${color_number}/$((${max_values} / 3)) for option ${values_for}:" --button=OK --center)"
if [[ -n "${color}" ]]; then
selected_color="$((16#${color:1:2})),$((16#${color:3:2})),$((16#${color:5:2}))"
break
else
exit_zero
fi
done
selected_color_hex="$(printf '%02x' ${selected_color//,/$' '})"
perl -e ' foreach $a(@ARGV){print "[ \e[48:2::".join(":",unpack("C*",pack("H*",$a)))."m \e[49m ]"};print ""' "${selected_color_hex}"
if [[ -z "${selected_colors}" ]]; then
selected_colors="${selected_color}"
else
selected_colors+=",${selected_color}"
fi
if [[ "$(echo ${selected_colors//,/$' '} | wc -w)" -eq "${max_values}" ]]; then
break
elif [[ "$(echo ${selected_colors//,/$' '} | wc -w)" -gt "${max_values}" ]]; then
exit_one
fi
color_number="$(("${color_number}" + 1))"
done
echo
}
function set_random_colors() {
unset random_colors
while true; do
if [[ "$(echo ${random_colors//,/$' '} | wc -w)" -eq "${max_values}" ]]; then
selected_colors="${random_colors}"
break
elif [[ "$(echo ${random_colors//,/$' '} | wc -w)" -gt "${max_values}" ]]; then
exit_one
fi
random_color_count='0'
unset random_color
while true; do
random_value="$(echo $(( $RANDOM % 255)))"
if [[ -z "${random_color}" ]]; then
random_color="${random_value}"
else
random_color+=" ${random_value}"
fi
random_color_count="$(("${random_color_count}" + 1))"
if [[ "${random_color_count}" = '3' ]]; then
if [[ "${random_color}" = '0 0 0' ]] || echo "${random_colors}" | grep -q "${random_color}"; then