Skip to content

Commit e6c7f1b

Browse files
author
Tony Crisci
committed
add all known ipc properties
1 parent 4517612 commit e6c7f1b

File tree

3 files changed

+113
-5
lines changed

3 files changed

+113
-5
lines changed

i3ipc/con.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ class Con:
6767
:vartype window_rect: :class:`Rect <i3ipc.Rect>`
6868
:ivar deco_rect:
6969
:vartype deco_rect: :class:`Rect <i3ipc.Rect>`
70+
:ivar geometry:
71+
:vartype geometry: :class:`Rect <i3ipc.Rect>`
7072
:ivar app_id: (sway only)
7173
:vartype app_id: str
7274
:ivar pid: (sway only)
7375
:vartype pid: int
7476
:ivar gaps: (gaps only)
7577
:vartype gaps: :class:`Gaps <i3ipc.Gaps>`
78+
:ivar representation: (sway only)
79+
:vartype representation: str
80+
:ivar visible: (sway only)
81+
:vartype visible: bool
7682
7783
:ivar ipc_data: The raw data from the i3 ipc.
7884
:vartype ipc_data: dict
@@ -86,7 +92,7 @@ def __init__(self, data, parent, conn):
8692
ipc_properties = [
8793
'border', 'current_border_width', 'floating', 'focus', 'focused', 'fullscreen_mode',
8894
'id', 'layout', 'marks', 'name', 'num', 'orientation', 'percent', 'scratchpad_state',
89-
'sticky', 'type', 'urgent', 'window', 'pid', 'app_id'
95+
'sticky', 'type', 'urgent', 'window', 'pid', 'app_id', 'representation'
9096
]
9197
for attr in ipc_properties:
9298
if attr in data:
@@ -139,12 +145,17 @@ def __init__(self, data, parent, conn):
139145
self.window_title = data['window_properties']['title']
140146

141147
self.rect = Rect(data['rect'])
142-
self.deco_rect = None
143148
if 'window_rect' in data:
144149
self.window_rect = Rect(data['window_rect'])
150+
151+
self.deco_rect = None
145152
if 'deco_rect' in data:
146153
self.deco_rect = Rect(data['deco_rect'])
147154

155+
self.geometry = None
156+
if 'geometry' in data:
157+
self.geometry = Rect(data['geometry'])
158+
148159
self.gaps = None
149160
if 'gaps' in data:
150161
self.gaps = Gaps(data['gaps'])

i3ipc/model.py

+26
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ def __init__(self, data):
1717
self.width = data['width']
1818

1919

20+
class OutputMode:
21+
"""(sway only) A mode for an output
22+
23+
:ivar width: The width of the output in this mode.
24+
:vartype width: int
25+
:ivar height: The height of the output in this mode.
26+
:vartype height: int
27+
:vartype refresh: The refresh rate of the output in this mode.
28+
:vartype refresh: int
29+
"""
30+
def __init__(self, data):
31+
self.width = data['width']
32+
self.height = data['height']
33+
self.refresh = data['refresh']
34+
35+
def __getitem__(self, item):
36+
# for backwards compatability because this used to be a dict
37+
if not hasattr(self, item):
38+
raise KeyError(item)
39+
return getattr(self, item)
40+
41+
@classmethod
42+
def _parse_list(cls, data):
43+
return [cls(d) for d in data]
44+
45+
2046
class Gaps:
2147
"""For forks that have useless gaps, the dimension of the gaps.
2248

i3ipc/replies.py

+74-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .model import Rect
1+
from .model import Rect, OutputMode
22

33

44
class _BaseReply:
@@ -89,6 +89,28 @@ class OutputReply(_BaseReply):
8989
:ivar rect: The rectangle of this output (equals the rect of the output it
9090
is on).
9191
:vartype rect: :class:`Rect`
92+
:ivar make: (sway only)
93+
:vartype make: str
94+
:ivar model: (sway only)
95+
:vartype model: str
96+
:ivar serial: (sway only)
97+
:vartype serial: str
98+
:ivar scale: (sway only)
99+
:vartype scale: float
100+
:ivar transform: (sway only)
101+
:vartype transform: str
102+
:ivar max_render_time: (sway only)
103+
:vartype max_render_time: int
104+
:ivar focused: (sway only)
105+
:vartype focused: bool
106+
:ivar dpms: (sway only)
107+
:vartype dpms: bool
108+
:ivar subpixel_hinting: (sway only)
109+
:vartype subpixel_hinting: str
110+
:ivar modes: (sway only)
111+
:vartype modes: list(:class:`OutputMode`)
112+
:ivar current_mode: (sway only)
113+
:vartype current_mode: :class:`OutputMode`
92114
:ivar ipc_data: The raw data from the i3 ipc.
93115
:vartype ipc_data: dict
94116
"""
@@ -108,11 +130,30 @@ class OutputReply(_BaseReply):
108130
('focused', bool),
109131
('dpms', bool),
110132
('subpixel_hinting', str),
111-
('modes', list),
112-
('current_mode', dict),
133+
('modes', OutputMode._parse_list),
134+
('current_mode', OutputMode),
113135
]
114136

