Gsettigs and dconf to set hotkey

南楼画角 提交于 2019-12-12 13:50:52

问题


Hello
I need to set a hotkey in ubuntu 12.10, i use

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'

but when i watch this schema i just see

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

but when i use dconf to see this schema

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

what i am doing wrong? Thank you.


回答1:


You forgot to set the value for the parent key: custom-keybindings which is of type @as[]. First check if it's empty with:

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

If it's empty: [] , run:

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

If it's not empty you will have to add the existing values to the above command (values must be surrounded by single quotes and separated by comma + space, like ['val1', 'val2', 'val3']). And then run:

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'


来源:https://stackoverflow.com/questions/14379164/gsettigs-and-dconf-to-set-hotkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!