main: add --override=[section.]key=value command line option
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This implements the same generic configuration override as foot uses, letting you override _any_ configuration option, e.g. --override prompt="custom prompt: " While fuzzel has custom command line options for _most_ configuration options, not *all* configuration options can be set from the command line. With this patch, all configuration options can be set from the command line. Closes #759
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 1bc67d9 · Browse files · 5 files·+33 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+33 added−1 removed
- other:+33 added−1 removed
Provenance
- Commit
5df0df2- Tree
3e26198- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
1bc67d9
5 files changed+33 added−1 removed
modified:completions/fish/fuzzel.fish+1 added
9 unmodified lines10 11 complete -c fuzzel -f12 complete -c fuzzel -r -s c -l config -d "path to configuration file (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)"13 complete -c fuzzel -r -l cache -d "file to load most recently launched applications from (XDG_CACHE_HOME/fuzzel)"14+complete -c fuzzel -x -l override -d "configuration option to override, in form SECTION.KEY=VALUE"15 complete -c fuzzel -x -s n -l namespace -d "layer shell surface namespace (launcher)"16 complete -c fuzzel -l check-config -d "verify configuration and exit with 0 if ok, otherwise exit with 1"17 complete -c fuzzel -x -s f -l font -a "(fc-list : family | sed 's/,/\n/g' | sort | uniq)" -d "font name and style in fontconfig format (monospace)"18 complete -c fuzzel -l use-bold -d "allow fuzzel to use bold fonts"81 unmodified linesmodified:completions/zsh/_fuzzel+1 added
2 unmodified lines3 _arguments \4 -s \5 '--config[path to configuration file (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)]:config:_files' \6 '--cache[file to load most recently launched applications from (XDG_CACHE_HOME/fuzzel)]:cache:_files' \7+ '--override=[configuration option to override, in form SECTION.KEY=VALUE]:()' \8 '(-n --namespace)'{-n,--namespace}'[layer shell surface namespace (launcher)]:()' \9 '--check-config[verify configuration and exit with 0 if ok, otherwise exit with 1]' \10 '(-v --version)'{-v,--version}'[show the version number and quit]' \11 '(-h --help)'{-h,--help}'[show help message and quit]' \98 unmodified linesmodified:doc/fuzzel.1.scd+14 added
44 unmodified lines45 Set to /dev/null to disable caching.46 47 Default: _XDG_CACHE_HOME/fuzzel_48 49+*--override*=[_SECTION_.]_KEY_=_VALUE_50+51+ Override an option set in the configuration file. If _SECTION_ is52+ not given, defaults to _main_.53+ 54+ Explicit command line options always override both the on-disk55+ configuration, and any *--override* used. For example:56+57+ ```58+ fuzzel --prompt hello --override prompt=world59+ ```60+61+ Here, the prompt will be set to _hello_.62+63 *-o*,*--output*=_OUTPUT_64 Specifies the monitor to display the window on. Autocompletion is available65 for zsh and fish, or you can list the available outputs with *wlr-randr* or66 with Sway using *swaymsg -t get_outputs*.618 unmodified linesmodified:CHANGELOG.md+7 added
33 unmodified lines34 35 36 ## Unreleased37 ### Added38+39+* `--override` command line option, allowing you to override **all**40+ options available in `fuzzel.ini` ([#759][759]).41+42+[759]: https://codeberg.org/dnkl/fuzzel/issues/75943+44+45 ### Changed46 ### Deprecated47 ### Removed48 ### Fixed1158 unmodified linesmodified:main.c+10 added-1 removed
345 unmodified lines346 " --check-config verify configuration, exit with 0 if ok,\n"347 " otherwise exit with 1\n"348 " --cache=PATH load most recently launched applications from\n"349 " PATH (XDG_CACHE_HOME/fuzzel)\n"350+ " --override=[section.].key=VALUE override configuration value\n"351 " -n,--namespace=NAMESPACE layer shell surface namespace\n"352 " -o,--output=OUTPUT output (monitor) to display on (none)\n"353 " -f,--font=FONT font name and style, in FontConfig format\n"354 " (monospace)\n"513 unmodified lines868 #define OPT_DMENU_ONLY_MATCH 310869 #define OPT_DMENU_MESSAGE 311870 #define OPT_DMENU_MESSAGE_MODE 312871 #define OPT_MESSAGE_COLOR 313872+ #define OPT_GENERIC_OVERRIDE 314873 874 static const struct option longopts[] = {875 {"config", required_argument, 0, OPT_CONFIG},876 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},78 unmodified lines955 {"mesg", required_argument, 0, OPT_DMENU_MESSAGE},956 {"mesg-mode", required_argument, 0, OPT_DMENU_MESSAGE_MODE},957 958 /* Misc */959+ {"override", required_argument, 0, OPT_GENERIC_OVERRIDE},960 {"log-level", required_argument, 0, OPT_LOG_LEVEL},961 {"log-colorize", optional_argument, 0, OPT_LOG_COLORIZE},962 {"log-no-syslog", no_argument, 0, OPT_LOG_NO_SYSLOG},963 {"version", no_argument, 0, 'v'},8 unmodified lines972 enum log_colorize log_colorize = LOG_COLORIZE_AUTO;973 bool log_syslog = true;974 const char *select = NULL;975 size_t select_idx = 0;976+ config_override_t generic_overrides = tll_init();977 978 struct {979 struct config conf;980 1002 unmodified lines1983 cmdline_overrides.conf.enable_mouse = false;1984 cmdline_overrides.no_mouse_set = true;1985 break;1986 1987+ case OPT_GENERIC_OVERRIDE:1988+ tll_push_back(generic_overrides, strdup(optarg));1989+ break;1990+1991 case 'v':1992 printf("fuzzel %s\n", version_and_features());1993 return EXIT_SUCCESS;1994 28 unmodified lines2023 return ret;2024 }2025 2026 struct config conf = {0};2019- bool conf_successful = config_load(&conf, config_path, NULL, check_config);2027+ bool conf_successful = config_load(&conf, config_path, &generic_overrides, check_config);2028+ tll_free_and_free(generic_overrides, free);2029 if (!conf_successful) {2030 config_free(&conf);2031 config_free(&cmdline_overrides.conf);2032 return ret;431 unmodified lines