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
Key Sequences / Key Chords #1208
Comments
Look at my issue #1190, I started doing this. Since opening the issue, I have hacked a bit more to have a widged display when I press something, but since I am about to build my own nixos desktop condiguration, I couldn't document it yet, open a PR here or something like that. But I have created a dotfiles repo containing the qtile config. One thing to remember: I haven't found a way to assign both vim style AND normal/emacs style bindings to the same key. (like using Jfyi the way keychains are stored is a bit ugly right now. I couldn't come up with a good tree-like container to store the variables yet, but I will look into it again when I have a better working desktop.. My goal is to be able to create keychains in the config.py with minimal effort & knowledge, but right now it still includes setting up a root key, a home key, defining the home, etc. Just look at the files KeyChain.py for the feature and keys.py for how to use it in the config. |
Oh, awesome! Thanks, @Melkor333! will take a look once hell (exam) week is over! Just as a first though, have you considered using a |
Yeah I have thought about using a dict and tried some ways to do it. But I wasn't able to come up with a useful way and just wanted to have something that works, so it's probably more of a proof of concept implementation at moment. I am also thinking about a way to programmatically add new shortcuts and modifying them without having to rewrite my configuration file. This would allow for dynamic creation and change of shortcuts. My longterm goal is to create a project/workspace based setup where I have global, project wide, group wide and window wide commands. I don't know how other window managers handle shortcuts exactly, but it would be interesting if it was possible to create a separate tool which is completely independent. As far as I know, there doesn't exist anything like that and if not limited to qtile, there may be more guys interested in using and extending it.. |
That's exactly what I was thinking! Though making it platform independent might be a bit more complex than it seems. I would take inspiration from either Doom Emacs (https://github.com/hlissner/doom-emacs) or Spacemacs(https://github.com/syl20bnr/spacemacs) - personally, I think the community driven nature of Spacemacs has made the key bindings more consistent and mnemonic, and since the |
Actually I only tried spacemacs for a short time before I gave up on it because there were too many random bugs for me. I worked with spacevim for some time tho, so I know about the idea of SPC and it is actually why I wanted to have this concept in qtile, too. But idk what all this stuff like e |
Predefined only in the sane defaults sense. Of course, they could be freely rebound. Nothing as heavy as a full blow DE, no dependencies or anythingike that. More like a simplified way to launch commands from the console without so much typing and some window manager manipulation options for convenience. Kinda like |
That would be great. I3 is doing something similar that i found very useful when i was using it |
I should have a working implementation of this up by the end of next week. Maybe I'll manage to throw in a curses completion thingy as well, but I doubt it. Also, I was thinking of adding an interface to dump keymaps in json, so people can test them out and exchange them. Of course you could still dynamically configure them if you so choose. Thoughts? |
Thank you very much for doing this! What exacty do you mean with curses completion? Something similar to emacs-which-key? And are you trying to merge it directly into qtile or you will it be separate like my implementation? |
No problem man. Time to give back to the FOSS community after all it has done for me (to the extent that I can). I think I will be merging it straight into Qtile because I am depending heavily on their hotkey daemon. After that, I will probably gut it and make it an independent thing as well (and hopefully let someone else maintain it, too much work to do right now) as there is no reason it couldn't be used with any other window manager. Rofi completion sounds awesome, but I don't know enough about it to do anything but use it. After I upload this stuff (gimme another couple of days, I fell sick recently and couldn't work at all) I'd very much appreciate any help. Update: |
I'm also interested in this feature, I can't work with mod+ keys alone, I need something like i3 mode to have my key combinations work in harmony across applications. Without this I can't go any further into qtile, it's a deal breaker for me. |
You can check out my config at Gitlab for a more or less working solution. The file KeyChain.py is imported in the keys.py file where the "modes" as you may call them are defined. If you have any questions to my config, I'll gladly answer them Oh and excuse the mess in the files! 😄 |
@Melkor333 thanks for sharing, at the moment I've put it on hold, but I'll be back at it soon. And no worries about the files 😁 |
Someone really sold the idea of a python twm for me on irc. However this is a dalbreaker as i currently have something similar with i3-modes |
Well it‘s currently not built in but I wrote a class which can do it, as said in my last comment.
|
@Melkor333 For the sake of others xcbq moved to libqtile.backend.x11
Edit:
|
@Melkor333 First, thanks for writing this up! Can you give me (us) a bit more explanation about what is going on here (so I can understand it versus just copy/paste)? For example, what is this doing?
And what does "ishome" do? What is root and Super_R doing here?
Maybe just a nudge in the right direction on understanding what is going on? Thanks in advance! |
@oboingo I reckon the hook is for he to rearrange his keys on the physical keyboard thorugh xmodmap upon startup_once event. The later, as far as I understood, which may be wrong: |
I whipped up something that seems to work, using @Melkor333 's code as a basis. https://gist.github.com/oboingo/67150b907d71dde00130cd2dcabf582c |
I did get this to work, it is in my example config: That being said, I am half way done re-writing it to integrate into Qtile directly (as opposed to being separate). Hopefully it will simplify it some. I am curious though, if it is going in directly... what does everyone like for what we call this? Key Chains? Key Chords? Key Groups? |
On Sat, Apr 25, 2020 at 08:13:56AM -0700, oboingo wrote:
I did get this to work, it is in my example config:
https://github.com/qtile/qtile-examples/blob/master/oboingo/keys.py
That being said, I am half way done re-writing it to integrate into Qtile directly (as opposed to being separate). Hopefully it will simplify it some.
I am curious though, if it is going in directly... what does everyone like for what we call this? Key Chains? Key Chords? Key Groups?
I vote for Key Chords, that's what the keyboard people call this type
of thing. But I'm happy to be overruled :)
|
In my opinion |
PR implements key chords(discussed here #1208) as core qtile functionality. Chords are implemented in two ways: "immediate chord" after enter chord its any subbinding or Escape cause leave chord "mode chord" work more like VIM modes we stay in this mode till Escape key is hit PR implements also widget indicator for "mode chord". Closes #1777
PR implements key chords(discussed here qtile#1208) as core qtile functionality. Chords are implemented in two ways: "immediate chord" after enter chord its any subbinding or Escape cause leave chord "mode chord" work more like VIM modes we stay in this mode till Escape key is hit PR implements also widget indicator for "mode chord". Closes qtile#1777
#1777 has been merged, thanks everyone! It still needs some documentation if anyone wants to help. |
This commit implements a chord stack to keep track of the chord modes that were activated. When exiting a mode, a higher-level chord with the mode attribute is searched for. If found, it is activated. Otherwise the root keybindings are restored. A new command is introduced: cmd_ungrab_all_chords. Unlike before, cmd_ungrab_chord does not directly go to the root mode. This can now be explicitly done with cmd_ungrab_all_chords. Rationale: + emacs-like shortcut sequences have been requested: qtile#1208, qtile#470 + they are available since qtile#1777 (mid-2020), but probably a niche application. Let's see how this develops. + people who wanted this feature (including me) probably gave up and maybe switched to another WM with this functionality, [e.g. this comment](qtile#1208 (comment)). + The functionality this PR provides cannot be achieved with user extensions, as stated in qtile#2241. The hooks are not called in the right places to create a work-around. + The pr was developed and tested extensively with [my config](https://github.com/ep12/qtileconf) (especially `xournal_bindings.py`). I was able to do everything I wanted. Before that I filtered the actions by program, see qtile#1661. With the `xournal` chord/mode I don't need all that complicated stuff. + Combining normal key bindings with custom modes is really quite ideal: the important stuff can be controlled with one keystroke, special stuff is in a separate mode. + The performance impact of this feature enhancement is ~0. + The config breakage impact of this feature is minimal: having `lazy.ungrab_chord()` bound to a key inside two nested `KeyChord`s with `mode` set behaves now differently; a suitable replacement (`lazy.ungrab_all_chords()`) is provided. Furthermore, the current_chord variable is removed as it is not necessary anymore. The linter complained about an else block after a for without a break. This superfluous else was removed.
This commit implements a chord stack to keep track of the chord modes that were activated. When exiting a mode, a higher-level chord with the mode attribute is searched for. If found, it is activated. Otherwise the root keybindings are restored. A new command is introduced: cmd_ungrab_all_chords. Unlike before, cmd_ungrab_chord does not directly go to the root mode. This can now be explicitly done with cmd_ungrab_all_chords. Rationale: + emacs-like shortcut sequences have been requested: #1208, #470 + they are available since #1777 (mid-2020), but probably a niche application. Let's see how this develops. + people who wanted this feature (including me) probably gave up and maybe switched to another WM with this functionality, [e.g. this comment](#1208 (comment)). + The functionality this PR provides cannot be achieved with user extensions, as stated in #2241. The hooks are not called in the right places to create a work-around. + The pr was developed and tested extensively with [my config](https://github.com/ep12/qtileconf) (especially `xournal_bindings.py`). I was able to do everything I wanted. Before that I filtered the actions by program, see #1661. With the `xournal` chord/mode I don't need all that complicated stuff. + Combining normal key bindings with custom modes is really quite ideal: the important stuff can be controlled with one keystroke, special stuff is in a separate mode. + The performance impact of this feature enhancement is ~0. + The config breakage impact of this feature is minimal: having `lazy.ungrab_chord()` bound to a key inside two nested `KeyChord`s with `mode` set behaves now differently; a suitable replacement (`lazy.ungrab_all_chords()`) is provided. Furthermore, the current_chord variable is removed as it is not necessary anymore. The linter complained about an else block after a for without a break. This superfluous else was removed.
This commit implements a chord stack to keep track of the chord modes that were activated. When exiting a mode, a higher-level chord with the mode attribute is searched for. If found, it is activated. Otherwise the root keybindings are restored. A new command is introduced: cmd_ungrab_all_chords. Unlike before, cmd_ungrab_chord does not directly go to the root mode. This can now be explicitly done with cmd_ungrab_all_chords. Rationale: + emacs-like shortcut sequences have been requested: qtile#1208, qtile#470 + they are available since qtile#1777 (mid-2020), but probably a niche application. Let's see how this develops. + people who wanted this feature (including me) probably gave up and maybe switched to another WM with this functionality, [e.g. this comment](qtile#1208 (comment)). + The functionality this PR provides cannot be achieved with user extensions, as stated in qtile#2241. The hooks are not called in the right places to create a work-around. + The pr was developed and tested extensively with [my config](https://github.com/ep12/qtileconf) (especially `xournal_bindings.py`). I was able to do everything I wanted. Before that I filtered the actions by program, see qtile#1661. With the `xournal` chord/mode I don't need all that complicated stuff. + Combining normal key bindings with custom modes is really quite ideal: the important stuff can be controlled with one keystroke, special stuff is in a separate mode. + The performance impact of this feature enhancement is ~0. + The config breakage impact of this feature is minimal: having `lazy.ungrab_chord()` bound to a key inside two nested `KeyChord`s with `mode` set behaves now differently; a suitable replacement (`lazy.ungrab_all_chords()`) is provided. Furthermore, the current_chord variable is removed as it is not necessary anymore. The linter complained about an else block after a for without a break. This superfluous else was removed.
This commit implements a chord stack to keep track of the chord modes that were activated. When exiting a mode, a higher-level chord with the mode attribute is searched for. If found, it is activated. Otherwise the root keybindings are restored. A new command is introduced: cmd_ungrab_all_chords. Unlike before, cmd_ungrab_chord does not directly go to the root mode. This can now be explicitly done with cmd_ungrab_all_chords. Rationale: + emacs-like shortcut sequences have been requested: qtile#1208, qtile#470 + they are available since qtile#1777 (mid-2020), but probably a niche application. Let's see how this develops. + people who wanted this feature (including me) probably gave up and maybe switched to another WM with this functionality, [e.g. this comment](qtile#1208 (comment)). + The functionality this PR provides cannot be achieved with user extensions, as stated in qtile#2241. The hooks are not called in the right places to create a work-around. + The pr was developed and tested extensively with [my config](https://github.com/ep12/qtileconf) (especially `xournal_bindings.py`). I was able to do everything I wanted. Before that I filtered the actions by program, see qtile#1661. With the `xournal` chord/mode I don't need all that complicated stuff. + Combining normal key bindings with custom modes is really quite ideal: the important stuff can be controlled with one keystroke, special stuff is in a separate mode. + The performance impact of this feature enhancement is ~0. + The config breakage impact of this feature is minimal: having `lazy.ungrab_chord()` bound to a key inside two nested `KeyChord`s with `mode` set behaves now differently; a suitable replacement (`lazy.ungrab_all_chords()`) is provided. Furthermore, the current_chord variable is removed as it is not necessary anymore. The linter complained about an else block after a for without a break. This superfluous else was removed.
I was just wondering if there was a way to get Qtile to respond to key sequences /chords such as
C-c C-c
d i w
Further, is it possible to use any of the mod keys alone? E.g. using the
Super
key as a leader key that makes Qtile listen to the sequence to follow until it recognizes one / can't match it to any?If not, I expect I'll finally get down to the "Hacking on Qtile" section of the manual, and start doing so. If that's the case, I'd really appreciate any pointers you guys might have.
Also thinking of implementing an emacs-which-key (https://github.com/justbur/emacs-which-key) kind of popup for when you bug out and forget shortcuts. Any pointers on that are more than welcome as well as I'll probably start working on that regardless of the answer to the above. The same goes for any preferences anyone might have, e.g. curses over GUI (and the case for either).
The text was updated successfully, but these errors were encountered: