bash 如何使用 gconftool-2 创建/删除 gconf 目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5421337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 23:40:21  来源:igfitidea点击:

How to create/delete gconf directory with gconftool-2?

bashsshgnomegnome-terminalgconf

提问by Alexander Sandler

... ughm ... the subject?

......呃......主题?

I am writing a script that will create gnome-terminal profiles for various machines that I want to connect to. I need a custom command to run on each terminal and profile is ideal solution for the problem. The script should do various modifications to the gnome-terminal profiles. Each profile has a directory in gconf. I want to be able to create and delete these directories from command line. Any idea how to do it?

我正在编写一个脚本,该脚本将为我想要连接的各种机器创建 gnome-terminal 配置文件。我需要在每个终端上运行一个自定义命令,而配置文件是该问题的理想解决方案。该脚本应该对 gnome-terminal 配置文件进行各种修改。每个配置文件在 gconf 中都有一个目录。我希望能够从命令行创建和删除这些目录。知道怎么做吗?

回答by gpoo

You can use:

您可以使用:

$ gconftool-2 --recursive-unset /apps/gnome-terminal/foo/bar

for unset everything from foo/bar in gnome-terminal.

用于在 gnome-terminal 中取消 foo/bar 中的所有内容。

Another alternative is to use an XML file with the keys you would like to change/unset, and use:

另一种选择是使用带有您想要更改/取消设置的键的 XML 文件,并使用:

$ gconftool-2 --unload clean-settings.xml

and later:

然后:

$ gconftool-2 --load new-settings.xml

However, I do not think you need to "delete" or "unset" anything. My recommendation is:

但是,我认为您不需要“删除”或“取消设置”任何内容。我的建议是:

  1. Customize gnome-terminal as you need it.
  2. Export the settings using:

    $ gconftool-2 --dump /apps/gnome-terminal > my-gnome-terminal-settings.xml

  3. Copy the files (or use whatever mechanisms for working with your remotes machines) and in your remote machine run:

    $ gconftool-2 --load my-gnome-terminal-settings.xml

  1. 根据需要自定义 gnome-terminal。
  2. 使用以下方法导出设置:

    $ gconftool-2 --dump /apps/gnome-terminal > my-gnome-terminal-settings.xml

  3. 复制文件(或使用任何用于远程机器的机制)并在远程机器中运行:

    $ gconftool-2 --load my-gnome-terminal-settings.xml

回答by Eugene Burmako

You can create/delete appropriate directories inside "~/.gconf" and then restart gconfd by executing gconftool-2 --shutdownfollowed by gconftool-2 --spawn. This will flush gconf caches and will apply your settings right away.

您可以在“~/.gconf”中创建/删除适当的目录,然后通过执行gconftool-2 --shutdown后跟gconftool-2 --spawn. 这将刷新 gconf 缓存并立即应用您的设置。

回答by Alexander Sandler

Apparently you can't do that directly. Instead, deleting contents of the directory deletes it. The problem is that, as it seems, gconf and friends implement some sort of settings caching. As a result, it takes some time until you see that directory is actually gone. Sometimes it is immediately, but more often you have to wait few minutes or even relogin. I could not identify what exactly takes for gconf to refresh it's directory structure.

显然你不能直接做到这一点。相反,删除目录的内容会删除它。问题是,看起来,gconf 和朋友实现了某种设置缓存。因此,您需要一些时间才能看到该目录实际上已消失。有时它是立即的,但更多时候您必须等待几分钟甚至重新登录。我无法确定 gconf 究竟需要什么来刷新它的目录结构。

回答by Erigami

To create a new directory with gconf-editor, find the parent of the dir you want, then create a new key of the form <directory-name>/key. That creates the dir for you.

要使用 新建目录gconf-editor,请找到所需目录的父目录,然后创建形式为 的新键<directory-name>/key。这将为您创建目录。

I assume you can do the same implicit creation with gconftool-2.

我假设您可以使用gconftool-2.