如何/在哪里创建 GNOME 自定义键绑定覆盖文件?

如何/在哪里创建 GNOME 自定义键绑定覆盖文件?

我一直在尝试使用木偶侏儒创建自定义键盘快捷键,但没有成功。我有以下架构:

class keyboard_shortcuts {
  $schema_root = 'org.gnome.settings-daemon.plugins.media-keys'
  $custom_keybinding_schema = "${schema_root}.custom-keybinding"
  $first_key = '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/'
  $first_schema = "${custom_keybinding_schema}:${first_key}"

  gnome::gsettings { $schema_root:
    schema => $schema_root,
    key    => 'custom-keybindings',
    value  => [
      "'${first_key}'"
    ],
  }

  gnome::gsettings { "${custom_keybinding_schema}_name":
    schema => $first_schema,
    key    => 'name',
    value  => 'Terminal',
  }

  gnome::gsettings { "${custom_keybinding_schema}_command":
    schema => $first_schema,
    key    => 'command',
    value  => '/usr/bin/terminator',
  }

  gnome::gsettings { "${custom_keybinding_schema}_binding":
    schema => $first_schema,
    key    => 'binding',
    value  => '<Ctrl><Alt>T',
  }
}

这将创建以下文件:

$ ls /usr/share/glib-2.0/schemas/25_*
/usr/share/glib-2.0/schemas/25_org.gnome.settings-daemon.plugins.media-keys.custom-keybinding_binding.gschema.override  /usr/share/glib-2.0/schemas/25_org.gnome.settings-daemon.plugins.media-keys.gschema.override
/usr/share/glib-2.0/schemas/25_org.gnome.settings-daemon.plugins.media-keys.custom-keybinding_command.gschema.override  '/usr/share/glib-2.0/schemas/25_Raise window on click.gschema.override'
/usr/share/glib-2.0/schemas/25_org.gnome.settings-daemon.plugins.media-keys.custom-keybinding_name.gschema.override
$ sudo cat /usr/share/glib-2.0/schemas/25_*
[org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/]
  binding = <Ctrl><Alt>T
[org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/]
  command = /usr/bin/terminator
[org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/]
  name = Terminal
[org.gnome.settings-daemon.plugins.media-keys]
  custom-keybindings = ['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']
[org.gnome.desktop.wm.preferences]
  raise-on-click = true

但是,在“键盘”小程序中,我看不到此键盘快捷键。如果我手动创建键盘快捷键并应用清单,它甚至不会删除现有的快捷键。我需要在其他地方创建覆盖吗?我试过了,/usr/share/GConf/gsettings因为那似乎是此类文件更自然的地方,但没有成功。


我还尝试使用digest快捷方式名称中的 而不是custom0。架构编译成功,但仍然不行:

$ strings /usr/share/glib-2.0/schemas/gschemas.compiled | grep custom-keybindings/
/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/514d8a494f087c0d549b9536c2ef3bd9/

相关问题

答案1

看起来你应该使用gsettings。查看这个答案了解详情。

相关内容