@@ -117,6 +117,11 @@ NOTE: Arguments that takes [<bool>] values, the values can be either: "true", 1,
117
117
Example: `customfetch -m "${auto}OS: $<os.name>" -m "${auto}CPU: $<cpu.cpu>"`
118
118
Will only print the logo (if not disabled), along side the parsed OS and CPU
119
119
120
+ -O, --override <string> Overrides a config value, but NOT arrays.
121
+ Syntax must be "name=value" E.g "auto.disk.fmt='Disk(%1): %6'".
122
+ For convinience purpose, names that doesn't have a dot for telling the table, will automatically be considered under the [config] table
123
+ E.g "sep-reset-after=true" works as "config.sep-reset-after=true"
124
+
120
125
-p, --logo-position <value> Position of the logo ("top" or "left" or "bottom")
121
126
-o, --offset <num> Offset between the ascii art and the layout
122
127
-l, --list-modules Print the list of the info tag modules and its members
@@ -525,7 +530,7 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
525
530
int opt = 0 ;
526
531
int option_index = 0 ;
527
532
opterr = 1 ; // re-enable since before we disabled for "invalid option" error
528
- const char *optstring = " -VhwnLlNa::f:o:C:i:d:D:p:s:m:" ;
533
+ const char *optstring = " -VhwnLlNa::f:o:C:O: i:d:D:p:s:m:" ;
529
534
static const struct option opts[] = {
530
535
{" version" , no_argument, 0 , ' V' },
531
536
{" help" , no_argument, 0 , ' h' },
@@ -536,6 +541,7 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
536
541
{" no-color" , optional_argument, 0 , ' N' },
537
542
{" ascii-logo-type" , optional_argument, 0 , ' a' },
538
543
{" offset" , required_argument, 0 , ' o' },
544
+ {" override" , required_argument, 0 , ' O' },
539
545
{" font" , required_argument, 0 , ' f' },
540
546
{" config" , required_argument, 0 , ' C' },
541
547
{" layout-line" , required_argument, 0 , ' m' },
@@ -583,23 +589,25 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
583
589
case " list-logos" _fnv1a16:
584
590
RETURN_IF_ANDROID_APP list_logos (config); break ;
585
591
case ' f' :
586
- config.font = optarg; break ;
592
+ config.overrides [ " gui. font" ] = {. value_type = STR, . string_value = optarg} ; break ;
587
593
case ' o' :
588
- config.offset = std::stoi (optarg); break ;
594
+ config.overrides [ " config. offset" ] = {. value_type = INT, . int_value = std::stoi (optarg)} ; break ;
589
595
case ' C' : // we have already did it in parse_config_path()
590
596
break ;
591
597
case ' D' :
592
- config.data_dir = optarg; break ;
598
+ config.overrides [ " config.data-dir " ] = {. value_type = STR, . string_value = optarg} ; break ;
593
599
case ' d' :
594
600
config.m_custom_distro = str_tolower (optarg); break ;
595
601
case ' m' :
596
602
config.m_args_layout .push_back (optarg); break ;
597
603
case ' p' :
598
- config.logo_position = optarg; break ;
604
+ config.overrides [ " config.logo-position " ] = {. value_type = STR, . string_value = optarg} ; break ;
599
605
case ' s' :
600
- config.source_path = optarg; break ;
606
+ config.overrides [ " config.source-path " ] = {. value_type = STR, . string_value = optarg} ; break ;
601
607
case ' i' :
602
608
config.m_image_backend = optarg; break ;
609
+ case ' O' :
610
+ config.overrideOption (optarg); break ;
603
611
case ' N' :
604
612
if (OPTIONAL_ARGUMENT_IS_PRESENT)
605
613
config.m_disable_colors = str_to_bool (optarg);
@@ -608,9 +616,9 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
608
616
break ;
609
617
case ' a' :
610
618
if (OPTIONAL_ARGUMENT_IS_PRESENT)
611
- config.ascii_logo_type = optarg;
619
+ config.overrides [ " config.ascii-logo-type " ] = {. value_type = STR, . string_value = optarg} ;
612
620
else
613
- config.ascii_logo_type . clear () ;
621
+ config.overrides [ " config.ascii-logo-type " ] = {. value_type = STR, . string_value = " " } ;
614
622
break ;
615
623
case ' n' :
616
624
if (OPTIONAL_ARGUMENT_IS_PRESENT)
@@ -626,25 +634,25 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
626
634
break ;
627
635
628
636
case " logo-padding-top" _fnv1a16:
629
- config.logo_padding_top = std::stoi (optarg); break ;
637
+ config.overrides [ " config.logo-padding-top " ] = {. value_type = INT, . int_value = std::stoi (optarg)} ; break ;
630
638
631
639
case " logo-padding-left" _fnv1a16:
632
- config.logo_padding_left = std::stoi (optarg); break ;
640
+ config.overrides [ " config.logo-padding-left " ] = {. value_type = INT, . int_value = std::stoi (optarg)} ; break ;
633
641
634
642
case " layout-padding-top" _fnv1a16:
635
- config.layout_padding_top = std::stoi (optarg); break ;
643
+ config.overrides [ " config.layout-padding-top " ] = {. value_type = INT, . int_value = std::stoi (optarg)} ; break ;
636
644
637
645
case " loop-ms" _fnv1a16:
638
646
config.loop_ms = std::stoul (optarg); break ;
639
647
640
648
case " bg-image" _fnv1a16:
641
- config.gui_bg_image = optarg; break ;
649
+ config.overrides [ " gui.bg-image " ] = {. value_type = STR, . string_value = optarg} ; break ;
642
650
643
651
case " wrap-lines" _fnv1a16:
644
652
if (OPTIONAL_ARGUMENT_IS_PRESENT)
645
- config.wrap_lines = str_to_bool (optarg);
653
+ config.overrides [ " config.wrap-lines " ] = {. value_type = BOOL, . bool_value = str_to_bool (optarg)} ;
646
654
else
647
- config.wrap_lines = true ;
655
+ config.overrides [ " config.wrap-lines " ] = {. value_type = BOOL, . bool_value = true } ;
648
656
break ;
649
657
650
658
case " add-color" _fnv1a16:
@@ -658,16 +666,16 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
658
666
exit (EXIT_SUCCESS);
659
667
660
668
case " sep-reset" _fnv1a16:
661
- config.sep_reset = optarg; break ;
669
+ config.overrides [ " config.sep-reset " ] = {. value_type = STR, . string_value = optarg} ; break ;
662
670
663
671
case " title-sep" _fnv1a16:
664
- config.title_sep = optarg; break ;
672
+ config.overrides [ " config.title-sep " ] = {. value_type = STR, . string_value = optarg} ; break ;
665
673
666
674
case " sep-reset-after" _fnv1a16:
667
675
if (OPTIONAL_ARGUMENT_IS_PRESENT)
668
- config.sep_reset_after = str_to_bool (optarg);
676
+ config.overrides [ " config.sep-reset-after " ] = {. value_type = BOOL, . bool_value = str_to_bool (optarg)} ;
669
677
else
670
- config.sep_reset_after = true ;
678
+ config.overrides [ " config.sep-reset-after " ] = {. value_type = BOOL, . bool_value = true } ;
671
679
break ;
672
680
673
681
default :
@@ -740,19 +748,24 @@ int main(int argc, char *argv[])
740
748
localize ();
741
749
742
750
#if ANDROID_APP
743
- Config config (configFile, configDir, colors, do_not_load_config );
751
+ Config config (configFile, configDir);
744
752
const std::string& parseargs_ret = parseargs (argc, argv, config, configFile);
745
753
if (parseargs_ret != _true)
746
754
return parseargs_ret;
747
755
756
+ if (!do_not_load_config)
757
+ config.loadConfigFile (configFile, colors);
758
+
748
759
// since ANDROID_APP means that it will run as an android widget, so in GUI,
749
760
// then let's make it always true
750
761
config.gui = true ;
751
762
config.wrap_lines = true ;
752
763
#else
753
- Config config (configFile, configDir, colors, false );
764
+ Config config (configFile, configDir);
754
765
if (!parseargs (argc, argv, config, configFile))
755
766
return 1 ;
767
+
768
+ config.loadConfigFile (configFile, colors);
756
769
#endif // ANDROID_APP
757
770
758
771
is_live_mode = (config.loop_ms > 50 );
0 commit comments