Skip to content

Conversation

Copy link

Copilot AI commented Nov 18, 2025

Adds "OS Defaults" preset to Terminal preferences that imports GNOME Terminal color scheme from system gschema.xml.

Changes

Core Implementation

  • GnomeTerminalColorParser: Parses /usr/share/glib-2.0/schemas/org.gnome.Terminal.gschema.xml using DOM parser

    • Extracts palette (16 colors), foreground, background, selection colors
    • XXE-hardened XML processing (disabled external entities, DOCTYPE, DTD)
    • Returns Optional<GnomeTerminalColors> on success, empty on failure
  • TerminalColorPresets: Conditionally adds "OS Defaults" preset when schema available

    • Maps GNOME palette indices to TerminalColor constants (BLACK, RED, ..., BRIGHT_WHITE)
    • Preset only visible when GnomeTerminalColorParser.isAvailable() returns true

Example Usage

// Parser automatically used during TerminalColorPresets initialization
if (GnomeTerminalColorParser.isAvailable()) {
    GnomeTerminalColorParser.parse().ifPresent(gnomeColors -> {
        Preset osPreset = new Preset(TerminalMessages.TerminalColorPresets_OsDefaults);
        osPreset.set(BLACK, gnomeColors.getPalette().get(0));
        // ... map remaining colors
        presets.add(osPreset);
    });
}

Test Coverage

  • GnomeTerminalColorParserTest: 6 test cases covering valid/invalid XML, missing files, incomplete schemas, custom highlight colors

Scope: GNOME Terminal only. No dconf/user settings parsing. File read once at initialization.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.gnome.org
    • Triggering command: curl -s REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add support for parsing OS color preferences

In the Terminal preferences we currently define a color palette the user can edit wiht different Presets.

We want a new option "OS Defaults" that look for different os specific settings. and start with a file

/usr/share/glib-2.0/schemas/org.gnome.Terminal.gschema.xml

an example can be found here https://gitlab.gnome.org/GNOME/gnome-terminal/-/blob/master/src/org.gnome.Terminal.gschema.xml that defines a

with the 16 color codes for the console but also Text color, background Selection and Selcted text would be good to extract

We want to use an XML parser here (no own string parsing!) and if file is not found not show the preset.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add support for parsing OS color preferences Add OS color preferences support for GNOME Terminal Nov 18, 2025
Copilot AI requested a review from laeubi November 18, 2025 06:00
Copilot finished work on behalf of laeubi November 18, 2025 06:00
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.

2 participants