feat: decouple window and column dimensions in config - #692
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cboxdoerfer
reviewed
Jun 12, 2026
| }; | ||
|
|
||
| static const char *config_file_name = "fsearch.conf"; | ||
| static const char *cache_file_name = "window.conf"; |
Owner
There was a problem hiding this comment.
In case other state options will be added in the future, I think it makes more sense to name the file something like state.ini. .ini also seems more suitable for a state file than .conf.
cboxdoerfer
reviewed
Jun 12, 2026
| g_assert(cache_key_file); | ||
|
|
||
| gchar cache_path[PATH_MAX] = ""; | ||
| config_build_cache_path(cache_path, sizeof(cache_path)); |
Owner
There was a problem hiding this comment.
On systems with GLIB >= 2.72 there's also support for g_get_user_state_dir (), which we should prefer over g_get_user_cache(). So we should try to load in the following order:
- user state dir
- user cache dir
- user config dir
cboxdoerfer
reviewed
Jun 12, 2026
| CONF_STR(sort_by, "Name"), | ||
| }; | ||
|
|
||
| static const FsearchKeyData CACHE_WINDOW_SECTION[] = { |
Owner
There was a problem hiding this comment.
Let's use STATE instead of CACHE throughout this PR.
cboxdoerfer
reviewed
Jun 12, 2026
|
|
||
| CONFIG_SAVE_SECTION(cache_key_file, "Window", CACHE_WINDOW_SECTION, config); | ||
|
|
||
| if (config_make_cache_dir()) { |
Owner
There was a problem hiding this comment.
Here we should also prefer to use the g_get_user_state_dir() if our GLIB_VERSION supports it, and only use cache and config dirs as fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stores volatile window/column geometry in a separate file under the XDG cache directory (
~/.cache/fsearch/window.conf) instead of mixing it into the main settings file (~/.config/fsearch/fsearch.conf).Why this matters (#659)
Users who version-control their dotfiles get noisy git diffs every time they resize the window or a column, because FSearch writes machine-specific geometry into the same file as substantive settings. Other apps (e.g. KeePassXC, cited in the issue) keep essential settings in
~/.configand volatile layout state in~/.cache. The maintainer greenlit this direction ("That's a great idea. Added to the TODO list.").Changes
CACHE_WINDOW_SECTION:window_width,window_height, and the six*_column_widthand five*_column_poskeys.restore_window_size,restore_column_config,restore_sort_order, theshow_*_columnbooleans,sort_by, andsort_ascendingstay in the main config file, since those are deliberate user choices rather than machine-specific geometry.config_build_cache_path()/config_build_cache_dir()/config_make_cache_dir()helpers that mirror the existing config-path helpers but are rooted atg_get_user_cache_dir().config_save()writes the geometry to a second GKeyFile under[Window]in the cache file. The main settings save is unaffected by a cache-write failure.config_load()reads geometry fromwindow.conf. If that file is absent, it falls back to reading legacy geometry keys from the[Interface]section offsearch.conf, so existing users keep their layout on first launch after upgrading (one-time migration; the next save relocates it to the cache file).config_load_default()applies the geometry defaults.Testing
Added
src/tests/test_config.c(registered insrc/tests/meson.build) covering:fsearch.confcontains nowindow_width/*_column_widthkeys whilewindow.confdoes, and geometry values round-trip through a reload.fsearch.confwith legacy[Interface]geometry and nowindow.confloads those values, and a subsequent save relocates them to the cache file.fsearch.conf, then loads back correctly.All three tests pass locally (built and run against glib-2.0).
Fixes #659
AI was used for assistance.