BanchouBoo / lucky

Lua-configured input daemon for X

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

non-recursive mappings ?

adityadesaha opened this issue · comments

First of all, I do appreciate the work you've put in for lucky, I believe it has great potential.
I would like to map ctrl+w to ctrl+Backspace in Firefox (which I can do right now), but I would like to map ctrl+x to ctrl+w in Firefox, in order to close the current tab. This I cannot do right now, since If I'm doing lucky.cmd('xdotool', 'key', '--clearmodifiers', 'ctrl+w'), then lucky intercepts that, and I'm stuck in an infinite loop. How can I get out of it?

commented

Sending keystrokes like this is something I'd eventually like to support directly in lucky which would hopefully be done in a way that would circumvent these issues entirely, but for now there should still be a way to work around it using filters. For example:

local firefox_ctrl_x = false

lucky.bind('ctrl+x', {
    filter = function(wid)
        return lucky.get_class(wid) == "firefox"
    end,
    press = function()
        firefox_ctrl_x = true
        lucky.cmd('xdotool', 'key', '--clearmodifiers', 'ctrl+w')
    end
})

lucky.bind('ctrl+w', {
    filter = function(wid)
        if firefox_ctrl_x then
            firefox_ctrl_x = false
            return false
        end
        return lucky.get_class(wid) == "firefox"
    end,
    press = function()
        lucky.cmd('xdotool', 'key', '--clearmodifiers', 'ctrl+Backspace')
    end
})

If you run into any issues with this approach let me know, I haven't tested this example myself.