config: add 'cache' option
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This allows users to define a default cache location in fuzzel.ini. It's mostly useful to disable caching, by setting it to /dev/null. Closes #219
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 04f9729 · Browse files · 6 files·+26 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+26 added−9 removed
- other:+26 added−9 removed
Provenance
- Commit
035532e- Tree
0693f80- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
04f9729
6 files changed+26 added−9 removed
modified:doc/fuzzel.ini.5.scd+5 added
290 unmodified lines291 When there are more matches than this, switch from immediate292 refiltering to delayed refiltering (see293 *delayed-filter-ms*). Default: _20000_.294 295+*cache*296+ Specify the default cache location. If unset,297+ *$XDG_CACHE_HOME/fuzzel* will be used. Set to */dev/null* to298+ disable caching. Default: _not set_.299+300 # SECTION: colors301 302 All color values are in RGBA.303 216 unmodified linesmodified:CHANGELOG.md+3 added-2 removed
43 unmodified lines44 (i.e. use the bundled version).45 * Mouse support. Left click selects/launches, right click quits46 fuzzel, wheel scrolls (a page at at time). This is, for the time47 being, not configurable ([#131][131])48-* `--cache=PATH` command line option, allowing a custom cache location49- to be used ([#189][189], [#219][219]).48+* `--cache=PATH` command line option, and `cache` option to49+ `fuzzel.ini`, allowing a custom cache location to be used50+ ([#189][189], [#219][219]).51 * `expunge` key binding, to remove an entry from the cache. Mapped to52 shift+delete by default.53 * `--prompt-color` and `colors.prompt`, controlling the54 text/foreground color of the prompt ([#365][365]).740 unmodified linesmodified:config.c+6 added-1 removed
944 unmodified lines945 return true;946 }947 else if (strcmp(key, "x-margin") == 0)948 return value_to_uint32(ctx, 10, &conf->margin.x);949- 949+950 else if (strcmp(key, "y-margin") == 0)951 return value_to_uint32(ctx, 10, &conf->margin.y);952 953 else if (strcmp(key, "lines") == 0)49 unmodified lines1003 1004 else if (strcmp(key, "exit-on-keyboard-focus-loss") == 0)1005 return value_to_bool(ctx, &conf->exit_on_kb_focus_loss);1006 1007+ else if (strcmp(key, "cache") == 0)1008+ return value_to_str(ctx, &conf->cache_path);1009+1010 else1011 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);1012 1013 return false;644 unmodified lines1658 .letter_spacing = {0},1659 .layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,1660 .exit_on_kb_focus_loss = true,1661 .list_executables_in_path = false,1662+ .cache_path = NULL,1663 };1664 1665 add_default_key_bindings(conf);1666 61 unmodified lines1728 free(conf->terminal);1729 free(conf->launch_prefix);1730 free(conf->font);1731 free(conf->icon_theme);1732+ free(conf->cache_path);1733 free_key_binding_list(&conf->key_bindings);1734 }1735 1736 struct rgba9 unmodified linesmodified:config.h+1 added
192 unmodified lines193 enum zwlr_layer_shell_v1_layer layer;194 bool exit_on_kb_focus_loss;195 196 bool list_executables_in_path;197+ char *cache_path;198 };199 200 typedef tll(char *) config_override_t;201 6 unmodified linesmodified:fuzzel.ini+4 added-2 removed
31 unmodified lines32 33 # line-height=<use font metrics>34 # letter-spacing=035 36-# layer = overlay37-# exit-on-keyboard-focus-loss = yes36+# layer=overlay37+# exit-on-keyboard-focus-loss=yes38 39+# cache=<not set>40+41 # render-workers=<number of logical CPUs>42 # match-workers=<number of logical CPUs>43 44 [colors]68 unmodified linesmodified:main.c+7 added-4 removed
795 unmodified lines796 };797 798 bool check_config = false;799 const char *config_path = NULL;800- const char *cache_path = NULL;800 enum log_class log_level = LOG_CLASS_WARNING;801 enum log_colorize log_colorize = LOG_COLORIZE_AUTO;802 bool log_syslog = true;803 const char *select = NULL;80 unmodified lines884 check_config = true;885 break;886 887 case OPT_CACHE:889- cache_path = optarg;888+ cmdline_overrides.conf.cache_path = optarg;889 break;890 891 case 'o':892 cmdline_overrides.conf.output = optarg;854 unmodified lines1747 if (cmdline_overrides.delayed_filter_ms_set)1748 conf.delayed_filter_ms = cmdline_overrides.conf.delayed_filter_ms;1749 if (cmdline_overrides.delayed_filter_limit_set)1750 conf.delayed_filter_limit = cmdline_overrides.conf.delayed_filter_limit;1751+ if (cmdline_overrides.conf.cache_path != NULL) {1752+ free(conf.cache_path);1753+ conf.cache_path = strdup(cmdline_overrides.conf.cache_path);1754+ }1755 1756 if (conf.dmenu.enabled) {1757 /* We don't have any meta data in dmenu mode */1758 conf.match_fields = MATCH_NAME;87 unmodified lines1846 }1847 1848 struct context ctx = {1849 .conf = &conf,1847- .cache_path = cache_path,1850+ .cache_path = conf.cache_path,1851 .render = render,1852 .matches = matches,1853 .apps = apps,1854 .themes = &themes,41 unmodified lines1896 break;1897 }1898 1899 if (wayl_update_cache(wayl))1897- write_cache(cache_path, apps, conf.dmenu.enabled);1900+ write_cache(conf.cache_path, apps, conf.dmenu.enabled);1901 1902 ret = wayl_exit_code(wayl);1903 1904 out:57 unmodified lines