Gsettigs和dconf设置热键

时间:2013-01-17 12:29:55

标签: ubuntu global-hotkey

您好我需要在ubuntu 12.10中设置一个热键,我使用

gsettings(dconf)

~$ gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ binding '<Primary><Alt>s'
~$ gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ binding '<Primary><Alt>s'
~$ gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ command 'gnome-terminal'

但是当我看到这个架构时,我只看到

~$ gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings
~$ @as []

但是当我使用dconf查看此架构时

~$ dconf list /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/
binding
command

我做错了什么? 谢谢。

1 个答案:

答案 0 :(得分:2)

您忘记设置父键的值:custom-keybindings类型为@as[]。首先检查它是否为空:

gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings

如果它为空:[],请运行:

gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/']"

如果它不为空,则必须将现有值添加到上述命令中(值必须用单引号括起,并用逗号+空格分隔,如['val1', 'val2', 'val3'])。然后运行:

gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/custom2/ binding '<Primary><Alt>s'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/custom2/ command 'gnome-terminal'