8

I am using Ubuntu 14.04 and I want to set the background color of my gnome-terminal using the command line.
From what I can tell gconftool-2 is the way to do this but I cant work out what the command is to do this.

my ~/.gconf/apps directory looks like:

├── %gconf.xml
├── gnome-terminal
│   ├── %gconf.xml
│   └── profiles
│       ├── Default
│       │   └── %gconf.xml
│       └── %gconf.xml
└── nm-applet
    └── %gconf.xml 

If I run

gconftool-2 -a /apps/gnome-terminal/profiles/Default

I get a long list of key value pairs, e.g. pairs like this

scroll_on_output = false
 cursor_blink_mode = system
 background_color = #28F528F528F5

which I believe belong to the "default" gnome-terminal profile, but how do I then set these values using gconftool-2 ?

Ive worked out I can "get" values with

gconftool-2 --get /apps/gnome-terminal/profiles/Default/background_color

but not sure how to assign a new variable, in this case I would guess its a string, e.g. I would expect it to be something like

gconftool-2 --set /apps/gnome-terminal/profiles/Default/background_color --type=string: #ababab

or something like that?

2 Answers2

6

Apparently gconftool-2 does not work anymore, however dconf did work for me. Close gnome-terminal and run this in xterm or another terminal emulator, or even tty.

Step 1: find the id of your desired profile

dconf dump /org/gnome/terminal/legacy/profiles:/ | awk '/\[:/||/visible-name=/'

My output:

[:732eb8b6-054a-446e-b89b-707f3331b62a]
visible-name='G-O'
[:b1dcc9dd-5262-4d8d-a863-c897e6d979b9]
visible-name='BLACK-GRAY'
[:950cf000-d979-4981-bbdd-65441138c782]
visible-name='B-W'
[:6390ed2d-5768-4650-b4c8-dc1ef4f5da1a]
visible-name='IBM'
[:868caf45-6db6-4427-81f0-d6fa28ef1c3e]
visible-name='gray-green'
[:1960ff5e-ffe6-48c3-8f7c-b771245d62ae]
visible-name='cathode'
[:9176f39d-9b41-4e64-87d9-ea388e3b873d]
visible-name='B-O'
[:98707df3-b227-4a01-ae76-310f8270b9bd]
visible-name='Default'
[:4038ffeb-a484-4c39-aead-9c45f4032f27]
visible-name='PRINT'
[:67607036-706f-4872-bd7d-a3eabf321460]
visible-name='B-G'

So my Default profile has id :98707df3-b227-4a01-ae76-310f8270b9bd

Step 2: allow for using custom colors instead of system colors

sudo dconf write /org/gnome/terminal/legacy/profiles:/:98707df3-b227-4a01-ae76-310f8270b9bd/use-theme-colors "false"

Step 3: set your desired background color

sudo dconf write /org/gnome/terminal/legacy/profiles:/:98707df3-b227-4a01-ae76-310f8270b9bd/background-color "'#ABAB9B9B6060'"

Step 4: (re)start gnome-terminal.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • thanks,when I copy paste your answer, commandline accepts it, exit status=0 but terminal background doesnt change, If I close and restart terminal, still no change. if I re-reun gconf --get .... it returns the previous color . Im suspecting your answer is correct regarding gconftool-2 but there possibly is a setting or startup script that is overriding the new value? – the_velour_fog May 25 '15 at 18:26
  • @user4668401 strange, I'm experiencing the same thing. The command is correct, but even with sudo it doesn't work – Sergiy Kolodyazhnyy May 25 '15 at 18:44
  • Interesting , I was suspecting it was because the gnome-terminal inherits its colors from the "system theme" (tickbox option under colors menu) and looking into what the system theme setting is. and Im already overriding the terminal tab colors using CSS so I tried use gtk.css file. no luck. will look into dconf – the_velour_fog May 25 '15 at 19:06
  • @user4668401 I'm gonna edit my post a bit later. I guess it's the thing now in 15.04 . . .go figure, right ? – Sergiy Kolodyazhnyy May 25 '15 at 19:11
  • hah , cool. I'll be interested to see what you discovered when you edit later – the_velour_fog May 25 '15 at 19:23
  • @user4668401 done, czech it out – Sergiy Kolodyazhnyy May 25 '15 at 20:52
  • nicely done. Unfortunately Im not getting the same result, I should have mentioned but Im on Ubuntu 14.04. I seem to be missing the dconf /org/gnome/terminal/ profile. even if I run dconf dump / and search output there is no entry for terminal. – the_velour_fog May 27 '15 at 02:30
  • @user4668401 um . . . well, you could create the schema, I guess, using same command dconf write – Sergiy Kolodyazhnyy May 27 '15 at 02:44
  • oh I didnt of that, I think I forget about supporting 14.04 and use your solution in the script, the script wont set the background for 14.04 , but should be ok for all other versions going forward. – the_velour_fog May 27 '15 at 09:58
  • There's no need for sudo, the user can set their own dconf settings. Also there's no need to restart gnome-terminal, it should pick up changes immediately. – egmont May 09 '19 at 13:38
  • Note that the shown commands alter the profile's settings, and as such take effect in all gnome-terminal tabs and windows of this profile. Thus this is a replacement for manually opening the preferences window and picking new colors there. If the user wishes to change the current terminal's color only, without affecting other tabs/windows of gnome-terminal (including newly opened ones), there are escape sequences (e.g. OSC 10 and 11) for that. – egmont May 09 '19 at 13:41
0

I just found out that gconf2 does seem to work - had the command wrong.
e.g. this works

gconftool-2 --set /apps/gnome-terminal/profiles/Default/background_color --type string "#393939"