下面的场景假设我们启动了计算机并在登录菜单中以用户 bort 的身份登录。这是在 14.04.2。
如果我打开一个终端,作为用户 bort,我可以列出一个 dconf 设置,例如
$ dconf read /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode
0
Run Code Online (Sandbox Code Playgroud)
如果我使用 dconf write 将值更改为 1,屏幕左侧的菜单将被隐藏
$ dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1
$ dconf read /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode
1
Run Code Online (Sandbox Code Playgroud)
现在菜单被隐藏了。现在假设我使用 dconf write 将其设置回 0。菜单将再次出现。
现在,如果我以 root 用户身份在一个终端中并尝试使用 su bort -c 更改 bort 的值,我可以更改它。我知道这一点,因为在我是用户 bort 的另一个终端中,我可以使用 dconf read 并看到该值已更改为 1。因此该值已更改但屏幕左侧的菜单仍然可见。如何使更改实际应用而不是仅在 dconf 数据库中更新?最终,我想知道这与 Puppet 的 exec 类型一起使用,但是能够以 root 身份从终端执行此操作将有助于实现该目标。
在终端中以 root 身份:
# su bort -c "/bin/sh -c '/usr/bin/dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1'"
Run Code Online (Sandbox Code Playgroud)
运行上一个命令后在终端中作为 bort :
$ dconf read /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode
1
Run Code Online (Sandbox Code Playgroud)
然而菜单还在那里。我知道此类问题在此站点上有一些答案,例如使用 dbus-launch 但这对我不起作用。也许它是特定于 …