Closed RomanSC closed 7 years ago
The current mode is not exposed with the IPC, see https://i3wm.org/docs/ipc.html, and so is not available in this library. There is a binding modes reply, which lists the available modes.
An alternative would be to listen to changes in the binding mode. This way, you would be able to store the current binding in a variable based on the most recent change.
That's kind of strange that you can't do that. Open an issue on the i3 project if you would like it added to the ipc.
Thanks for the help. I'll post an issue to i3 so that maybe ipc can get it. I'll use a workaround somehow.
Here's a link to that issue: https://github.com/i3/i3/issues/2711
Airblader says: "You can get the mode (i3bar needs it as well). You just can't query it directly, but there is an event when it changes for which you can listen."
xfce4-i3-workspaces must be using this somehow. I don't know because I can't write C yet. But if you search for mode in that project I think it might be relevent in some way. Line 425-440: https://github.com/denesb/xfce4-i3-workspaces-plugin/blob/master/panel-plugin/i3w-plugin.c
Here are the docs for listening to events
@acrisci Thanks thats making more sense. I understand now I need to do something like:
import i3ipc
i3 = i3ipc.Connection() # starts the socket to listen on
Then create some sort of function to run for when the event happens.
def myfun():
#do something
print("Super fun")
Then do something like:
# listen for events
i3.on('workspace::focus', myfun())
Closing the issue because it's not an issue. I just need to figure out how to listen for an event for mode change and name somehow.
Thanks again.
Hey, thanks for this library. I'm pretty new to programming and CS, having just started writing python recently. So having this library is really awesome because I can write some of my first "real" pieces of software for a WM that I love. Anyway.
Is there a way to get the current mode? I tried dir(i3ipc.Connection()) and have managed to acces the status of workspaces through i3ipc.Connection().get_workspaces()
i3 config example:
mode "resize" {
With vim like bindings
}
Will gladly send you my finished program for example code once it's done. Thanks again.