Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-recursive mappings ? #2

Closed
adityadesaha opened this issue Oct 4, 2023 · 2 comments
Closed

non-recursive mappings ? #2

adityadesaha opened this issue Oct 4, 2023 · 2 comments

Comments

@adityadesaha
Copy link

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?

@BanchouBoo
Copy link
Owner

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.

@adityadesaha
Copy link
Author

adityadesaha commented Oct 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants