gsettings 提供了对GSetings的命令行操作。
GSetings实际上是一套高级API,用来操作dconf。
dconf存储着GNOME3的配置,是二进制格式。它做为GSettings的后端系统存在,暴露出低级API。在GNOME2时代,类似的角色是gconf,但它是以XML文本形式存储。
更接地气的说法是,dconf是GNOME3的注册表,gsettings是一个查询、读取、设置注册表键值的命令行工具。
列出所有schema
$ gsettings list-schemas
查找某个schema
$ gsettings list-schemas | grep "org.gnome.settings-daemon.plugins.keyboard"
org.gnome.settings-daemon.plugins.keyboard
查找某个schema下的所有key
$ gsettings list-keys "org.gnome.settings-daemon.plugins.keyboard"
active
priority
查看某个schema下某个key的值
$ gsettings get "org.gnome.settings-daemon.plugins.keyboard" priority
0
查看某个schema下某个key的值类型
这是一个整形
$ gsettings range "org.gnome.settings-daemon.plugins.keyboard" priority
type i
这是一个boolean类型
$ gsettings range "org.gnome.settings-daemon.plugins.keyboard" active
type b
设置某个schema下某个key的值
$ gsettings set "org.gnome.settings-daemon.plugins.keyboard" active false
也可以一步到位,同时搜索schema和keys
$ gsettings list-recursively | grep "org.gnome.settings-daemon.plugins.keyboard"
org.gnome.settings-daemon.plugins.keyboard active false
org.gnome.settings-daemon.plugins.keyboard priority 0
org.gnome.settings-daemon.plugins.keyboard active false
org.gnome.settings-daemon.plugins.keyboard priority 0
查看帮助文档
$ gsettings -h
Unknown command -h
Usage:
gsettings --version
gsettings [--schemadir SCHEMADIR] COMMAND [ARGS…]
Commands:
help Show this information
list-schemas List installed schemas
list-relocatable-schemas List relocatable schemas
list-keys List keys in a schema
list-children List children of a schema
list-recursively List keys and values, recursively
range Queries the range of a key
describe Queries the description of a key
get Get the value of a key
set Set the value of a key
reset Reset the value of a key
reset-recursively Reset all values in a given schema
writable Check if a key is writable
monitor Watch for changes
Use “gsettings help COMMAND” to get detailed help.
如果你觉得命令行操作还是不太直观,可以使用GUI工具 gconf-editor
|