SwaySock

SwaySock is a library for controlling the running Sway process through its IPC interface

You can query the state of the window manager, listen to events, and execute sway commands.