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

Key chords or modes #552

Open
VoltaireNoir opened this issue Jan 7, 2024 · 3 comments
Open

Key chords or modes #552

VoltaireNoir opened this issue Jan 7, 2024 · 3 comments

Comments

@VoltaireNoir
Copy link

This might come across as a noob question but I tried looking in the man pages and searching in the issues as well, but I can't find info on whether it's possible to define key chords or modes in the keybindings config.

An example would be: MOD + O + B -> launches firefox, MOD + O + F -> launches file manager.
This is possible with sxhkd, but this feature is built into WM's such as xmonad and qtile.

Does spectrwm natively support this? If not, is there any chance that this might be supported in the future?

@c0dev0id
Copy link
Contributor

c0dev0id commented Jan 8, 2024

No, key choards are currently not possible.

I'm sort of working around this with dmenu launchers.

Bind this to MOD+O

#!/bin/sh
S=$(printf "B_Firefox\nV_Gvim\nT_Terminal" | dmenu -p Mod)
case $S in
    B*) firefox & ;;
    V*) gvim & ;;
    T*) xterm & ;;
esac

Then it's MOD-O B Enter

Or for the first Entry just MOD+O Enter

It's not perfect, but it does the job.

EDIT: Or maybe have sxhkd running in the background as well... I haven't tried, but I don't see why it wouldn't work.

@VoltaireNoir
Copy link
Author

No, key choards are currently not possible.

I'm sort of working around this with dmenu launchers.

Bind this to MOD+O

#!/bin/sh
S=$(printf "B_Firefox\nV_Gvim\nT_Terminal" | dmenu -p Mod)
case $S in
    B*) firefox & ;;
    V*) gvim & ;;
    T*) xterm & ;;
esac

Then it's MOD-O B Enter

Or for the first Entry just MOD+O Enter

It's not perfect, but it does the job.

EDIT: Or maybe have sxhkd running in the background as well... I haven't tried, but I don't see why it wouldn't work.

Thank you for the response. I am indeed using sxhkd but only for the key chords like keybindings and nothing else. Which is why I was wondering if I can just use spectrwm's keybindings instead so that I don't have to run another process for this alone.

Your solution is actually quite good. I might actually switch to this and remove sxhkd. Thank you.

@molchknolle
Copy link

I have the following in my spectrwm.conf for when I feel like typing on my Model M, which doesn't have super keys. Maybe something similar would also work for you:

program[chord] = xdotool keydown --delay 500 super keyup super
bind[chord] = Control+odiaeresis

It uses xdotool to simulate the super key being pressed and then being lifted again after half a second, so there is time enough to trigger any binding inbetween. Typing C-ö p would for instance be translated into super+p, and so on.

You could also make a binding to just send the keydown event and then have the keyup part as a separate binding, giving you the equivalent of a dedicated mode. (umm don't try this without first defining the keyup-binding though, or you could get stuck with nothing but your super bindings available... :D )

Probably it should also be possible to have a whole range of such "leaders" or "modes", for example by having key combinations that make xdotool send ctrl+super or even super+hyper and then have various bindings in your spectrwm.conf starting with those combinations of modifiers.

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

3 participants