115137

138+
class BarConfigGaps:
139+
"""(sway only) The useless gaps for the bar.
140+
141+
:ivar left: The gap to the left.
142+
:vartype left: int
143+
:ivar right: The gap to the right.
144+
:vartype right: int
145+
:ivar top: The gap on the top.
146+
:vartype top: int
147+
:ivar bottom: The gap on the bottom.
148+
:vartype bottom: int
149+
"""
150+
def __init__(self, data):
151+
self.left = data['left']
152+
self.right = data['right']
153+
self.top = data['top']
154+
self.bottom = data['bottom']
155+
156+
116157
class BarConfigReply(_BaseReply):
117158
"""A reply to the ``GET_BAR_CONFIG`` message with a specified bar id.
118159
@@ -138,19 +179,49 @@ class BarConfigReply(_BaseReply):
138179
:ivar colors: Contains key/value pairs of colors. Each value is a color
139180
code in hex, formatted #rrggbb (like in HTML).
140181
:vartype colors: dict
182+
:ivar tray_padding:
183+
:vartype tray_padding: int
184+
:ivar hidden_state:
185+
:vartype hidden_state: str
186+
:ivar modifier:
187+
:vartype modifier: int
188+
:ivar workspace_min_width:
189+
:vartype workspace_min_width: int
190+
:ivar strip_workspace_numbers:
191+
:vartype strip_workspace_numbers: bool
192+
:ivar strip_workspace_name:
193+
:vartype strip_workspace_name: bool
194+
:ivar gaps: (sway only)
195+
:vartype gaps: :class:`BarConfigGaps`
196+
:ivar bar_height: (sway only)
197+
:vartype bar_height: int
198+
:ivar status_padding: (sway only)
199+
:vartype status_padding: int
200+
:ivar status_edge_padding: (sway only)
201+
:vartype status_edge_padding: int
141202
:ivar ipc_data: The raw data from the i3 ipc.
142203
:vartype ipc_data: dict
143204
"""
144205
_members = [
145206
('id', str),
207+
('tray_padding', int),
208+
('hidden_state', str),
146209
('mode', str),
210+
('modifier', int),
147211
('position', str),
148212
('status_command', str),
149213
('font', str),
150214
('workspace_buttons', bool),
215+
('workspace_min_width', int),
216+
('strip_workspace_numbers', bool),
217+
('strip_workspace_name', bool),
151218
('binding_mode_indicator', bool),
152219
('verbose', bool),
153220
('colors', dict),
221+
('gaps', BarConfigGaps),
222+
('bar_height', int),
223+
('status_padding', int),
224+
('status_edge_padding', int),
154225
]
155226

156227

0 commit comments

Comments
 (0)