Skip to content

Commit 8947b9f

Browse files
author
Tony Crisci
committed
add raw ipc data to classes
1 parent 881ddef commit 8947b9f

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

i3ipc/aio/connection.py

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class Con(con.Con):
123123
:vartype pid: int
124124
:ivar gaps: (gaps only)
125125
:vartype gaps: :class:`Gaps <i3ipc.Gaps>`
126+
127+
:ivar ipc_data: The raw data from the i3 ipc.
128+
:vartype ipc_data: dict
126129
"""
127130

128131
async def command(self, command: str) -> List[CommandReply]:

i3ipc/con.py

+4
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ class Con:
7373
:vartype pid: int
7474
:ivar gaps: (gaps only)
7575
:vartype gaps: :class:`Gaps <i3ipc.Gaps>`
76+
77+
:ivar ipc_data: The raw data from the i3 ipc.
78+
:vartype ipc_data: dict
7679
"""
7780

7881
def __init__(self, data, parent, conn):
82+
self.ipc_data = data
7983
self._conn = conn
8084
self.parent = parent
8185

i3ipc/events.py

+29
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ class WorkspaceEvent(IpcBaseEvent):
6262
:ivar old: When the change is "focus", an old (object) property will be
6363
present with the previous workspace if it exists.
6464
:vartype old: :class:`Con` or :class:`None`
65+
:ivar ipc_data: The raw data from the i3 ipc.
66+
:vartype ipc_data: dict
6567
"""
6668

6769
def __init__(self, data, conn, _Con=con.Con):
70+
self.ipc_data = data
6871
self.change = data['change']
6972
self.current = None
7073
self.old = None
@@ -84,9 +87,12 @@ class OutputEvent(IpcBaseEvent):
8487
8588
:ivar change: The type of change (currently only "unspecified").
8689
:vartype change: str
90+
:ivar ipc_data: The raw data from the i3 ipc.
91+
:vartype ipc_data: dict
8792
"""
8893

8994
def __init__(self, data):
95+
self.ipc_data = data
9096
self.change = data['change']
9197

9298

@@ -100,9 +106,12 @@ class ModeEvent(IpcBaseEvent):
100106
:ivar pango_markup: Whether pango markup should be used for displaying this
101107
mode.
102108
:vartype pango_markup: bool
109+
:ivar ipc_data: The raw data from the i3 ipc.
110+
:vartype ipc_data: dict
103111
"""
104112

105113
def __init__(self, data):
114+
self.ipc_data = data
106115
self.change = data['change']
107116
self.pango_markup = data.get('pango_markup', False)
108117

@@ -117,9 +126,12 @@ class WindowEvent(IpcBaseEvent):
117126
:ivar change: The type of change.
118127
:vartype change: str
119128
:ivar container: The window's parent container.
129+
:ivar ipc_data: The raw data from the i3 ipc.
130+
:vartype ipc_data: dict
120131
"""
121132

122133
def __init__(self, data, conn, _Con=con.Con):
134+
self.ipc_data = data
123135
self.change = data['change']
124136
self.container = _Con(data['container'], None, conn)
125137

@@ -150,6 +162,8 @@ class BarconfigUpdateEvent(IpcBaseEvent, BarConfigReply):
150162
:ivar colors: Contains key/value pairs of colors. Each value is a color
151163
code in hex, formatted #rrggbb (like in HTML).
152164
:vartype colors: dict
165+
:ivar ipc_data: The raw data from the i3 ipc.
166+
:vartype ipc_data: dict
153167
"""
154168
pass
155169

@@ -172,9 +186,12 @@ class BindingInfo:
172186
:ivar input_type: This will be "keyboard" or "mouse" depending on whether
173187
or not this was a keyboard or a mouse binding.
174188
:vartype input_type: str
189+
:ivar ipc_data: The raw data from the i3 ipc.
190+
:vartype ipc_data: dict
175191
"""
176192

177193
def __init__(self, data):
194+
self.ipc_data = data
178195
self.command = data['command']
179196
self.event_state_mask = data.get('event_state_mask', [])
180197
self.input_code = data['input_code']
@@ -196,9 +213,12 @@ class BindingEvent(IpcBaseEvent):
196213
:vartype change: str
197214
:ivar binding: Contains details about the binding that was run.
198215
:vartype binding: :class:`BindingInfo <i3ipc.BindingInfo>`
216+
:ivar ipc_data: The raw data from the i3 ipc.
217+
:vartype ipc_data: dict
199218
"""
200219

201220
def __init__(self, data):
221+
self.ipc_data = data
202222
self.change = data['change']
203223
self.binding = BindingInfo(data['binding'])
204224

@@ -211,9 +231,12 @@ class ShutdownEvent(IpcBaseEvent):
211231
212232
:ivar change: The type of change.
213233
:vartype change: str
234+
:ivar ipc_data: The raw data from the i3 ipc.
235+
:vartype ipc_data: dict
214236
"""
215237

