вторник, 10 апреля 2012 г.

migrate custom GNOME3 keybindings from GConf to dconf

Quite natural need but was not implemented by GNOME team. Ok, can do it on our own!
1. Get em' from GConf:
cd `mktemp -d`
gconftool-2 --dump /desktop/gnome/keybindings | sed -n '/<key>custom/,/<key>[^c]/ p' > 1
2. Next, cut off xml garbage:
cat 1 | grep '<string' | sed 's|^.*<string>||;s|</string.*$||; s|&quot;|"|g; s|&lt;|<|g;s|&gt;|>|g' > 2
3. Now take these command/binding/name triplets into the dconf-compatible form:
i=0 ; while read v; do echo "[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$i]" ; echo command=\'$v\' ; read v ; echo binding=\'$v\' ; read v ; echo name=\'$v\' ; i=$(($i+1)); echo ; done < 2 > 3
4. Yau! Get it into the dconf!
dconf load / < 3
5. Now fix the custom-keybindings key in org/gnome/settings-daemon/plugins/media-keys
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings `egrep '^\[' 3 | sed "s|\[|'/|;s|\]|/'|" | tr '\n' , | sed 's|^|[|;s|,$|]|'`
That's it!

Комментариев нет:

Отправить комментарий