如何/在哪裡建立 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快捷方式名稱的 a 而不是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.查看這個答案了解詳情。

相關內容