在以前的 Ubuntu 版本中,我能够从用于设置新笔记本电脑的脚本中执行这些 gsettings 命令:
gsettings set org.gnome.desktop.interface.show-battery-percentage true
gsettings set org.gnome.nautilus.preferences.default-folder-viewer 'list-view'
gsettings set org.gnome.nautilus.list-view.default-zoom-level 'small'
但从 20.04 开始,我无法:
$ gsettings set org.gnome.nautilus.list-view.default-zoom-level 'small'
Usage:
gsettings [--schemadir SCHEMADIR] set SCHEMA[:PATH] KEY VALUE
Set the value of KEY to VALUE
Arguments:
SCHEMADIR A directory to search for additional schemas
SCHEMA The name of the schema
PATH The path, for relocatable schemas
KEY The key within the schema
VALUE The value to set
但是,如果我在 UI 上执行此操作(例如使用 gnome-tweaks),并且我dconf watch /
在执行此操作时运行,则一切看起来都是正确的。
答案1
来自架构文件/usr/share/glib2.0/schemas/org.gnome.nautilus.gschema.xml
<schema path="/org/gnome/nautilus/list-view/" id="org.gnome.nautilus.list-view" gettext-domain="nautilus">
<key name="default-zoom-level" enum="org.gnome.nautilus.ListZoomLevel">
<default>'standard'</default>
<summary>Default list view zoom level</summary>
</key>
SCHEMA = org.gnome.nautilus.list-view
KEY = default-zoom-level
gsettings [--schemadir SCHEMADIR] set SCHEMA[:PATH] KEY VALUE
简化以上内容
gsettings set SCHEMA KEY VALUE
gsettings set org.gnome.nautilus.list-view default-zoom-level $VALUE
因此你的 gsettings 命令应该是
gsettings get org.gnome.nautilus.list-view default-zoom-level
gsettings set org.gnome.nautilus.list-view default-zoom-level '$value'