Change color scheme for xfce4 terminal manually

XFCE4 terminal stores user preferences in $XDG_CONFIG_HOME/xfce4/terminal/terminalrc (typically, ~/.config/xfce4/terminal/terminalrc - might not exist if you haven't changed any preferences). I found that XFCE4 Terminal watches this file and reloads settings when it changes, so you can write to this file to change settings.

However, there is no single entry you can edit to change the colours. The various palettes are actually a set of settings. For example:

$ cat /usr/share/xfce4/terminal/colorschemes/solarized-dark.theme 
[Scheme]
Name=Solarized (dark)
Name[bg]=Златисто (тъмно)
Name[fr]=Solarisé (foncé)
Name[nl]=Overbelicht (donker)
Name[th]=ในแสงแดด (มืด)
Name[uk]=Золотистий (темний)
ColorForeground=#839496
ColorBackground=#002b36
ColorCursor=#93a1a1
TabActivityColor=#dc322f
ColorPalette=#073642;#dc322f;#859900;#b58900;#268bd2;#d33682;#2aa198;#eee8d5;#002b36;#cb4b16;#586e75;#657b83;#839496;#6c71c4;#93a1a1;#fdf6e3
ColorBold=#93a1a1
ColorBoldUseDefault=FALSE

And terminalrc will look like:

$ cat .config/xfce4/terminal/terminalrc                           
[Configuration]
ColorForeground=#839496
FontName=Ubuntu Mono 12
ColorBackground=#002b36
ColorCursor=#93a1a1
ColorBold=#93a1a1
ColorBoldUseDefault=FALSE
ColorPalette=#073642;#dc322f;#859900;#b58900;#268bd2;#d33682;#2aa198;#eee8d5;#002b36;#cb4b16;#586e75;#657b83;#839496;#6c71c4;#93a1a1;#fdf6e3
TabActivityColor=#dc322f
TabActivityColor=#dc322f

As can be seen, there's no way to easily identify which palette the colours came from.

Scripting this doesn't seem safe, but here's an inefficient attempt:

#! /bin/bash
if ! [[ -f /usr/share/xfce4/terminal/colorschemes/$1.theme ]]
then
    echo "No such colorscheme: $1"
    exit 1
fi
cd ~/.config/xfce4/terminal
# strip settings from any themes
grep -Fxvf <(cat /usr/share/xfce4/terminal/colorschemes/*.theme) terminalrc > .terminalrc.tmp
grep -v -e Name -e Scheme "/usr/share/xfce4/terminal/colorschemes/$1.theme" >> .terminalrc.tmp
cp terminalrc terminalrc.bak
mv .terminalrc.tmp terminalrc

Copy this to somewhere in your PATH (for example, ~/bin/xfce-color-switch). Then:

$ xfce4-color-switch dark-pastels

enter image description here

$ xfce4-color-switch solarized   
No such colorscheme: solarized
$ xfce4-color-switch solarized-dark

enter image description here

You'll have to remember colorscheme names for this, but I'll add instructions on how to add tab-completion once I figure them out.


A better approach would be: create your own color scheme and allow yourself to choose one across many.

To do that, create the directory:

mkdir -p ~/.local/share/xfce4/terminal/colorschemes

And place files like that inside:

[Scheme]
Name=my good profile
ColorForeground=#4ccd4ccd4ccd
ColorBackground=#f851f465ebe7
TabActivityColor=#d8d8a9a97f7f
ColorCursor=#f0f0b6b66666
ColorSelection=#16163b3b5959
ColorPalette=rgb(0,0,0);rgb(170,0,0);rgb(0,170,0);rgb(170,85,0);rgb(0,0,170);rgb(170,0,170);rgb(0,138,138);rgb(170,170,170);rgb(85,85,85);rgb(255,85,85);rgb(85,255,85);rgb(196,160,0);rgb(85,85,255);rgb(255,85,255);rgb(68,204,204);rgb(255,255,255)

If you have an already configured terminalrc file in your ~/.config/xfce4/terminal directory, you can just copy the appropriate lines.

After doing so, your new color scheme appears inside the main list. So you can, for example, have both a custom white color theme, and a custom black.