我想监视dconf
更改,以便在我修改设置、应用程序等时,我可以看到更改了哪些键(如果有)。
有没有办法我可以做到这一点?
我想从命令行更改org.compiz.profiles.unity.plugins.core
->hsize
和 -> vsize
。
我以为我可以用
gsettings set org.compiz.profiles.unity.plugins.core vsize 4
Run Code Online (Sandbox Code Playgroud)
但后来我收到一条错误消息:
No such schema 'org.compiz.profiles.unity.plugins.core'
Run Code Online (Sandbox Code Playgroud)
有可能吗?可以清楚地看到设置,如所附屏幕截图所示。
我需要通过 Puppet、虚拟终端或 ssh 自动化桌面配置。
不幸的是,gsettings
通过 ssh 或虚拟终端调用会给出:
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
(process:29520): dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
Run Code Online (Sandbox Code Playgroud)
当我$DISPLAY
用export DISPLAY=:0.0
它设置时会出现另一个错误:
(process:29862): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused
Run Code Online (Sandbox Code Playgroud)
我能做什么?
两天前,我从 Windows 迁移到了 Ubuntu 16.04。我喜欢我们可以自定义 Unity 桌面的方式。我只是在玩弄桌面环境的外观和感觉。就像在 Windows 中一样,我希望启动器位于屏幕底部。在谷歌上,我发现了一个命令,它是这样的:
gsettings set com.canonical.Unity.Launcher launcher-position Bottom
Run Code Online (Sandbox Code Playgroud)
此外,还有用于完成工作的 unity-tweak-tool 和 dconf 编辑器。但这些是完成工作的 GUI 方法。
我的问题是:
这里的答案告诉了如何获取进程的标准文件描述符。但是,我没有在输出中得到任何东西。
此外,该strace -p pid -o output.txt
命令会向文件中抛出大量文本。
那么,简而言之,使用 GUI 应用程序做事与从命令行做事是一样的吗?
我正在尝试使用以下命令行使用 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 不计算目录中的项目数(出于优化目的)
我在 VirtualBox 中运行 Ubuntu 12.04.1 LTS x64。在一次非常不幸的误点击(重置保存状态而不是加载保存状态)之后,我遇到了一个非常烦人的问题。
几乎所有应用程序(unity、synaptic、gedit 等)都会在启动时打印:
Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
Run Code Online (Sandbox Code Playgroud)
并且所有 GUI 设置都在重新启动后重置。
另一个症状:
$ GSETTINGS_BACKEND=dconf dconf-editor
(dconf-editor:2353): GLib-GIO-WARNING **: Can't find module 'dconf' specified in GSETTINGS_BACKEND
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications
Run Code Online (Sandbox Code Playgroud)
但/usr/lib/x86_64-linux-gnu/gio/modules/libdconfsettings.so
存在。
我尝试过的(并没有帮助):
sudo apt-get install -f --reinstall dconf-tools libdconf0 libdconf-dbus-1-0 dconf-service
make install
它我必须保留当前的 Ubuntu 安装,因此完全重新安装对我来说不是一个选择。 …
经过一番研究,我发现我可以使用gsettings
终端中的命令快速设置配置选项,而不是安装dconf-editor
orgconf-editor
或 CCSM。
但是我们需要 SCHEMA/PATH 和 KEY 来设置值。
语法是:
gsettings set SCHEMA[:PATH] KEY VALUE
Run Code Online (Sandbox Code Playgroud)
例如,从不自动隐藏启动器:
gsettings set com.canonical.Unity2d.Launcher hide-mode 0
Run Code Online (Sandbox Code Playgroud)
并且,对于不与启动器重叠的窗口:
gsettings set com.canonical.Unity2d.Launcher use-strut true
Run Code Online (Sandbox Code Playgroud)
那么,我在哪里可以获得可以使用 gsettings 设置的所有 SCHEMA / PATH / KEY 的列表?
不,请不要建议该gsettings list-keys
命令,因为我不知道可能有数百个可用的模式。
有一种方法可以用 Gconf 注册 URL 协议处理程序,现在已经过时了,而且似乎无法用 DConf(或 Gsettings,它推荐的包装器)来做同样的事情。
自 DConf 以来,如何正确注册 URL 协议处理程序?
此外,在我的 Ubuntu 12.04 上,有些东西对我来说看起来很奇怪(因为我不明白)
该协议apt://
应由apturl
命令处理。我的 Opera 浏览器也是如此,但这只是因为我使用浏览器的配置工具添加了这个特定的关联。否则,在其余环境中:
xdg-open apt://foo.bar
打开elinks
(我的www-browser
选择)。gnome-open apt://foo.bar
打开软件?中心。gconf-editor
,我看到一个键,/desktop/gnome/url-handlers/apt
其值为apturl "%s"
并且已启用。这种配置似乎被忽略了,这是合理预期的,因为 GConf 被认为已过时。dconf-editor
,我看不到任何与 URL 处理程序或协议相关的内容/desktop/gnome
我的眼睛看起来有点乱(只是用这个措辞开玩笑,没什么不好的)
下面是什么?
旁注:我正在寻找即使在未加载完整桌面环境的情况下也能最好工作的东西,例如在运行 i3wm 会话时只gsettings-daemon
加载(以及与此案例无关的其他内容)。
“注册”协议处理程序的另一种方法是使用*.desktop
文件及其 MIME 类型;例如MimeType=application/<the-protocol>;
。
我找到了一个/usr/share/applications/ubuntu-software-center.desktop
有这个内容的:
[Desktop Entry]
Name=Ubuntu Software Center
GenericName=Software Center
Comment=Lets you choose from …
Run Code Online (Sandbox Code Playgroud) 从 Ubuntu 14.10 升级到 15.10 后,似乎不再支持gnome-terminal
使用更改首选项gconftool-2
。我猜这个问题与Gconf 与 GSettings 迁移有关。
现在,我想更改我的一些旧脚本(因为它们在 Ubuntu 15.10 中已损坏)以使用dconf
/gesettings
而不是gconftool-2
.
例如,在 Ubuntu 14.10(gnome-terminal
版本 3.6.2)上,我可以使用以下方法设置Default
配置文件中的列数:
$ gconftool-2 --set /apps/gnome-terminal/profiles/Default/default_size_columns \
--type=int 140
$ gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_custom_default_size \
--type=bool true
Run Code Online (Sandbox Code Playgroud)
现在,在 Ubuntu 15.10 中,输入:
$ dconf list /org/gnome/terminal/legacy/
Run Code Online (Sandbox Code Playgroud)
给
profiles:/
schema-version
Run Code Online (Sandbox Code Playgroud)
然而
$ gsettings list-relocatable-schemas | grep Terminal
Run Code Online (Sandbox Code Playgroud)
给
org.gnome.Terminal.SettingsList
org.gnome.Terminal.Legacy.Profile
org.gnome.Terminal.Legacy.Keybindings
Run Code Online (Sandbox Code Playgroud)
上面的输出让我感到困惑:
/org/gnome/terminal/legacy/profiles:/
路径dconf
但没有org.gnome.Terminal.Legacy.Profiles
(注意尾随s
)模式 ID …安装 Gsettings 架构的典型工作流程是这样的:
创建一个带有扩展名的架构,.gschema.xml
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="com.companyname.appname" path="/com/companyname/appname/">
<key type="b" name="mybool">
<default>false</default>
<summary>Example summary</summary>
<description>Example description</description>
</key>
</schema>
</schemalist>
Run Code Online (Sandbox Code Playgroud)将架构复制到/usr/share/glib-2.0/schemas/
.
通过运行以下命令编译架构:
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
Run Code Online (Sandbox Code Playgroud)但是,写入/usr/share/glib-2.0/schemas/
需要 root 权限。有没有办法将架构安装到非全局用户目录?