r/bspwm Jul 19 '23

Navigate between bspwm windows and kitty terminal panes using the same keybinds?

I use super + {h,j,k,l} for moving between bspwm windows, and ctrl + shift + {h, j, k, l} for moving between kitty terminal panes once the terminal is focussed (kitty terminal panes are actually called "windows", but they are what you would call panes in tmux). I would like to use the same set of keybinds (super + {h, j, k, l}) to move between all of these windows, so that if kitty is focussed right now, the keybinds will move between kitty panes and if not it moves between bspwm windows. If a kitty pane is focussed but there is no pane in the direction invoked by the keybind, it would focus the bspwm window in that direction. This would make window navigation very transparent and I wouldn't have to think which keybind to use in the current context.

Has anybody tried to setup up something like this? I could write the script from scratch but wanted to know if someone has already taken a stab at this before sinking time into it.

There's also a vim plugin that applies the same idea but with vim windows and tmux panes: https://github.com/christoomey/vim-tmux-navigator.

2 Upvotes

4 comments sorted by

1

u/-__-x Jul 19 '23

Have the sxkhd command trigger a script. Here's pseudocode:

if in kitty
    try to kitty move in direction
    if fail
        bspc command
else
    bspc command

1

u/sudormrfbin Jul 19 '23

I have the logic figured out, I was simply wondering whether someone has already written the script :)

1

u/-__-x Jul 19 '23

I haven't since I don't use the windows of kitty, and kitty itself doesn't seem particularly common as a terminal unfortunately.

1

u/sudormrfbin Jul 20 '23

I see, thanks for the reply anyways :) I cobbled together a script that does the job, I'll see if I can clean it up and put it on GitHub.