hyprpy icon indicating copy to clipboard operation
hyprpy copied to clipboard

Dispatchers

Open mbpowers opened this issue 2 years ago • 3 comments

I'm here to show interest in dispatchers being added.

I was thinking a good start might be adding a instance.dispatch() that takes in a string using the same syntax as hyprctl. This would allow users to access all dispatchers whether or not hyprpy has them implemented yet.

If this plan sounds good and I have time I may shoot over a PR.

mbpowers avatar Nov 18 '23 19:11 mbpowers

Hey @mbpowers, apologies for the late reply, life got in the way. That sounds like a great start, feel free to implement and shoot it over if you are still interested in this! Would be much appreciated.

ulinja avatar Dec 16 '23 14:12 ulinja

no worries at all, just got some free time myself :] #12

mbpowers avatar Dec 16 '23 20:12 mbpowers

The proposed instance.dispatch() method was merged as of 82acd79, which allows sending generic disptachers to the hyprland instance:

from hyprpy import Hyprland

instance = Hyprland()
most_recent_window = instance.get_windows()[-1]
instance.dispatch(["closewindow", f"address:{most_recent_window.address}"]) # Closes the window

I'd love to flesh out dispatchers more in the future, such that the above example becomes:

from hyprpy import Hyprland

instance = Hyprland()
most_recent_window = instance.get_windows()[-1]
most_recent_window.close() # Closes the window

I currently don't have much time to implement this myself, so any help would be greatly appreciated if anyone's interested!

ulinja avatar May 11 '24 11:05 ulinja