Last active
February 9, 2025 16:01
-
-
Save Opposite34/f3a487d940e9fb968d01f7e30969fbd1 to your computer and use it in GitHub Desktop.
Dwindle (BSPWM, Qtile, Hyprland)-style Tiling Script for GlazeWM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import websockets | |
| import json | |
| async def main(): | |
| uri = "ws://localhost:6123" | |
| async with websockets.connect(uri) as websocket: | |
| await websocket.send("sub -e window_managed") | |
| await websocket.send("sub -e focus_changed") | |
| await websocket.send("sub -e focused_container_moved") | |
| while True: | |
| response = await websocket.recv() | |
| json_response = json.loads(response) | |
| if json_response["messageType"] == "client_response": | |
| print(f"Event subscription: {json_response['success']}") | |
| elif json_response["messageType"] == "event_subscription": | |
| window_data = json_response['data'].get('managedWindow') or json_response['data'].get('focusedContainer') | |
| width = window_data['width'] | |
| height = window_data['height'] | |
| print(f"Width: {width}, Height: {height}") | |
| if width != None and height != None: | |
| if width > height: | |
| await websocket.send('c set-tiling-direction horizontal') | |
| elif width < height: | |
| await websocket.send('c set-tiling-direction vertical') | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have now edited this to check window focused and also to base the tiling direction with width/height instead of just toggling. Thank you ThePhxRises on GlazeWM Discord for bringing attention to this.
It is still not fully correct Dwindle behavior though, since the tiling direction check is still done after an action happens like I previously said (this happens when say you move a window the left window from a
left top-right/down-rightto the right side, it won't be replacing the top-right or the down-right like how Dwindle does.