Fallback to gsettings for profile list when dconf is empty - #542
Fallback to gsettings for profile list when dconf is empty#542laraibg786 wants to merge 1 commit into
Conversation
Tilix ships its profile list and default profile as schema defaults, and dconf only reports values the user has set, so both read back empty until a profile is added or renamed. DEFAULT_SLUG ended up blank, the profile path collapsed to a trailing double slash and dconf rejected it. dlist_append read the list the same way and overwrote it rather than appending, dropping the existing profile from Tilix. Read through gsettings when dconf returns nothing, seed the list before adding a profile, and stop with the usual guidance if neither resolves. Closes Gogh-Co#320
|
@Mgldvd Please validate the changes and let me know if you want things to be handled differently, like for example skipping dconf and using gsettings only. BTW this solves the same bug for the tilix which still for MATE and GNOME terminals and we have a workaround documented in README to add another profile or rename existing ones. Once this gets merged and is good by you I will raise PRs for those as well and we can skip with the README workaround. Thanks. |
|
I'm not a Bash/Tilix expert, and I used AI-assisted tooling to help trace the relevant code paths and GSettings/dconf behavior. I've tried to verify the points below against the actual code and Tilix schemas, but please feel free to correct me if I've missed some project-specific context. 🤓 Thanks for the fix. The
In that case, the current fallback is skipped, but I think the two fallbacks should be handled independently, for example: if [[ -n "${GS}" ]]; then
if [[ -z "${DEFAULT_SLUG}" ]]; then
if DEFAULT_SLUG_RAW="$(
"${GS}" get com.gexperts.Tilix.ProfilesList default
)"; then
DEFAULT_SLUG="${DEFAULT_SLUG_RAW//\'/}"
fi
fi
if ! [[ ${TILIX_RES::1} =~ ^[yY]$ ]] &&
[[ -z "$("${DCONF}" read "${PROFILE_LIST_KEY}")" ]]; then
if PROFILE_LIST="$(
"${GS}" get com.gexperts.Tilix.ProfilesList list
)" && [[ -n "${PROFILE_LIST}" ]]; then
"${DCONF}" write "${PROFILE_LIST_KEY}" "${PROFILE_LIST}"
fi
fi
fi
In PROFILE_NAME="$(${DCONF} read ${PROFILE_KEY}/visible-name | tr -d \')"So for a profile whose A similar fallback could be used there: PROFILE_NAME="$(
"${DCONF}" read "${PROFILE_KEY}/visible-name" |
tr -d \'
)"
if [[ -z "${PROFILE_NAME}" ]] && [[ -n "${GS}" ]]; then
if PROFILE_NAME_RAW="$(
"${GS}" get \
"com.gexperts.Tilix.Profile:${PROFILE_KEY}/" \
visible-name
)"; then
PROFILE_NAME="${PROFILE_NAME_RAW//\'/}"
fi
fiAlternatively, for this specific Tilix color-scheme path, if preserving the profile name is the only reason to read I'd also quote the new Once these two cases are covered, I think the Tilix fallback should be in good shape. |
GNOME Terminal and MATE Terminal ship their default profile as a schema
default, and dconf only reports values the user has explicitly set --
so a never-renamed/never-customized profile reads back empty. That empty
value either gets concatenated into a dconf key with a doubled slash
("two consecutive slashes" error, #386), or -- for GNOME Terminal
specifically -- causes the modern/legacy branch selector to misroute into
the gconftool-2 branch; when gconftool-2 isn't installed (the common case
today), the read line collapses into bash's own `read` builtin being
called with a dconf path as the variable name (#351's exact crash).
Mirrors the gsettings-fallback pattern already used by the (still open)
PR #542 for the same problem in Tilix: read the default profile through
gsettings when dconf comes back empty, and fail with clear guidance
instead of a cryptic crash if neither resolves it. Also fixes GNOME
Terminal's branch selector itself to check for the modern profile schema
existing, not just for dconf having written keys under it, since that's
what caused the misrouting in the first place.
Also fixes mintty: updateMinttyConfig() only ever did a replace-only sed,
so a .minttyrc missing a given color key silently got no value written
for it. Now appends the key if it isn't already present, mirroring
apply_xfce4-terminal()'s existing create-or-append pattern.
Verified with `task test` (shellcheck --severity=error, bats, bash -n) --
all pass. Not verified against a real GNOME Terminal/MATE/mintty install,
since none are available in this environment; needs review from someone
who can test on those.
Tracked in #552 (GNOME/MATE) and #553 (mintty), referencing the original
reports in #351, #386, and #385.
The review on PR #542 (still open, unmerged) flagged that the Tilix dconf-fallback only covers the default profile pointer, not the profile list itself -- dlist_append() reads the list straight from dconf with no fallback, so on a fresh install (list empty in dconf, same as default) it silently drops the pre-existing profile instead of appending to it. Confirmed this is real, not a rare corner case: tested the actual installed org.gnome.Terminal.ProfilesList schema on this machine, plus the Tilix and MATE schemas in a disposable Docker container (never touching a live system). In a genuinely fresh install of all three, dconf read on both the profile list and the default profile comes back empty at the same time -- every time, not sometimes. Adds seed_profile_list_from_gsettings(), a small helper that seeds the dconf list key from its gsettings schema default before dlist_append() can read an empty one, and wires it into Tilix, GNOME Terminal, and MATE Terminal (Tilix had no dconf fallback of any kind yet, since #542 was never merged). Also adds the gsettings fallback for the Tilix visible-name read in appy_tilixschemes(), the second edge case from the same review. Re-verified all three in the same disposable Docker container: fresh install, empty dconf, seed_profile_list_from_gsettings() correctly populates the list from each schema default. task test passes (shellcheck, bats, bash -n).
|
Thanks again for tracking down the root cause here -- and for confirming both edge cases in the review. Went ahead and implemented the full fix directly on Verified the list-seeding actually works against the real installed schemas for all three terminals (GNOME Terminal on a real machine, Tilix and MATE Terminal in a disposable Docker container) -- confirmed a fresh install has both the profile list and the default profile empty in dconf at the same time, every time, and the fallback correctly seeds the list from gsettings before anything reads it. Closing this one since the fix is already in |
|
Reproduced (2) in a container: on a never-renamed profile visible-name is empty in On (1) mechanically confirmed, with default written and list on its schema default, It would have been more traceable for the issue if you had pushed your changes onto my branch and merged this PR, rather than committing directly to master 9bf2c6f. |
Tilix ships its profile list and default profile as schema defaults, and dconf only reports values the user has set, so both read back empty until a profile is added or renamed. The proposed solution is to read through gsettings when default dconf returns nothing, seed the list before adding a profile, and stop with the usual guidance if neither resolves.
Closes #320