mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-08-12 12:10:27 +00:00
Utility function for checking if a key-combo is bound
This commit is contained in:
@@ -39,3 +39,13 @@ function swapNeighbours() {
|
||||
function showNavigator() {
|
||||
Keybindings.bindkey("<Super>j", () => null, { opensNavigator: true })
|
||||
}
|
||||
|
||||
// listFreeBindings("<super>").join("\n")
|
||||
function listFreeBindings(modifierString) {
|
||||
let free = [];
|
||||
const chars = "abcdefghijklmnopqrstuvxyz1234567890".split("")
|
||||
const symbols = ["minus", "comma", "period", "plus"]
|
||||
return [].concat(chars, symbols).filter(
|
||||
key => Keybindings.getBoundActionId(modifierString+key) === 0
|
||||
).map(key => modifierString+key)
|
||||
}
|
||||
|
||||
@@ -120,6 +120,15 @@ function openNavigatorHandler(actionName, keystr) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function handleAccelerator(display, actionId, deviceId, timestamp) {
|
||||
const action = actionIdMap[actionId];
|
||||
|
||||
Reference in New Issue
Block a user