Skip to content
Myr

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

5 files+33 added−1 removed

modified:completions/fish/fuzzel.fish+1 added
9 unmodified lines
1011complete -c fuzzel -f12complete -c fuzzel -r -s c -l config -d "path to configuration file (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)"13complete -c fuzzel -r -l cache -d "file to load most recently launched applications from (XDG_CACHE_HOME/fuzzel)"14complete -c fuzzel -x -l override -d "configuration option to override, in form SECTION.KEY=VALUE"15complete -c fuzzel -x -s n -l namespace -d "layer shell surface namespace (launcher)"16complete -c fuzzel -l check-config -d "verify configuration and exit with 0 if ok, otherwise exit with 1"17complete -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)"18complete -c fuzzel -l use-bold -d "allow fuzzel to use bold fonts"
81 unmodified lines
modified:completions/zsh/_fuzzel+1 added
2 unmodified lines
3_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 lines
modified:doc/fuzzel.1.scd+14 added
44 unmodified lines
45 Set to /dev/null to disable caching.4647 Default: _XDG_CACHE_HOME/fuzzel_4849*--override*=[_SECTION_.]_KEY_=_VALUE_5051 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:5657 ```58 fuzzel --prompt hello --override prompt=world59 ```6061 Here, the prompt will be set to _hello_.6263*-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 lines
modified:CHANGELOG.md+7 added
33 unmodified lines
343536## Unreleased37### Added3839* `--override` command line option, allowing you to override **all**40 options available in `fuzzel.ini` ([#759][759]).4142[759]: https://codeberg.org/dnkl/fuzzel/issues/759434445### Changed46### Deprecated47### Removed48### Fixed
1158 unmodified lines
modified:main.c+10 added-1 removed
345 unmodified lines
346 " --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 lines
868 #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 314873874 static const struct option longopts[] = {875 {"config", required_argument, 0, OPT_CONFIG},876 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},
78 unmodified lines
955 {"mesg", required_argument, 0, OPT_DMENU_MESSAGE},956 {"mesg-mode", required_argument, 0, OPT_DMENU_MESSAGE_MODE},957958 /* 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 lines
972 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();977978 struct {979 struct config conf;980
1002 unmodified lines
1983 cmdline_overrides.conf.enable_mouse = false;1984 cmdline_overrides.no_mouse_set = true;1985 break;19861987 case OPT_GENERIC_OVERRIDE:1988 tll_push_back(generic_overrides, strdup(optarg));1989 break;19901991 case 'v':1992 printf("fuzzel %s\n", version_and_features());1993 return EXIT_SUCCESS;1994
28 unmodified lines
2023 return ret;2024 }20252026 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