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

Consider adding on_focus to watchers API #2918

Closed
anicolao opened this issue Aug 12, 2020 · 5 comments
Closed

Consider adding on_focus to watchers API #2918

anicolao opened this issue Aug 12, 2020 · 5 comments

Comments

@anicolao
Copy link

Is your feature request related to a problem? Please describe.
I would like to be able to programmatically react to a kitty window being focused.

Describe the solution you'd like
I'm open to anything but the best fit seems to be the --watchers API which already contains resize and close events.

Describe alternatives you've considered
A WINCH signal could be sent to the contained process, but that's already used for resize and no resize will have happened. It'd be strictly more convenient for my purposes but feels like a hack and one that's prone to compatibility issues.

Possibly some window managers are capable of telling you when different windows get focused. But there are a lot of windows and having to watch all focus changes if I'm only interested in some windows seems strictly worse, and only kitty knows which kitty window has focus (though my main goal is to know which os window has focus).

@kovidgoyal
Copy link
Owner

There are already escape codes for focus reporting, which kitty
supports. A bit of googling should get you the details.

@anicolao
Copy link
Author

Should that mean removing --watchers altogether? As resize and close are already things that can be handled via signals.

@kovidgoyal
Copy link
Owner

As I recall, --watchers was added to allow non-co-operating programs to
monitor one another. If that's your use case, sure, it can be added, I
was under the impression you wanted a way for the program running in the
terminal to be notified of focus changes, for which there is already an
escape code.

@anicolao
Copy link
Author

The specific use case is ssh remotehost dtach -a running in kitty windows on multiple computers, as in a pair programming session. When one person changes focus, optionally if others are following them their corresponding kitty window should get focus too.

Possibly dtach could be modified, or bash, but neither is an easy place to add the functionality. A watcher I think would do it but I may not have thought it through. The watcher would work similarly to my resize handler, having to set the titlebar to a unique value, and then issue a launch remote control command to the terminal which would then trigger each client to find the window by title and raise it. Substitution of the window id in remote control could remove some ugliness in both these cases, too (the remote shell doesn't have an easy way to get the window id, as it is different for every client).

@kovidgoyal
Copy link
Owner

I dont quite follow your use case, but if you feel you need focus
events, I have no objection to adding them to watchers. I'll get around
to it when I have some time, or patches are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants