How to change gnome-terminal profile preferences using dconf or gsettings?

14,834

The syntax to be used with the gsettings command is described in GNOME Terminal Frequently Asked Questions.

First you need to find out the identifier of the profile you want to change. For example, the identifier of the gnome-terminal default profile can be obtained from schema org.gnome.Terminal.ProfilesList.

Then change the desired keys of path /org/gnome/terminal/legacy/profiles:/:UUID/ of schema org.gnome.Terminal.Legacy.Profile: for this profile.

Note the colons in the above path. It will not work if they are omitted.

Here is a script that use the above to set default-size-columns of the default profile:

profile=$(gsettings get org.gnome.Terminal.ProfilesList default)
profile=${profile:1:-1} # remove leading and trailing single quotes
gsettings set "org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$profile/" default-size-columns 150
Share:
14,834

Related videos on Youtube

Håkon Hægland
Author by

Håkon Hægland

Updated on September 18, 2022

Comments

  • Håkon Hægland
    Håkon Hægland over 1 year

    After upgrading form Ubuntu 14.10 to 15.10, it seems that changing gnome-terminal preferences using gconftool-2 is no longer supported. I guess this issue is related the Gconf to GSettings migration.

    Now, I would like to change some of my old scripts ( since they are broken in Ubuntu 15.10 ) to work with dconf/gesettings instead of gconftool-2.

    As an example, on Ubuntu 14.10 ( gnome-terminal version 3.6.2 ) I could set the number of columns in the Default profile using:

    $ gconftool-2 --set /apps/gnome-terminal/profiles/Default/default_size_columns \
                --type=int 140
    $ gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_custom_default_size \
                --type=bool true
    

    Now, in Ubuntu 15.10, typing:

    $ dconf list /org/gnome/terminal/legacy/
    

    gives

    profiles:/
    schema-version
    

    whereas

    $ gsettings list-relocatable-schemas | grep Terminal
    

    gives

    org.gnome.Terminal.SettingsList
    org.gnome.Terminal.Legacy.Profile
    org.gnome.Terminal.Legacy.Keybindings
    

    The above output confuses me:

    Still in Ubuntu 15.10 (using gnome-terminal version 3.16.2), if I run:

    $ gsettings list-keys org.gnome.Terminal.Legacy.Profile:/ | grep default
    

    I get:

    default-size-rows
    default-show-menubar
    default-size-columns
    

    so there is a default-size-columns key that could (?) correspond to the default_size_columns key in Ubuntu 14.10, but there is no use-custom-default-size key corresponding to the use_custom_default_size key in Ubuntu 14.10. This also confuses me.

    Also, if I try running:

    $ gsettings set org.gnome.Terminal.Legacy.Profile:/ default-size-columns 150
    

    and open a new gnome-terminal the setting of default-size-columns seems to have no effect since the terminal still opens with 80 columns..

    • Håkon Hægland
      Håkon Hægland about 8 years
      @ByteCommander I have upgraded to 15.10 now, and the question remains the same w.r.t 15.10 as for 15.04. I also found a solution, that I would like to post. How can this question be reopened, so I can post the solution?
  • Byte Commander
    Byte Commander about 8 years
    Cool that you found the solution yourself. Don't forget to accept your own answer.
  • Anatoli
    Anatoli about 7 years
    Actually, you can specify the number of the profile instead of its ID, so the command would be just: gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy‌​/profiles:/:0/ default-size-columns 150
  • Anatoli
    Anatoli about 7 years
    Or even shorter: gsettings set org.gnome.Terminal.Legacy.Profile:/:0/ default-size-columns 150
  • yaobin
    yaobin over 4 years
    Your answer saved my day! How did you find out the syntax of "org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legac‌​y/profiles:/:.../"? Did you find it in the documentation? What got me stuck was I didn't realize "Profile" should be followed by "/org/gnome/...".