Theme applier script for gnome-terminal using dconf
Shamal Lakshan

Writing a theme applier for gnome terminal using dconf

Since Gnome-Terminal does not come with an prebuilt method to change it’s theme according to a preconfigured colo palette, many people hav found different ways to do this. The way I prefer to do this is by using a tool called dconf which is a low-level configuration system. Its main purpose is to provide a backend to GSettings on platforms that don’t already have configuration storage systems.

Usage of dconf for writing new values is really easy. The basic syntax is:

1
dconf write KEY VALUE

But, before applying the theme we should find the key of the gnome-terminal profile we need to install the color theme on. This can be done using:

1
dconf dump /org/gnome/terminal/legacy/profiles:/

This command will give you a similar output to the below image:

  • The visible name key will show the name of the profile (“Blossom” in my case.)
  • What we need for this is the key in the first line which starts with a ":"

After obtaining the key we can start writing the new values…
When writing background color, foreground color and the palette should be edited seperately.

To change the background color:

1
dconf write /org/gnome/terminal/legacy/profiles:/{PROFILE}/background-color "'{BG-COLOR}'"
  • replace {PROFILE} with your key.
  • replace {BG-COLOR} with your Background color.

The same process applies for FG-color and the palette:

1
dconf write /org/gnome/terminal/legacy/profiles:/{PROFILE}/foreground-color "'{FG-COLOR}'"

For the palette you should arrange all your colors in the palette from left to right and then again the bottom row from left to right in the same list seperating with good old commas ","

1
dconf write /org/gnome/terminal/legacy/profiles:/{PROFILE}/palette {PALETTTE}
  • replace {PROFILE} with your key.
  • replace {PALETTE} with your color palette | ex: “[‘#f46e00’,’#f70047’,’#00ff7d’,’#fcdd42’,’#26b3d2’,’#9200ff’,’#ea748f’,’#d3d7cf’,’#f5ac00’,’#ff5555’,’#55ff55’,’#ffff55’,’#729fcf’,’#ff0eff’,’#34e2e2’,’#eeeeec’]”

The "['element1','element2']" in the above example is crucial…


To ease the process I have created a bash script to automatically apply the Blossom Color Theme. That script also support using custom values for keys. You could also use that script to ease your workflow with gnome-terminal customization.