mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-08-13 12:40:20 +00:00
Notes: how to check if a key sequence is bound (outside clutter)
This commit is contained in:
@@ -67,7 +67,28 @@ global.display.connect(
|
||||
display, action, deviceId, timestamp)
|
||||
})
|
||||
#+END_SRC
|
||||
** Lookup an keybinding action by a accelerator string
|
||||
~global.display.get_keybinding_action(keycode, mask)~ is simple to use in clutter event handlers since the keycode and mask is readily available. Outside of clutter is harder:
|
||||
|
||||
#+BEGIN_SRC javascript
|
||||
function devirtualizeMask(gdkVirtualMask) {
|
||||
const keymap = Gdk.Keymap.get_default();
|
||||
let [success, rawMask] = keymap.map_virtual_modifiers(gdkVirtualMask);
|
||||
if (!success)
|
||||
throw new Error("Couldn't devirtualize mask " + gdkVirtualMask);
|
||||
return rawMask;
|
||||
}
|
||||
|
||||
function getBoundActionId(keystr) {
|
||||
let [dontcare, keycodes, mask] =
|
||||
Gtk.accelerator_parse_with_keycode(keystr);
|
||||
if(keycodes.length > 1) {
|
||||
throw new Error("Multiple keycodes " + keycodes + " " + keystr);
|
||||
}
|
||||
const rawMask = devirtualizeMask(mask);
|
||||
return global.display.get_keybinding_action(keycodes[0], rawMask);
|
||||
}
|
||||
#+END_SRC
|
||||
* GJS
|
||||
** import system / module system
|
||||
`imports.NAME` reflects the directories and javascript files present in `imports.searchPath`.
|
||||
|
||||
Reference in New Issue
Block a user