I heard about a script which will change the colors of GNOME Terminal each time it starts. I can't remember where I saw this...

  • You want different, random colors each time?
    – innaM
    Sep 16, 2009 at 6:35
  • Well not random. It was more like predefined.
    – Kredns
    Sep 16, 2009 at 19:19

1 Answer 1


I haven't seen the script you mention. But I think it is possible to create such a script.

Gnome Terminal picks up the background colour from the profile in use, so any change will impact the background colour of all terminals using the same profile.

That said, the configuration key is stored in /apps/gnome-terminal/profiles/Default/background_color, where Default is the currently used profile.

It can be set thus:

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

So, I'm guessing that one can write a script to clone the Default profile on the fly, change it's background_color, invoke gnome-terminal with this profile, and delete the profile before exiting. You'll also need a database of good foreground/background color combinations for this script to use.

Update: Here is a script to do what is discussed above. It does not generate a random background color, that you'll have to generate using some list.



#replace with program to generate a random background color

# dump the "Default" profile, replace with new random profile name
gconftool-2 --dump /apps/gnome-terminal/profiles/${DEFAULT_PROFILE} > ${PROFILE_EXPORT_FILE}

# load the new random profile, change the background color
gconftool-2 --load ${PROFILE_EXPORT_FILE}
gconftool-2 --set "/apps/gnome-terminal/profiles/${PROFILE_NAME}/background_color" --type string "${BACKGROUND_COLOR}"

# add the new random profile to list of profiles
PROFILE_LIST=`gconftool-2 --get /apps/gnome-terminal/global/profile_list`
gconftool-2 --set  /apps/gnome-terminal/global/profile_list --type list --list-type string "$NEW_PROFILE_LIST"
# start gnome-terminal with new random profile, such that the script blocks till terminal is closed.
gnome-terminal --window-with-profile=${PROFILE_NAME} --disable-factory

# cleanup: remove the new random profile, and remove it from list of profiles
gconftool-2 --recursive-unset /apps/gnome-terminal/profiles/${PROFILE_NAME}
PROFILE_LIST=`gconftool-2 --all-dirs /apps/gnome-terminal/profiles | sed "s/ \/apps\/gnome-terminal\/profiles\///" | sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}'`
gconftool-2 --set  /apps/gnome-terminal/global/profile_list --type list --list-type string '['"${PROFILE_LIST}"']'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.