-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Description
Documentation here gives one example which works perfectly, however...
https://i3ipc-python.readthedocs.io/en/latest/#listening-to-events
There's no actual list that I've been able to find telling me what events I can listen for. I'm refering to the first argument in i3ipc.on('workspace::focus', on_workspace_focus)
i3.on('workspace::focus', on_workspace_focus) # when current workspace changes
With my code below all three of the following don't appear to do anything but they exist (really they certainly do 'something' I just haven't figured it out yet):
i3.on("mode::change", on_mode_changed) # ???
i3.on("binding::mode", on_mode_changed) # ???
i3.on("mode::binding", on_mode_changed) # ???
import i3ipc
i3 = i3ipc.Connection()
# # Define a callback to be called when you switch workspaces.
# def on_workspace_focus(self, e):
# # The first parameter is the connection to the ipc and the second is an object
# # with the data of the event sent from i3.
# if e.current:
# print('Windows on this workspace:')
# for w in e.current.leaves():
# print(w.name)
# # Dynamically name your workspaces after the current window class
# def on_window_focus(i3, e):
# focused = i3.get_tree().find_focused()
# ws_name = "%s:%s" % (focused.workspace().num, focused.window_class)
# i3.command('rename workspace to "%s"' % ws_name)
# Subscribe to events
# i3.on('workspace::focus', on_workspace_focus)
# i3.on("window::focus", on_window_focus)
# Start the main loop and wait for events to come in.
# i3.main()
def on_mode_changed(self, obj):
if obj.current:
print(obj.data)
print(obj.data.name)
print(dir(obj))
def on_workspace_changed(self, obj):
if obj.current:
print(obj.current.name)
# for x in obj.current:
# print(x)
i3.on("mode::change", on_mode_changed)
i3.on("binding::mode", on_mode_changed)
i3.on("mode::binding", on_mode_changed)
i3.on("workspace::focus", on_workspace_changed)
i3.main()
If the documentation simply listed all possible events I could just test and find out myself, what they do:
import i3ipc
i3 = i3ipc.Connection()
def test_event(self, obj):
# self contains everything in the global
# scope including i3
print(dir(obj))
i3.on("workspace::focus", test_event) # returns an object
i3.main()
If I can get a list I would like to help improve documentation if possible.
Thanks
hlecuanda and dsifford
Metadata
Metadata
Assignees
Labels
No labels