Skip to content

Fallback to gsettings for profile list when dconf is empty - #542

Closed
laraibg786 wants to merge 1 commit into
Gogh-Co:masterfrom
laraibg786:fix-tilix-profile-lookup
Closed

Fallback to gsettings for profile list when dconf is empty#542
laraibg786 wants to merge 1 commit into
Gogh-Co:masterfrom
laraibg786:fix-tilix-profile-lookup

Conversation

@laraibg786

Copy link
Copy Markdown
Contributor

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

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
@laraibg786

Copy link
Copy Markdown
Contributor Author

@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.

@Mgldvd

Mgldvd commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

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 dconfgsettings fallback makes sense, but I think there are still two edge cases worth addressing before merging.

  1. ProfilesList.list is only recovered inside the [[ -z "${DEFAULT_SLUG}" ]] branch.

default and list are independent settings, so it is possible for default to already have an explicit value in dconf while list is still using the GSettings schema default.

In that case, the current fallback is skipped, but dlist_append() later rebuilds the profile list from the raw dconf value. If that value is empty, the existing schema-default profile can still be dropped from the resulting list.

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
  1. visible-name has the same distinction between raw dconf values and effective GSettings values.

In appy_tilixschemes() it is still read only from dconf:

PROFILE_NAME="$(${DCONF} read ${PROFILE_KEY}/visible-name | tr -d \')"

So for a profile whose visible-name has never been explicitly written to dconf, PROFILE_NAME may be empty even though GSettings provides an effective schema-default value.

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
fi

Alternatively, for this specific Tilix color-scheme path, if preserving the profile name is the only reason to read visible-name, it may be cleaner to avoid rewriting visible-name at all. I would not remove that behavior from set_theme() globally, though, since other callers use it when creating/naming profiles.

I'd also quote the new "${DCONF}" and "${GS}" command invocations while touching this code.

Once these two cases are covered, I think the Tilix fallback should be in good shape.

Mgldvd added a commit that referenced this pull request Sep 6, 2026
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.
Mgldvd added a commit that referenced this pull request Sep 7, 2026
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).
@Mgldvd

Mgldvd commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

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 master (9bf2c6f), covering both cases from the review: the profile-list fallback (not just the default profile pointer) and the visible-name fallback in appy_tilixschemes(). Also extended the same fix to GNOME Terminal and MATE Terminal, since they hit the identical dconf-schema-default gap (tracked separately in #351/#386, now closed via #552).

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. task test (shellcheck, bats, bash -n) passes on the result.

Closing this one since the fix is already in master, but really appreciate the diagnosis -- it's what pointed at the second edge case in the first place.

@Mgldvd Mgldvd closed this Sep 7, 2026
@laraibg786
laraibg786 deleted the fix-tilix-profile-lookup branch September 7, 2026 05:35
@laraibg786

Copy link
Copy Markdown
Contributor Author

Reproduced (2) in a container: on a never-renamed profile visible-name is empty in dconf, set_theme writes it straight back, and the name gets blanked. Worth noting this is a regression my patch introduced rather than a pre-existing bug, before the fallback, every dconf write on that path failed with "error: dconf key must not contain two consecutive slashes" (14 of them, same failure as #386), so the name only survived because the whole color-scheme path silently did nothing.

On (1) mechanically confirmed, with default written and list on its schema default, dlist_append drops the existing profile. I couldn't find a path where Tilix itself produces that split state, so it needs a manual dconf write or a partial config restore. But the structural point holds either way: the real defect is that dlist_append reads the list from dconf with no fallback, and gating that on DEFAULT_SLUG being empty coupled two unrelated conditions. Decoupling them is the right call.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to Apply Themes in Tilix

2 participants