216238
def __init__(self, data):
239+
self.ipc_data = data
217240
self.change = data['change']
218241

219242

@@ -229,9 +252,12 @@ class TickEvent(IpcBaseEvent):
229252
i3 (<=4.15).
230253
:ivar payload: The payload that was sent with the tick.
231254
:vartype payload: str
255+
:ivar ipc_data: The raw data from the i3 ipc.
256+
:vartype ipc_data: dict
232257
"""
233258

234259
def __init__(self, data):
260+
self.ipc_data = data
235261
# i3 didn't include the 'first' field in 4.15. See i3/i3#3271.
236262
self.first = data.get('first', None)
237263
self.payload = data['payload']
@@ -244,8 +270,11 @@ class InputEvent(IpcBaseEvent):
244270
:vartype change: str
245271
:ivar input: Information about the input that changed.
246272
:vartype input: :class:`InputReply <i3ipc.InputReply>`
273+
:ivar ipc_data: The raw data from the i3 ipc.
274+
:vartype ipc_data: dict
247275
"""
248276

249277
def __init__(self, data):
278+
self.ipc_data = data
250279
self.change = data['change']
251280
self.input = InputReply(data['input'])

i3ipc/replies.py

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
class _BaseReply:
55
def __init__(self, data):
6+
self.ipc_data = data
67
for member in self.__class__._members:
78
value = data.get(member[0], None)
89
if value is not None:
@@ -24,6 +25,8 @@ class CommandReply(_BaseReply):
2425
:vartype success: bool
2526
:ivar error: A human-readable error message.
2627
:vartype error: str or :class:`None` if no error message was set.
28+
:ivar ipc_data: The raw data from the i3 ipc.
29+
:vartype ipc_data: dict
2730
"""
2831
_members = [
2932
('success', bool),
@@ -55,6 +58,8 @@ class WorkspaceReply(_BaseReply):
5558
:vartype rect: :class:`Rect`
5659
:ivar output: The video output this workspace is on (LVDS1, VGA1, ...).
5760
:vartype output: str
61+
:ivar ipc_data: The raw data from the i3 ipc.
62+
:vartype ipc_data: dict
5863
"""
5964
_members = [
6065
('num', int),
@@ -84,6 +89,8 @@ class OutputReply(_BaseReply):
8489
:ivar rect: The rectangle of this output (equals the rect of the output it
8590
is on).
8691
:vartype rect: :class:`Rect`
92+
:ivar ipc_data: The raw data from the i3 ipc.
93+
:vartype ipc_data: dict
8794
"""
8895
_members = [
8996
('name', str),
@@ -131,6 +138,8 @@ class BarConfigReply(_BaseReply):
131138
:ivar colors: Contains key/value pairs of colors. Each value is a color
132139
code in hex, formatted #rrggbb (like in HTML).
133140
:vartype colors: dict
141+
:ivar ipc_data: The raw data from the i3 ipc.
142+
:vartype ipc_data: dict
134143
"""
135144
_members = [
136145
('id', str),
@@ -161,6 +170,8 @@ class VersionReply(_BaseReply):
161170
:vartype human_readable: str
162171
:ivar loaded_config_file_name: The current config path.
163172
:vartype loaded_config_file_name: str
173+
:ivar ipc_data: The raw data from the i3 ipc.
174+
:vartype ipc_data: dict
164175
"""
165176
_members = [
166177
('major', int),
@@ -179,6 +190,8 @@ class ConfigReply(_BaseReply):
179190
:ivar config: A string containing the config file as loaded by i3 most
180191
recently.
181192
:vartype config: str
193+
:ivar ipc_data: The raw data from the i3 ipc.
194+
:vartype ipc_data: dict
182195
"""
183196
_members = [
184197
('config', str),
@@ -192,6 +205,8 @@ class TickReply(_BaseReply):
192205
193206
:ivar success: Whether the tick succeeded.
194207
:vartype success: bool
208+
:ivar ipc_data: The raw data from the i3 ipc.
209+
:vartype ipc_data: dict
195210
"""
196211
_members = [
197212
('success', bool),
@@ -222,6 +237,8 @@ class InputReply(_BaseReply):
222237
:vartype xkb_active_layout_index: int
223238
:ivar libinput: (Only libinput devices) An object describing the current device settings.
224239
:vartype libinput: dict
240+
:ivar ipc_data: The raw data from the i3 ipc.
241+
:vartype ipc_data: dict
225242
"""
226243
_members = [
227244
('identifier', str),
@@ -251,6 +268,8 @@ class SeatReply(_BaseReply):
251268
:vartype focus: int
252269
:ivar devices: An array of input devices that are attached to the seat.
253270
:vartype devices: list(:class:`InputReply`)
271+
:ivar ipc_data: The raw data from the i3 ipc.
272+
:vartype ipc_data: dict
254273
"""
255274
_members = [('name', str), ('capabilities', int), ('focus', int),
256275
('devices', InputReply._parse_list)]

0 commit comments

Comments
 (0)