在Gnome中保存自定义键盘快捷键


25

在Debian系统上,我已经通过系统设置>键盘>快捷方式自定义了Gnome(Shell)键盘快捷键。

在哪里可以找到具有这些设置的文件,以便可以将文件复制到闪存驱动器上进行备份,然后使用它替换其他Gnome系统上的键盘快捷键?



Answers:


22

Gnome 3用于DCONF将首选项存储在单个二进制文件中:~/.config/dconf/user
根据Gnome文档,建议仅保存所需的设置,然后使用dconf或恢复gsettings。但是,一次gsettings只能还原单个键的值(加上值必须​​加引号),这对于这种任务来说有点尴尬。这给我们留下了dconf
因此,在这种情况下,请保存gnome-shell键盘快捷键1的当前设置:

dconf dump /org/gnome/shell/keybindings/ > bkp

这是一个bkp示例:

[/]
toggle-message-tray=['<Super>m']
open-application-menu=['<Super>F1']
toggle-application-view=['<Control>F1']
focus-active-notification=['<Super>n']
toggle-recording=['<Control><Shift><Alt>r']

将设置加载到另一个系统上:

dconf load /org/gnome/shell/keybindings/ < bkp

1:WM和媒体密钥快捷方式属于不同的架构:

/org/gnome/desktop/wm/keybindings/
/org/gnome/mutter/keybindings/
/org/gnome/mutter/wayland/keybindings/
/org/gnome/settings-daemon/plugins/media-keys/

注意,dconf 仅转储非默认值,因此如果您运行例如

dconf dump /org/gnome/desktop/wm/keybindings/

并且没有得到任何输出,这意味着没有定义自定义WM快捷方式。


附带说明一下,dconf-editor该工具可帮助可视化dconf设置结构,即schema [:path] key value任何键的类型和默认值等。


记录下来,保存首选项gsettings

gsettings list-recursively org.gnome.shell.keybindings > bkp

bkp 样品:

org.gnome.shell.keybindings focus-active-notification ['<Super>n']
org.gnome.shell.keybindings open-application-menu ['<Super>F1']
org.gnome.shell.keybindings toggle-application-view ['<Super>a']
org.gnome.shell.keybindings toggle-message-tray ['<Super>m']
org.gnome.shell.keybindings toggle-recording ['<Control><Shift><Alt>r']

现在加载首选项(就像我说的那样,对于备份文件中的每一行,您需要一个单独的命令,并且不要忘记引用这些值):

gsettings set org.gnome.shell.keybindings focus-active-notification "['<Super>n']"
gsettings set org.gnome.shell.keybindings open-application-menu "['<Super>F1']"
gsettings set org.gnome.shell.keybindings toggle-application-view "['<Super>a']"
gsettings set org.gnome.shell.keybindings toggle-message-tray "['<Super>m']"
gsettings set org.gnome.shell.keybindings toggle-recording "['<Control><Shift><Alt>r']"

dconf dump /org/gnome/shell/keybindings/ > bkp不适用于Centos7。–
Lucas

抱歉,我试图编辑我的评论,但被堆栈交换阻止。做一个dconf dump /可以帮助显示哪些键可用。在Centos上,我将终端绑定到Ctrl+Alt+T,并显示在中org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0。倾销org/gnome似乎是在Centos 7上备份大多数内容的一种好方法。–
Lucas

对于使用非默认操作的自定义键盘快捷键的任何人:这些都存储/org/gnome/settings-daemon/plugins/media-keys/在下custom-keybindings(例如:我已经定义了一些快捷键,将鼠标指针放在每个屏幕的中央)。
十进制

没有/org/gnome/shell/keybindings/在Fedora 28
阿纳托利techtonik

@don_crissti dconf仅保存修改后的设置,并将其保存在不同的位置。
anatoly techtonik

0

搜索键绑定,如下所示:

gsettings list-recursively | grep keybindings

设置键绑定,如下所示:

org.gnome.desktop.wm.keybindings close "['<Alt>F5']"

请注意,键盘调整重叠绑定会破坏后者。例如,switch-applications-backward ['<Alt><Shift>Tab']将被布局开关覆盖"Left Alt" + "Left Shift",因此['<Left Alt><Left Shift>Tab']将无法正常工作['<Left Alt><Right Shift>Tab']

像这样设置布局切换的键绑定,gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Shift>Alt', '<Super>space']"或者gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift', '<Super>space']"使其不起作用。

希望有人会发现这个有用。

侏儒v3.28.1

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.