question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sending an existing Qtile keybinding to another program using qtile.cmd_simulate_keypress() fails

See original GitHub issue

I use a terminal (kitty) with tiling-like support and I’d like to reuse the same keybindings I use in Qtile with the kitty panes. However, Qtile has priority over the keybindings. I’ve managed to disable certain Qtile keybindings whenever a terminal window is focused using this minimal example:

def move_focus(qtile, direction):
    if qtile.current_window.get_wm_class()[0] != 'kitty':
        if direction == 'left':
            qtile.current_group.layout.cmd_left()
    else:
        qtile.cmd_simulate_keypress([MOD], 'h')

keys = [Key([MOD], 'h', lazy.function(move_focus, direction='left'), desc='move focus left')]

However, the key combination still doesn’t get passed through to the terminal. How can I achieve that?

I’ve found other people with a similar issue:

_Originally posted by @raj-magesh in https://github.com/qtile/qtile/discussions/3037_

EDIT:

Okay, going through old Qtile issues, the kitty developer also raised this issue ~8 years ago: https://github.com/qtile/qtile/issues/324

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jwijenberghcommented, Nov 28, 2021

This is indeed what #2925 is for, when that is merged we’re not completely there yet as actual swallowing based on a function’s execution is not implemented. However, #2925 supports swallowing based on the functions .when(...) check. We need to make a separate pr for more .when() checks, such as the wm_class or even arbitrary lazy.functions so if that is merged in a separate pr you can define your keybinding as follows:

Key([MOD], 'h', lazy.layout.left().when(wm_class != 'kitty'), desc='move focus left when kitty is not focused')

If someone wants to take a look at supporting these custom .when() checks, the code needs to be added here. Maybe I will make a pr myself but I’m a bit busy with other issues and prs atm.

1reaction
elParaguayocommented, Nov 19, 2021

No problem at all.

Help is always appreciated if you’re able (there’s help in the docs about how to collaborate if you need some tips) but don’t worry if you don’t have the time.

As you can see, the issue is being looked at so it should get resolved at some point!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default configuration's bindings do not work after a ... - GitHub
Hello, I'm having the same issue as @cr1ogen, just, no keybindings available when error in local config. I can interact with the bar ......
Read more >
Keybindings in images - Qtile Docs
Generate your own images. Qtile provides a tiny helper script to generate keybindings images from a config file. In the repository, the script...
Read more >
Keys — Qtile 0.1.dev50+g1c6a962.d20221218 documentation
Keys¶. The keys variable defines Qtile's key bindings. Individual key bindings are defined with Key as demonstrated in the following example.
Read more >
Scripting Commands - Qtile Docs
Here is documented some of the commands available on objects in the command tree when running qtile shell or scripting commands to qtile....
Read more >
Hacking on Qtile - Qtile Docs
Testing with the X11 backend requires Xephyr (and xvfb for headless mode) in addition to the core dependencies. Building cffi module¶. Qtile ships...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found