gsettings の使い方
gsettings の使い方を調べてみた。
一応、マニュアルは以下にある。
http://library.gnome.org/devel/gio/unstable/gsettings.html
しかし、これじゃ分からなかったので調べてみた。
gsettings は、 /usr/share/glib-2.0/schemas 以下にインストールされる *.gschema.xml の設定を変更したり表示したりするツールで、 GUI では
$ dconf-editor
というツールがある。
今回は /usr/share/glib-2.0/schemas/org.gnome.gcalctool.gschema.xml を題材に設定変更してみる。
gsettings は
$ gsettings (get|set|reset|monitor|writable) id key
の書式で実行する。gcalctoolの小数点以下の表示桁数を見てみる。
$ gsettings get org.gnome.gcalctool accuracy 9
これは、xmlファイルの
<schema path="/apps/gcalctool/" id="org.gnome.gcalctool" gettext-domain="gcalc tool"> <key type="i" name="accuracy"> <default>9</default> <range min="0" max="9"/> <summary>Accuracy value</summary> <description>The number of digits displayed after the numeric point</descr iption> </key>
に対応している。
この桁数を 7 に変更するには、
$ gsettings set org.gnome.gcalctool accuracy 7
のようにする。表示すると
$ gsettings get org.gnome.gcalctool accuracy 7
となっている。gcalctoolを実行して試しても小数点以下の桁数は7に変更されている。
設定可能範囲は
$ gsettings set org.gnome.gcalctool accuracy 20 (gsettings set:21331): GLib-GIO-CRITICAL **: g_settings_set_value: assertion `g_settings_range_check (&info, value)' failed Key accuracy is not writable
となって変更できない。
デフォルトは 9 なので、 reset すればもとに戻る。
$ gsettings reset org.gnome.gcalctool accuracy $ gsettings get org.gnome.gcalctool accuracy 9
簡単に、 gsettings の get set reset の使い方を紹介しました。スクリプトで変更するときは、gsettings が使えそうです。