【问题标题】:syntax to override gsettings bytestring覆盖 gsettings 字节串的语法
【发布时间】:2020-12-22 07:33:50
【问题描述】:

我正在尝试在覆盖文件中为 nemo 定义 gsetting 默认值。 密钥 (org.nemo.preferences bulk-rename-tool) 是 type="ay",这意味着它是一个字节串,如 developer.gnome.org 中所述

在 nemo 的首选项对话框中将其设置为 gprename 后,gsettings get org.nemo.preferences bulk-rename-tool 的返回值为 b’gprename’ 和 在运行环境中,我可以成功设置值 gsettings set org.nemo.preferences bulk-rename-tool "b’gprename’" 但是我找不到正确的语法来包含在覆盖文件中。

我尝试了方括号、双引号/单引号,包括 developer.gnome.org 上提到的各种组合和变体的 nul 终止符 - 没有成功。

例如

[org.nemo.preferences]
bulk-rename-tool="b’gprename’"

导致

# glib-compile-schemas /usr/share/glib-2.0/schemas/

error parsing key 'bulk-rename-tool' in schema 'org.nemo.preferences' as
specified in override file '/usr/share/glib-2.0/schemas/99_custom-cinnamon.gschema.override':
0-13:can not parse as value of type 'ay'.Ignoring override for this key.

或者

bulk-rename-tool=[b’gprename’]

给予

error parsing key 'bulk-rename-tool' in schema 'org.nemo.preferences' as
specified in override file '/usr/share/glib-2.0/schemas/99_custom-cinnamon.gschema.override':
1:expected value.Ignoring override for this key.

由于架构中的默认值仅列出空括号[],因此我也尝试过类似

bulk-rename-tool=[b’gprename'\0]

这给了我

1.14:unterminated string constant.

所以也许这是最接近工作的,只是 nul 终止符显然是错误的语法......

【问题讨论】:

    标签: gsettings


    【解决方案1】:
    [org.nemo.preferences]
    bulk-rename-tool=b'thunar --bulk-rename'
    

    不要在配置覆盖“...”中使用引号。只有通过 cli 设置值时才会使用它们,即

    $ dconf write /org/nemo/preferences/bulk-rename-tool "b'thunar --bulk-rename'"
    

    您发布的编译行是正确的,应该可以正常工作。

    $ glib-compile-schemas /usr/share/glib-2.0/schemas/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多