adamharmansky / showkeys

Keybind popup like in awesomewm
MIT License
64 stars 1 forks source link

Request: Compatibility with tmux. #3

Open apisandipas opened 2 years ago

apisandipas commented 2 years ago

Currently, when running a program in a tmux pane, the program is not detected by showkeys. I'm currently looking into how one could parse out the name of the currently selected Tmux pane, but to no avail so far.

adamharmansky commented 2 years ago

Thanks for the feedback! I am not a tmux user so I didn't notice this. I'll have a look at how tmux works and see if I can come up with something.

apisandipas commented 2 years ago

I was taking a look at tmux's API. It appears I can get a list of panes, but it only shows their ID. If this can be solved with bash alone, I can possible help with a solution, but my C is rubbish.

adamharmansky commented 2 years ago

I have been looking through the manual and found that tmux ls has a lot of useful options. For example, `tmux ls -F '#W' gives me the following list:

vim
bash

The problem is that the client_pid variable (tmux manpage line 2565) seems to be empty.

adamharmansky commented 2 years ago

If this can be solved with bash alone, I can possible help with a solution, but my C is rubbish.

Yes, it definitely can. The way the program works now is that it calls a long shell command (located at the end of config.h) that checks whether to display the list of keys for the program or not. I will probably re-do this at some point though.

adamharmansky commented 2 years ago

I've just optimized the way programs are detected, so make sure to check the latest commit. (still no tmux, but I think I'm close)

adamharmansky commented 2 years ago

Alright, I think I've font something: The following command returns the command running on latest active session:

tmux ls -F '#W #{window_activity}' | sort -k 2 | tail -n 1 | awk '{print $1}'

It's not 100% accurate, but it should work. I'll just need to integrate it into the program_list script.

adamharmansky commented 2 years ago

I am not quite sure what I've done but it seems to work. However, it recognizes ranger as python3, so there is still a lot of room for improvement. I'll leave this thread open if anyone has any suggestions.