Ubuntu – Seriously, dconf, gconf, gsettingsā€¦ How to save the terminal settings

dconfgconfgnomegnome-terminalgsettings

I'm trying to do something relatively simple that most of us have wanted to do at one time or another: Save my gnome-teminal settings.

I'm running 14.04 (desktop obviously). I've realized from my research that dconf, gconf, and gsettings have over the course of the last couple version bumps, been designated to store the settings for different aspects of Gnome/Unity.

If I ask all of the questions I have about these tools. It would spiral out of control, and I don't want to learn the internals of 3 tools (8 if you count gconftool, gconftool-2, gconfd-2, dconf-service, dconf-ibus, and the dconf database as individual tools)

My new goal is consolidate all of the settings into gsettings, as it contains the most existing settings.

Has this been done?

I've determined that I can unregister gconf schemas.

I've determined that gsettings operates on the dconf database with a much friendlier interface (i.e. the finest tab completion anyone could ask for in a command-line tool.)

Would there be any major caveats, aside from the time investment, to moving config from gconf to dconf, and just creating gsettings schemas for those settings… So that I can easily save my gnome-terminal settings, and any other UI preferences I wish to adjust that come up?

[Edit:]

Thanks to the comment by @Rinzwind below, I have decided to ignore gconf and found the settings for gnome-terminal. However it consists of only 2 keys, exec-arg, and exec.

Where can I find a list of all the keys I can add?

Best Answer

This is an old question but clearly still relevant.

Based on this useful post, here is how to backup/restore your GNOME Terminal settings; this can be used for instance when migrating from one computer to another.

* Please be advised * : this will overwrite the default Terminal profile on the new machine!

  1. Make sure you're using the same profile name on both machines by renaming it under "Profiles" in the Preferences dialog and activate it if necessary (click on drop-down menu and select "Set as default")
  2. On the source machine run this little script:

    gprofile=$(gsettings get org.gnome.Terminal.ProfilesList default)
    gprofile=${gprofile:1:-1}
    gschema=org.gnome.Terminal.Legacy.Profile
    gpath=/org/gnome/terminal/legacy/profiles:/:${gprofile}/
    gsettings list-recursively ${gschema}:${gpath} > /tmp/term_profile.gsettings
    
  3. Examine the profile backup file (/tmp/term_profile.gsettings) to make sure it looks sensible. It might be useful to delete any unwanted settings that you don't want to carry across.

  4. Copy the backup file across to the new computer, eg:

    scp /tmp/term_profile.gsettings new-host:/tmp
    
  5. Now run the following little script on the new computer; we'll start with a dry-run to have a chance to spot any unexpected stuff:

    gprofile=$(gsettings get org.gnome.Terminal.ProfilesList default)
    gprofile=${gprofile:1:-1}
    gschema=org.gnome.Terminal.Legacy.Profile
    gpath=/org/gnome/terminal/legacy/profiles:/:${gprofile}/        
    cut -f2- -d' ' /tmp/term_profile.gsettings | while read line; do
       key=$(echo $line | cut -f1 -d' ')
       value=$(echo $line | cut -f2- -d' ')
       echo "$key => $value"
       # commented out for dry-run:
       # gsettings set ${gschema}:${gpath} $key "$value"
    done
    
  6. Assuming the output looks good, repeat the above script but un-comment the gsettings set line. Your changes (eg: palette change) should apply immediately to your running Terminal.

Tested on 19.10 but should work on some older (and possibly newer) versions too.

Note that this only takes care of the preferences found under "Profile"; assuming the relevant gsettings keys can be discovered, the technique should work to backup/restore them too.