如何使用 gsettings 获取架构的摘要和描述

Jür*_*ger 7 gnome settings gsettings dconf

我更喜欢使用 gsettings 而不是 dconf-editor 因为 dconf-editor 缺少命令行选项来直接转到架构(例如,我必须执行“org - click - gnome -click - settings-daemon - click - plugins - click - 电源 - 单击。使用 gsettings 的一个问题是我看不到我在 dconf-editor 中获得的“描述”和“摘要”字段。有什么办法可以得到这些?

最好的,于尔根

小智 5

使用 无法做到这一点gsettings,因为该选项根本不存在。官方 Gnome 站点上有大量有关gsettings该程序的文档和内部结构。

但是,在 github 上有一个有趣的项目gsettings-info,它完全符合您的要求。它是一个脚本,用于从 gschema 信息中查询有关模式和/或键的信息,并返回有关它们的相同数据,这些数据在您使用dconf-editor.

您将需要 Git 和 git xsltproc(它用来读取 gschema 信息的库)

sudo apt install git xsltproc
Run Code Online (Sandbox Code Playgroud)

通过以下方式获取程序:

git clone git://github.com/jmatsuzawa/gsettings-info.git
cd gsettings-info 
Run Code Online (Sandbox Code Playgroud)

现在您可以运行脚本

./gsettings-info <command>
Run Code Online (Sandbox Code Playgroud)

您可以从主文件夹运行它(偶尔通过转到该文件夹​​并使用 来更新它git pull),或者安装到系统或将它放在您的~/bin文件夹中,以便只需输入gsettings-info.

如果您从下载的文件夹中运行它,输入./gsettings-info help将提供所有选项,自述文件和Github 页面上的信息也是如此

您可以找到有关架构和键的大量信息。以下是如何查找有关某些键的数据的示例。这假设它是从下载的文件夹运行的,因此./需要运行脚本。

  1. 要查找有关所选模式的特定键的详细信息,请输入:

    ./gsettings-info desc org.gnome.gnumeric.autocorrect
    
    Run Code Online (Sandbox Code Playgroud)

    返回:

    init-caps: Autocorrect initial caps
    init-caps-list: Autocorrect initial caps
    first-letter: The autocorrect engine does not correct the initial caps for words in this list.
    first-letter-list: The autocorrect engine does not correct the first letter for words in this list.
    names-of-days: Autocorrect names of days
    replace: Autocorrect replace
    
    Run Code Online (Sandbox Code Playgroud)
  2. 要显示特定键的默认值和信息,请使用:

    ./gsettings-info show org.gnome.gnumeric.autocorrect init-caps
    
    Run Code Online (Sandbox Code Playgroud)

    返回:

    KEY: init-caps
    TYPE: b
    SUMMARY: Autocorrect initial caps
    DESCRIPTION: Autocorrect initial caps
    DEFAULT: true
    
    Run Code Online (Sandbox Code Playgroud)

这似乎正是您正在寻找的,并且是在命令行而不是 in 上显示此信息的唯一方法dconf-editor