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
  • Why gconftool2 ? you can do that through profile settings in gnome-terminal itself May 25, 2015 at 18:02
  • 2
    its part of a bash install script , dont have access to GUI May 25, 2015 at 18:03

2 Answers 2

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.

12
  • 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? May 25, 2015 at 18:26
  • @user4668401 strange, I'm experiencing the same thing. The command is correct, but even with sudo it doesn't work May 25, 2015 at 18:44
  • dconf works tho May 25, 2015 at 18:59
  • 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 May 25, 2015 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 ? May 25, 2015 at 19:11
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"
2
  • 1
    Doesn't work in 16.04
    – Anwar
    Aug 12, 2016 at 14:21
  • 1
    @Anwar Shah I think thats because 16.04 has had gtk version increased to 3 from 2 so now use gsettings insread of gconftool-2 Aug 12, 2016 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .