Cha*_*May 32 gnome keyboard-shortcuts gnome-shell gnome3 dconf
在我的 Debian 系统上,我通过系统设置 > 键盘 > 快捷键自定义了我的 Gnome (Shell) 键盘快捷键。
我在哪里可以找到具有这些设置的文件,以便我可以将文件复制到闪存驱动器上进行备份,然后使用它来替换其他 Gnome 系统上的键盘快捷键?
don*_*sti 29
Gnome 3 用于DCONF将首选项存储在单个二进制文件中:~/.config/dconf/user.
根据 Gnome 文档,建议仅保存您需要的设置并使用dconf或恢复它们gsettings。但是,一次gsettings只能恢复一个键的值(另外,必须引用该值),这使得这种任务有点尴尬。这给我们留下了dconf.
因此,在这种特殊情况下,请保存gnome-shell键盘快捷键1的当前设置:
dconf dump /org/gnome/shell/keybindings/ > bkp
Run Code Online (Sandbox Code Playgroud)
这是一个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']
Run Code Online (Sandbox Code Playgroud)
在另一个系统上加载设置:
dconf load /org/gnome/shell/keybindings/ < bkp
Run Code Online (Sandbox Code Playgroud)
1:WM 和 Media Keys 快捷键属于不同的模式:
/org/gnome/desktop/wm/keybindings/
/org/gnome/mutter/keybindings/
/org/gnome/mutter/wayland/keybindings/
/org/gnome/settings-daemon/plugins/media-keys/
Run Code Online (Sandbox Code Playgroud)
请注意,dconf 仅转储非默认值,因此如果您运行例如
dconf dump /org/gnome/desktop/wm/keybindings/
Run Code Online (Sandbox Code Playgroud)
并且没有得到任何输出,这意味着没有定义自定义 WM 快捷方式。
作为旁注,dconf-editor是一种帮助可视化dconf设置结构的工具,即schema [:path] key value任何键的类型和默认值等。
作为记录,使用以下命令保存首选项gsettings:
gsettings list-recursively org.gnome.shell.keybindings > bkp
Run Code Online (Sandbox Code Playgroud)
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']
Run Code Online (Sandbox Code Playgroud)
现在加载首选项(正如我所说,对于备份文件中的每一行,您需要一个单独的命令并且不要忘记引用这些值):
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']"
Run Code Online (Sandbox Code Playgroud)
您可以使用dconf以下命令保存/备份/导出自定义快捷键/键绑定sed
dconf dump / | sed -n '/\[org.gnome.settings-daemon.plugins.media-keys/,/^$/p' > custom-shortcuts.conf # Export
Run Code Online (Sandbox Code Playgroud)
与通常答案的不同之处在于,这将保留文件中 dconf 设置的路径,使其更容易导入,只需dconf load / < file.
dconf load / < custom-shortcuts.conf # Import
Run Code Online (Sandbox Code Playgroud)
仅适用于添加的自定义快捷方式
请注意,dconf仅转储非默认值
要备份,您可能需要使用custom-shortcuts-$(date -I).conf
通过在导入前重置为默认值来测试它是否有效
gsettings reset-recursively org.gnome.settings-daemon.plugins.media-keys
Run Code Online (Sandbox Code Playgroud)