Where is "Settings" information stored?

When I tweak a setting in the Settings menu in Ubuntu, where is that information stored? For example if I add a custom keyboard shortcut, or set my default display, where does is this information later retrieved from by the OS? I am sure it ends up in a text file somewhere, but I haven't found it yet (probably because I am not quite sure where to look).

Update:

WOW! All the answers below so far have been super helpful! My question was perhaps a little too general, and ideally I would accept all answers as correct because they all provide very useful tools for finding useful config (or other) information.

I am accepting @A.B.'s answer, because dconf watch / scratched my particular itch perfectly. However, I would direct future readers to @serg's answer for it's detail, and @DK Bose's answer for its general usefulness. I would also suggest anyone with a similar question to experiment with all the suggested commands as I will be doing!


Solution 1:

There are many possible places:

  1. Your config folder ~/.config. Watch with

    inotifywatch -e modify,create,delete -r ~/.config
    
  2. The dot files direct to your home folder. Watch, e.g. your .mozilla folder with

    inotifywatch -e modify,create,delete -r ~/.mozilla
    
  3. The files in your local folder ~/.local. Watch with

    inotifywatch -e modify,create,delete -r ~/.local
    
  4. The dconf database, watch with

    dconf watch /
    

    and make some changes to check it ...

Solution 2:

One possible general approach is this. Close all other programs except the one you're going to tweak. Make your tweak. Then, immediately run something like this:

find ~/ -mmin -1 -type f -ls

You may see some hits you may decide aren't relevant. find allows you to eliminate them:

find ~/ ! -path "*mozilla*" ! -path "*google-chrome*" ! -path "*cache*" ! -path "*dropbox*" -mmin -1 -type f -ls

You can add or delete paths, depending on your needs.

As an example, I'll change a setting of a text editor, Mousepad, and then run the long version.

$ find ~/ ! -path "*mozilla*" ! -path "*google-chrome*" ! -path "*cache*" ! -path "*dropbox*" -mmin -1 -type f -ls  
7735309   12 -rw-r--r--   1 dkb    dkb       10948 Oct 29 10:56 /home/dkb/.config/Mousepad/accels.scm  
7734498    4 -rw-rw-r--   1 dkb    dkb        1397 Oct 29 10:56 /home/dkb/.config/Mousepad/mousepadrc  
7209188  240 -rw-------   1 dkb    dkb      242407 Oct 29 10:56 /home/dkb/.local/share/recently-used.xbel  
$ 

(The last hit mostly isn't useful.)

Solution 3:

Where Settings menu information is stored depends on some of the items. Such things as desktop background, themes, language, and keyboard shortcuts ( including custom ones ) - those all go into dconf schemas, while such things as Display settings and Network settings have to interface with xrandr and network-manager programs respectively.

For instance, in the settings menu I have a custom shortcut PAGE-DOWN. If I do dconf dump / | grep -C 5 PAGE Appropriately enough, I will see the following entry:

[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7]
binding='<Alt>period'
command='bash -c "xdotool getactivewindow key Page_Down"'
name='PAGE-DOWN'

Same thing for Power settings , it's in dconf:

[org/gnome/settings-daemon/plugins/power]
idle-dim=false
lid-close-battery-action='nothing'
lid-close-ac-action='nothing'

Theme:

$ dconf dump / | grep  theme                                       
cursor-theme='crystalblue_classic'
icon-theme='Deepin-2013'
gtk-theme='Numix'
theme='Numix'

As far as positioning the screen goes, you can do it through Settings -> Display menu or use xrandr , for example something like

xrandr --output VGA1 --auto --output HDMI1 --auto --right-of VGA1

(Example from Arch Wiki)

Even more manual way, is to alter .config/monitors.xml file, which is what xrandr does.

But above all of them governs gnome-settings-daemon if you have Gnome shell or unity-settings-daemon if you have Unity ( default desktop ). Knowing that, I've used dconf, gconf and xrandr in numerous scripts on this site to adjust desktop functionality, and used gnome-settings-daemon to simplify behavior of openbox environment. Bellow are some of the examples,

Assign default keyboard language per-application ( uses gsettings)

How to permanently set my second screen's resolution?(uses xrandr )