@@ -117,6 +117,11 @@ NOTE: Arguments that takes [<bool>] values, the values can be either: "true", 1,
117117 Example: `customfetch -m "${auto}OS: $<os.name>" -m "${auto}CPU: $<cpu.cpu>"`
118118 Will only print the logo (if not disabled), along side the parsed OS and CPU
119119
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+
120125 -p, --logo-position <value> Position of the logo ("top" or "left" or "bottom")
121126 -o, --offset <num> Offset between the ascii art and the layout
122127 -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
525530 int opt = 0 ;
526531 int option_index = 0 ;
527532 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:" ;
529534 static const struct option opts[] = {
530535 {" version" , no_argument, 0 , ' V' },
531536 {" help" , no_argument, 0 , ' h' },
@@ -536,6 +541,7 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
536541 {" no-color" , optional_argument, 0 , ' N' },
537542 {" ascii-logo-type" , optional_argument, 0 , ' a' },
538543 {" offset" , required_argument, 0 , ' o' },
544+ {" override" , required_argument, 0 , ' O' },
539545 {" font" , required_argument, 0 , ' f' },
540546 {" config" , required_argument, 0 , ' C' },
541547 {" layout-line" , required_argument, 0 , ' m' },
@@ -583,23 +589,25 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
583589 case " list-logos" _fnv1a16:
584590 RETURN_IF_ANDROID_APP list_logos (config); break ;
585591 case ' f' :
586- config.font = optarg; break ;
592+ config.overrides [ " gui. font" ] = {. value_type = STR, . string_value = optarg} ; break ;
587593 case ' o' :
588- config.offset = std::stoi (optarg); break ;
594+ config.overrides [ " config. offset" ] = {. value_type = INT, . int_value = std::stoi (optarg)} ; break ;
589595 case ' C' : // we have already did it in parse_config_path()
590596 break ;
591597 case ' D' :
592- config.data_dir = optarg; break ;
598+ config.overrides [ " config.data-dir " ] = {. value_type = STR, . string_value = optarg} ; break ;
593599 case ' d' :
594600 config.m_custom_distro = str_tolower (optarg); break ;
595601 case ' m' :
596602 config.m_args_layout .push_back (optarg); break ;
597603 case ' p' :
598- config.logo_position = optarg; break ;
604+ config.overrides [ " config.logo-position " ] = {. value_type = STR, . string_value = optarg} ; break ;
599605 case ' s' :
600- config.source_path = optarg; break ;
606+ config.overrides [ " config.source-path " ] = {. value_type = STR, . string_value = optarg} ; break ;
601607 case ' i' :
602608 config.m_image_backend = optarg; break ;
609+ case ' O' :
610+ config.overrideOption (optarg); break ;
603611 case ' N' :
604612 if (OPTIONAL_ARGUMENT_IS_PRESENT)
605613 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
608616 break ;
609617 case ' a' :
610618 if (OPTIONAL_ARGUMENT_IS_PRESENT)
611- config.ascii_logo_type = optarg;
619+ config.overrides [ " config.ascii-logo-type " ] = {. value_type = STR, . string_value = optarg} ;
612620 else
613- config.ascii_logo_type . clear () ;
621+ config.overrides [ " config.ascii-logo-type " ] = {. value_type = STR, . string_value = " " } ;
614622 break ;
615623 case ' n' :
616624 if (OPTIONAL_ARGUMENT_IS_PRESENT)
@@ -626,25 +634,25 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
626634 break ;
627635
628636 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 ;
630638
631639 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 ;
633641
634642 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 ;
636644
637645 case " loop-ms" _fnv1a16:
638646 config.loop_ms = std::stoul (optarg); break ;
639647
640648 case " bg-image" _fnv1a16:
641- config.gui_bg_image = optarg; break ;
649+ config.overrides [ " gui.bg-image " ] = {. value_type = STR, . string_value = optarg} ; break ;
642650
643651 case " wrap-lines" _fnv1a16:
644652 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)} ;
646654 else
647- config.wrap_lines = true ;
655+ config.overrides [ " config.wrap-lines " ] = {. value_type = BOOL, . bool_value = true } ;
648656 break ;
649657
650658 case " add-color" _fnv1a16:
@@ -658,16 +666,16 @@ static STRING_IF_ANDROID_APP_ELSE(bool) parseargs(int argc, char* argv[], Config
658666 exit (EXIT_SUCCESS);
659667
660668 case " sep-reset" _fnv1a16:
661- config.sep_reset = optarg; break ;
669+ config.overrides [ " config.sep-reset " ] = {. value_type = STR, . string_value = optarg} ; break ;
662670
663671 case " title-sep" _fnv1a16:
664- config.title_sep = optarg; break ;
672+ config.overrides [ " config.title-sep " ] = {. value_type = STR, . string_value = optarg} ; break ;
665673
666674 case " sep-reset-after" _fnv1a16:
667675 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)} ;
669677 else
670- config.sep_reset_after = true ;
678+ config.overrides [ " config.sep-reset-after " ] = {. value_type = BOOL, . bool_value = true } ;
671679 break ;
672680
673681 default :
@@ -740,19 +748,24 @@ int main(int argc, char *argv[])
740748 localize ();
741749
742750#if ANDROID_APP
743- Config config (configFile, configDir, colors, do_not_load_config );
751+ Config config (configFile, configDir);
744752 const std::string& parseargs_ret = parseargs (argc, argv, config, configFile);
745753 if (parseargs_ret != _true)
746754 return parseargs_ret;
747755
756+ if (!do_not_load_config)
757+ config.loadConfigFile (configFile, colors);
758+
748759 // since ANDROID_APP means that it will run as an android widget, so in GUI,
749760 // then let's make it always true
750761 config.gui = true ;
751762 config.wrap_lines = true ;
752763#else
753- Config config (configFile, configDir, colors, false );
764+ Config config (configFile, configDir);
754765 if (!parseargs (argc, argv, config, configFile))
755766 return 1 ;
767+
768+ config.loadConfigFile (configFile, colors);
756769#endif // ANDROID_APP
757770
758771 is_live_mode = (config.loop_ms > 50 );
0 commit comments