The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

How do I correctly qualify event subscriptions with the IPC interface?

asked 2014-12-06 21:47:04 +0000

Adaephon gravatar image

updated 2014-12-08 09:45:32 +0000

Hello everyone,

I am developing a small Python library to communicate with the i3 IPC interface and experience some problems when trying to subscribe to events as described in the official documentation. There the documentation puts the following example for event subscription:

4.1 Subscribing to Events

By sending a message of type SUBSCRIBE with a JSON-encoded array as payload you can register to an event.

Example:

type: SUBSCRIBE
payload: [ "workspace", "focus" ]

I take this to mean that I can specifically subscribe to focus events of workspaces. Why else would I want to add "focus" to the payload.

But it seems that - at least for me - there is no difference in the events received between subscribing to ["workspace", "focus"] or subscribing to just ["workspace"].

I first tried to subscribe to "new window" events by supplying ["window", "new"] as payload to the subcription message. But when doing this, I still received messages for any other window change - "focus", "title" and "fullscreen_mode". This did not seem to be different from subscribing to just ["window"]. Therefore my question:

What am I missing?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-12-06 22:18:21 +0000

Michael gravatar image

Can you clarify which part of the documentation seemed to suggested that?

The truth is that event types are more coarse: the “window” event type simply contains a “change” member that tells you what changed. Both the “"change": "new"” event and the “"change": "focus"” event are of type “window”.

As a rule of thumb: an event type is everything that has a subsection in section “4. Events” in http://i3wm.org/docs/ipc.html

Any further filtering should be done in the application itself.

edit flag offensive delete link more

Comments

Thanks for the quick response. To answer your question: the example in Section 4.1 - `["workspace", "focus"]` - lead me to believe that I could - and maybe even should - subcribe to specific events. I also updated my question accordingly.

Adaephon gravatar imageAdaephon ( 2014-12-08 09:49:24 +0000 )edit

Ok, I did some testing and found that I can subscribe multiple event types at once - for example `["workspace", "window", "mode"]`. So, am I right to assume that `"focus"` is just a typo or possibly a remnant from a time when there was a "focus" event?

Adaephon gravatar imageAdaephon ( 2014-12-08 14:14:53 +0000 )edit
Michael gravatar imageMichael ( 2014-12-13 21:34:10 +0000 )edit

Question Tools

Stats

Asked: 2014-12-06 21:47:04 +0000

Seen: 67 times

Last updated: Dec 08 '14