dconf 更改字符串键

Dre*_*mor 25 bash scripts dconf

我正在尝试使用以下命令行使用 bash 脚本更改基于字符串的 dconf 键:

dconf write /org/gnome/nautilus/preferences/show-directory-item-counts 'never'
Run Code Online (Sandbox Code Playgroud)

但它返回以下错误:

error: 0-5:unknown keyword

Usage:
  dconf write KEY VALUE 

Write a new value to a key

Arguments:
  KEY         A key path (starting, but not ending with '/')
  VALUE       The value to write (in GVariant format)
Run Code Online (Sandbox Code Playgroud)

有人能帮我吗?

编辑 1:我试图让 nautilus 不计算目录中的项目数(出于优化目的)

ste*_*ver 35

该值需要额外的引用,即分配 GVariant 字符串值,'foo'您需要将 value 参数写为"'foo'"

dconf write /org/gnome/nautilus/preferences/show-directory-item-counts "'never'"
Run Code Online (Sandbox Code Playgroud)

dconf -简单的工具,操纵dconf数据库https://developer.gnome.org/


小智 8

steeldriver 所说的是正确的做法。然而,使用gsettings是一种更简单的存档方式。

gsettings set org.gnome.nautilus.preferences show-directory-item-counts never
Run Code Online (Sandbox Code Playgroud)

  • 使用 gsettings 可能是更好的方法。请参阅 https://developer.gnome.org/dconf/unstable/dconf-tool.html,其中指出:“dconf 无法对值执行类型和一致性检查。如果需要此类检查,gsettings 实用程序是一种替代方法。” (2认同)
  • 似乎 gsettings 与 dconf 的键不同,例如 `dconf read /org/compiz/profiles/unity/plugins/scale/initiate-edge` 返回 `'TopRight'`,但 `gsettings get org.compiz.profiles.unity。 plugins.scaleitiate-edge`返回`没有这样的模式'org.compiz.profiles.unity.plugins.scale'` (2认同)