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

Break colon block chain via command #169

Closed
marcosrdac opened this issue Dec 20, 2019 · 8 comments
Closed

Break colon block chain via command #169

marcosrdac opened this issue Dec 20, 2019 · 8 comments

Comments

@marcosrdac
Copy link

marcosrdac commented Dec 20, 2019

I`m trying to do this: focus at more than one pane with

# focus the node for the given path jump
alt + v : alt + {h,j,k,l,Tab}
	bspc node -f @{west,south,north,east,brother}

And it looks like VIM's visual mode in my head, when I walk through my text (be them nodes). The only thing I dislike my setup is having to Escape in order to end the "visual mode" chain. I would like to send a command like

alt+v; alt+k; alt+k; alt+Return

So that it would: enter visual mode (alt+v), include above node in selection (alt+k), do that again (alt+k), and send the command to open a terminal as big as my current focus/selection (alt+Return).

I tried to xdotool the solution

# focus the node for the given path jump
alt + v : alt + {h,j,k,l,Tab, Return}
	bspc node -f @{west,south,north,east,brother, \
	xdotool key "Escape" && $TERMINAL}

But I read it's not possible to do that. Is there any way I could tell sxhkd to escape the block chain and also open the terminal without me typing Escape? (signalling or sending a proper command would be awesome, but I'm ready for the workarounds!)

I appreciate your attention!

PS.: I'm just obcessed with this software :D

@sawsuh
Copy link

sawsuh commented Dec 21, 2019

When you launch sxhkd, you can specify a chain break key with the '-a' flag. For example, sxhkd -a space allows you to use the space bar to end a chain instead of escape.

@marcosrdac
Copy link
Author

Thanks, @sawsuh. I've read about this option, but that is not exactly what I mean: I want to do some stuff in the colon mode via keypresses (navigate through windows in this case), and some other thing + end colon mode (e.g. opening a terminal and be in normal mode again) with an only key press. I want to skip pressing ESC in this last case, but only here. I means, just, like sending a vim copy command (y) after having selected a block of text with "v".

I know there isn't something like that out of the box for now in sxhkd, but I would like to do that by any indirect, functional way, (e.g. sending ESC automatically before $TERMINAL with a pre xdotool command). I'm interested in any solution like this, because the necessary pre-ESC just pisses me off!

@Lythenas
Copy link

Maybe you can emulate modes using multiple sxhkd instances. And toggle which one is active by sending the USR2 signal which toggles the grabbing state of the the bindings.

@marcosrdac
Copy link
Author

marcosrdac commented Dec 22, 2019

Thanks by your attention, @Lythenas! I must say that I've found the perfect solution when reading @baskerville's code: sending sxhkd SIGALRM tells it to abort its chord chain. Just made a pull request (#170) to the base project, so that people can know it by reading sxhkd's manual.

So, what I do now on my configs, in case anyone is looking for that:

# focus the node for the given path jump
alt + v : alt + {h,j,k,l,Tab}
	bspc node -f @{west,south,north,east,brother}
alt + v : alt + Return
	pkill -ALRM sxhkd; $TERMINAL

And I'm done. Thanks to all of you!

@indeedwatson
Copy link

indeedwatson commented Jan 18, 2020

EDIT okay I found another solution:

# discord
super + Return; {d, @d}
    {tdrop -m -n cordless -f '-e cordless' termite, \
    pkill -ALRM sxhkd}

Original comment:

# focus the node for the given path jump
alt + v : alt + {h,j,k,l,Tab}
	bspc node -f @{west,south,north,east,brother}
alt + v : alt + Return
	pkill -ALRM sxhkd; $TERMINAL

And I'm done. Thanks to all of you!

I thought this could be an answer to this bug: #83 (comment) tried it, and it worked. Then I realized it only worked on one command.

Meaning:

super + Return; r
    redshift_toggle; pkill -ALRM sxhkd

this, and only this case, works, but:

super + Return; d
    tdrop -m -n cordless -f '-e cordless' termite; pkill -ALRM sxhkd

Here it doesn't work, it keeps me in the chain. If I press super + Return, then d, cordless opens, and if I then press r, the redshift_toggle is triggered and the chain is ended.

Perhaps @Lythenas solution is the best, although I still don't understand @baskerville answer here:

When sxhkd receives the initial chord, it has no way of knowing whether it should lock the chain or not.

In my opinion it shouldn't know, it should exit a chain when you tell it to via a command made to exit the chain.

@marcosrdac
Copy link
Author

marcosrdac commented Jan 21, 2020

It's also important to know that the signal is being sent after your "tdrop" command exits. Is it a dropdown terminal? Because if it is, the command is probably not exiting until the dropdown terminal is closed, and therefore (as it never happens) no signal will be sent to sxhkd.

Another good solution would be using "&" instead of ";":

super + Return; d
    tdrop -m -n cordless -f '-e cordless' termite & pkill -ALRM sxhkd

So that "tdrop" runs in background and ALRM is sent to the sxhkd. This tip is useful for any command that isn't run instantaneously.

@indeedwatson
Copy link

You're right, I didn't think of that. Now I'm sad cause I felt so clever with my
last solution :D

@lwilletts
Copy link

Thank you for raising awareness of chords. I've been using sxhkd for a long time now and I didn't know it had this functionality for mimicking i3 modes. Here's a completely WM agnostic way of resizing windows (relies on wmutils)

mod1 + r: {h,j,k,l}
    wrs {-20 0,0 20,0 -20,20 0} $(pfw)
mod1 + r: Escape
    pkill -ALRM sxhkd

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

5 participants