Tango
dconf write /org/gnome/terminal/legacy/profiles:/$profile/palette "['rgb(0,0,0)', 'rgb(204,0,0)', 'rgb(78,154,6)', 'rgb(196,160,0)', 'rgb(52,101,164)', 'rgb(117,80,123)', 'rgb(6,152,154)', 'rgb(211,215,207)', 'rgb(85,87,83)', 'rgb(239,41,41)', 'rgb(138,226,52)', 'rgb(252,233,79)', 'rgb(114,159,207)', 'rgb(173,127,168)', 'rgb(52,226,226)', 'rgb(238,238,236)']"
Linux console
dconf write /org/gnome/terminal/legacy/profiles:/$profile/palette "['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,170,170)', 'rgb(170,170,170)', 'rgb(85,85,85)', 'rgb(255,85,85)', 'rgb(85,255,85)', 'rgb(255,255,85)', 'rgb(85,85,255)', 'rgb(255,85,255)', 'rgb(85,255,255)', 'rgb(255,255,255)']"
XTerm
dconf write /org/gnome/terminal/legacy/profiles:/$profile/palette "['rgb(0,0,0)', 'rgb(205,0,0)', 'rgb(0,205,0)', 'rgb(205,205,0)', 'rgb(30,144,255)', 'rgb(205,0,205)', 'rgb(0,205,205)', 'rgb(229,229,229)', 'rgb(76,76,76)', 'rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(255,255,0)', 'rgb(70,130,180)', 'rgb(255,0,255)', 'rgb(0,255,255)', 'rgb(255,255,255)']"
Rxvt
dconf write /org/gnome/terminal/legacy/profiles:/$profile/palette "['rgb(0,0,0)', 'rgb(205,0,0)', 'rgb(0,205,0)', 'rgb(205,205,0)', 'rgb(0,0,205)', 'rgb(205,0,205)', 'rgb(0,205,205)', 'rgb(250,235,215)', 'rgb(64,64,64)', 'rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(255,255,0)', 'rgb(0,0,255)', 'rgb(255,0,255)', 'rgb(0,255,255)', 'rgb(255,255,255)']"
Default
(same as Tango but with different palette color 1 -- dark grey instead of black)
dconf write /org/gnome/terminal/legacy/profiles:/$profile/palette "['rgb(46,52,54)', 'rgb(204,0,0)', 'rgb(78,154,6)', 'rgb(196,160,0)', 'rgb(52,101,164)', 'rgb(117,80,123)', 'rgb(6,152,154)', 'rgb(211,215,207)', 'rgb(85,87,83)', 'rgb(239,41,41)', 'rgb(138,226,52)', 'rgb(252,233,79)', 'rgb(114,159,207)', 'rgb(173,127,168)', 'rgb(52,226,226)', 'rgb(238,238,236)']"
or
dconf reset /org/gnome/terminal/legacy/profiles:/$profile/palette
Best Answer
The question was modified in comments: How to get the background color? For this, the command
xtermcontrol --get-bg
can be used.This particular command relies on the terminal emulator supporting the OSC 11 escape sequence, which usually goes together with OSC 12 (foreground;
xtermcontrol --get-fg
), OSC 4 (palette colors;xtermcontrol --get-color0
..--get-color15
) and a few others. Some popular terminal emulators implement these, some other popular ones don't, so these commands don't work everywhere. The VTE widget, and hence in turn VTE-based terminal emulators such asgnome-terminal
do support these.These escape sequences are quite tricky when they are used for querying the colors rather than setting them: The response is injected by the terminal emulator exactly as if it came from the keyboard, that is, as if the user typed it.
xtermcontrol
reads this input and then prints as output, hiding this technical detail. (And if you really wish to, you can foolxtermcontrol
to report a wrong answer by manually typing one from the keyboard, haha.)Back to the original question:
There is no way to query the current profile in gnome-terminal. Why?
Reading
gsettings
ordconf
cannot work for two reasons:They contain the static configuration (settings) of gnome-terminal, not runtime information. Even if they contained runtime information, they'd have to contain the information for all the open gnome-terminal windows and tabs, each of which might be using a separate profile. And then somehow we'd still need to be able to identify which one to look for.
They can only work locally, not across e.g. a
su
orssh
.gnome-terminal could initialize an environment variable when a window or tab is opened, but there's no way to update it subsequently if the profile is changed. (See also the discussion about
$COLORFGBG
at https://bugzilla.gnome.org/show_bug.cgi?id=733423.)It could report the current profile as a response to some escape sequence, as if the user typed it from the keyboard (similarly to the aforementioned OSC 4, 10, 11). However, there's no standard for this, and it would even have security implications (see https://bugzilla.gnome.org/show_bug.cgi?id=151260), plus presumably no support in the
xtermcontrol
utility for many years to come (heck it doesn't even support 256 colors yet).