confd_什么是dconf,它的功能是什么,我该如何使用它?

问题描述

Mark Shuttleworth recently blogged关于决定在11.10版本中包含Qt库,以及followup from Jono Bacon。 Mark表示,将用Qt编写的应用程序集成到更大的Ubuntu系统中的最大挑战是Qt目前使用dconf的non-compatibility。

什么是dconf,它在Ubuntu中扮演的角色是什么?

最佳解决方案

介绍

由于本网站上的其他答案一起讨论了gconf和dconf,我将集中讨论用于访问dconf数据库的命令行工具,如gsettings和gui dconf-editor。

dconf is a low-level configuration system. Its main purpose is to provide a backend to GSettings on platforms that don’t already have configuration storage systems.

dconf is a simple key-based configuration system. Keys exist in an unstructured database (but it is intended that keys that logically belong together are grouped together).

Having all of the keys in a single compact binary format also avoids the intense fragmentation problems currently experienced by the tree-of-directories-of-xml-files approach.

dconf is optimised for reads. Typically, reading a key from dconf involves zero system calls and zero context switches. Writes are less optimised — they traverse the bus and are handled by a “writer” — a DBus service — in the ordinary way.

使用gsettings查看和更改设置

一旦了解了gsettings,就可以像gui dconf-editor一样简单。可以通过输入man gsettings或转到Ubuntu manpages online来列出选项。

注意:由于每个人的系统都安装了不同的程序,因此我在使用XUbuntu XFce和很多GNOME程序时,可能必须用自己的实验代替我选择的不同项目。

要列出所有可用的模式,请输入

gsettings list-schemas

要包括所有键,请输入

gsettings list-recursively

但是,通常更容易指定您想要的内容,例如,

gsettings list-schemas | grep -i shotwell

这会返回一个长列表;我把它缩短为:

org.yorba.shotwell

org.yorba.shotwell.preferences.ui

org.yorba.shotwell.preferences.slideshow

org.yorba.shotwell.plugins.enable-state

org.yorba.shotwell.printing

org.yorba.shotwell.preferences.editing

org.yorba.shotwell.preferences.files

现在,当您找到了您感兴趣的架构时,请列出键

gsettings list-keys org.yorba.shotwell.preferences.ui

这会返回一个列表(我再次缩短了它):

background-color

display-basic-properties

display-extended-properties

display-photo-ratings

display-photo-tags

display-photo-titles

event-photos-sort-ascending

event-photos-sort-by

选择一个并查看当前值是什么

gsettings get org.yorba.shotwell.preferences.ui display-photo-tags

这将返回true值,因此要将其反转,请使用

gsettings set org.yorba.shotwell.preferences.ui display-photo-tags false

这些是一些简单的例子,但基本上显示了如何使用gsettings识别和更改键和值。

使用dconf-editor更改设置

通过单击以下命令安装gui程序dconf-editor(12.04):

或者通过跑步

sudo apt-get install dconf-tools

然后通过进入终端或快速启动菜单dconf-editor来运行它。

正如您在屏幕截图中看到的,可以在左侧展开所有各种模式,并选择相应的密钥。导航到所需的值非常简单(在本例中为gnome-mplayer首选项)。您可以单击复选框以激活值,或将数值添加到其他一个框中。您还可以使用Ctrl + F键盘快捷键在dconf编辑器中搜索。

您还可以通过在下面的屏幕截图中添加[‘/var/log/auth.log’,var ….’]形式的路径,向log-viewer添加另一个日志。

结论

您可以使用gsettings和dconf-editor调整设置,还有许多其他有用的方法,它们很容易使用。值得仔细查看它们是否存在不在程序首选项中的选项,因为您可以按照自己的方式自定义程序。正如最近在这个问题上展示的化石自由

知道如何使用gsettings或dconf-editor非常有价值。也可以看看:

次佳解决方案

对于那些来自需要简单回复的窗口的人来说,dconf是相当于windows注册表的gnome …一个大的二叉树,任何程序都可以存储和共享他们的配置。

他们首先从传统的unix配置(每个应用程序的一个文本文件,每个都有自己的格式)迁移到由gconf管理的标准XML文件树。最近,由于几乎没有人直接编辑这些XML文件以及读取和解析MANY文件的性能问题,他们通过从gconf迁移到dconf迁移到二进制格式。

与Windows注册表不同,dconf应该列出所有配置条目,即使它们被设置为默认值。因此没有隐藏的条目,您可以更改然后重置然后轻松默认。

第三种解决方案

dconf不是Ubuntu特有的,它是用于存储应用程序设置的GNOME技术。有关详细信息,请阅读http://live.gnome.org/dconf

参考资料

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值