Tuesday, April 2, 2013

Editing DConf Defaults

Yep... geek speak warning.

Okay so you're one of the few who look at Linux as a deployment thing rather than having to set up things for each and every user. And suddenly they go and change things from gconf to dconf (and vice versa - the most confusing bit, isn't the misinformation, but knowing where to put settings - gconf seems to work for some things. dconf for others).

Misinformation I say? So it took me a while but I finally figured out where the defaults were stored - on Ubuntu 12.04, they're in: /usr/share/glib-2.0/schemas. Once there, you just have to create a gscheme.override file and you're away... only... where do you find out what the path to the keys are? A GUI tool would be nice right?

So the advice on the Internet seems to be to install dconf-tools and and use dconf-editor. There's a problem here. The paths dconf-editor seem to be COMPLETELY different from those you actually need. Don't waste your time. It'll just make you want to punch someone. That and it's rather a miserable tool. The find function and keyboard navigation just makes you want to cry.

So at the my last big testing session a few bugs came up related to things I thought (but hadn't had time to test) I had sorted only to find that none of those defaults seem to take. It turns out there are multiple paths to the same value but setting it in the wrong place results in it being ignored. This must be the bit about "stored in an unstructured database" on it's main page.

So where is the information we want? Well it happens to be in that same directory pointed to above. Except that it's all in XML with full descriptions and the like. So I quickly (it can probably be improved upon a lot - it's just enough for my needs at the moment) wrote this script to sort out this particular little problem:



grep -m1 -I -i "$1" $SCHEMA_PATH/* | while read line ; do
  FILE=$( echo $line | cut -f 1 -d ":" )
  echo -e "File: $FILE"
  grep "$1" $FILE | grep "^ .<schema path" | while read line2 ; do
    SCHEMA="$( echo $line2 | cut -f 2 -d '"' )"
    ID="$( echo $lin2 | cut -f 4 -d '"' )"
    echo -e "\tSchema:\t$line2\tID:$ID"
  grep -i "$1" $FILE | grep "name=\"" | cut -f 4 -d '"' | while read line2 ; do
    echo -e "\tKeyname" $line2

The ID gives you the path that you need for making an overrides file, whereas the keyname at least gives you a clue of where to look... If you save this in a file called search_dconf_schemas and make it executable (and preferably on your path), then you would it use it by typing in:

search_dconf_schemas search_term

Here's hoping this comes in handy for someone...

I'm think this could be a whole lot smarter. Actually making this process really easy might become a whole new sideline project (although I'm going to have a few of those on the go including some renovations).

ARGHHHHHH!!!!!!!! It seems that even some of the files in there seem to be ignored. All of these for example.
(of particular interest is unityshell).

Custom keyboard shortcuts have to be defined in gconf on Ubuntu 12.04. Unity 2d settings are in dconf where as all Unity settings are in gconf.

Way to make things horrendously inconsistent Canonical...

No comments:

Post a Comment