Skip to content

Commit

Permalink
add all known ipc properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Crisci committed Mar 22, 2020
1 parent 4517612 commit e6c7f1b
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 5 deletions.
15 changes: 13 additions & 2 deletions i3ipc/con.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ class Con:
:vartype window_rect: :class:`Rect <i3ipc.Rect>`
:ivar deco_rect:
:vartype deco_rect: :class:`Rect <i3ipc.Rect>`
:ivar geometry:
:vartype geometry: :class:`Rect <i3ipc.Rect>`
:ivar app_id: (sway only)
:vartype app_id: str
:ivar pid: (sway only)
:vartype pid: int
:ivar gaps: (gaps only)
:vartype gaps: :class:`Gaps <i3ipc.Gaps>`
:ivar representation: (sway only)
:vartype representation: str
:ivar visible: (sway only)
:vartype visible: bool
:ivar ipc_data: The raw data from the i3 ipc.
:vartype ipc_data: dict
Expand All @@ -86,7 +92,7 @@ def __init__(self, data, parent, conn):
ipc_properties = [
'border', 'current_border_width', 'floating', 'focus', 'focused', 'fullscreen_mode',
'id', 'layout', 'marks', 'name', 'num', 'orientation', 'percent', 'scratchpad_state',
'sticky', 'type', 'urgent', 'window', 'pid', 'app_id'
'sticky', 'type', 'urgent', 'window', 'pid', 'app_id', 'representation'
]
for attr in ipc_properties:
if attr in data:
Expand Down Expand Up @@ -139,12 +145,17 @@ def __init__(self, data, parent, conn):
self.window_title = data['window_properties']['title']

self.rect = Rect(data['rect'])
self.deco_rect = None
if 'window_rect' in data:
self.window_rect = Rect(data['window_rect'])

self.deco_rect = None
if 'deco_rect' in data:
self.deco_rect = Rect(data['deco_rect'])

self.geometry = None
if 'geometry' in data:
self.geometry = Rect(data['geometry'])

self.gaps = None
if 'gaps' in data:
self.gaps = Gaps(data['gaps'])
Expand Down
26 changes: 26 additions & 0 deletions i3ipc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ def __init__(self, data):
self.width = data['width']


class OutputMode:
"""(sway only) A mode for an output
:ivar width: The width of the output in this mode.
:vartype width: int
:ivar height: The height of the output in this mode.
:vartype height: int
:vartype refresh: The refresh rate of the output in this mode.
:vartype refresh: int
"""
def __init__(self, data):
self.width = data['width']
self.height = data['height']
self.refresh = data['refresh']

def __getitem__(self, item):
# for backwards compatability because this used to be a dict
if not hasattr(self, item):
raise KeyError(item)
return getattr(self, item)

@classmethod
def _parse_list(cls, data):
return [cls(d) for d in data]


class Gaps:
"""For forks that have useless gaps, the dimension of the gaps.
Expand Down
77 changes: 74 additions & 3 deletions i3ipc/replies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .model import Rect
from .model import Rect, OutputMode


class _BaseReply:
Expand Down Expand Up @@ -89,6 +89,28 @@ class OutputReply(_BaseReply):
:ivar rect: The rectangle of this output (equals the rect of the output it
is on).
:vartype rect: :class:`Rect`
:ivar make: (sway only)
:vartype make: str
:ivar model: (sway only)
:vartype model: str
:ivar serial: (sway only)
:vartype serial: str
:ivar scale: (sway only)
:vartype scale: float
:ivar transform: (sway only)
:vartype transform: str
:ivar max_render_time: (sway only)
:vartype max_render_time: int
:ivar focused: (sway only)
:vartype focused: bool
:ivar dpms: (sway only)
:vartype dpms: bool
:ivar subpixel_hinting: (sway only)
:vartype subpixel_hinting: str
:ivar modes: (sway only)
:vartype modes: list(:class:`OutputMode`)
:ivar current_mode: (sway only)
:vartype current_mode: :class:`OutputMode`
:ivar ipc_data: The raw data from the i3 ipc.
:vartype ipc_data: dict
"""
Expand All @@ -108,11 +130,30 @@ class OutputReply(_BaseReply):
('focused', bool),
('dpms', bool),
('subpixel_hinting', str),
('modes', list),
('current_mode', dict),
('modes', OutputMode._parse_list),
('current_mode', OutputMode),
]


class BarConfigGaps:
"""(sway only) The useless gaps for the bar.
:ivar left: The gap to the left.
:vartype left: int
:ivar right: The gap to the right.
:vartype right: int
:ivar top: The gap on the top.
:vartype top: int
:ivar bottom: The gap on the bottom.
:vartype bottom: int
"""
def __init__(self, data):
self.left = data['left']
self.right = data['right']
self.top = data['top']
self.bottom = data['bottom']


class BarConfigReply(_BaseReply):
"""A reply to the ``GET_BAR_CONFIG`` message with a specified bar id.
Expand All @@ -138,19 +179,49 @@ class BarConfigReply(_BaseReply):
:ivar colors: Contains key/value pairs of colors. Each value is a color
code in hex, formatted #rrggbb (like in HTML).
:vartype colors: dict
:ivar tray_padding:
:vartype tray_padding: int
:ivar hidden_state:
:vartype hidden_state: str
:ivar modifier:
:vartype modifier: int
:ivar workspace_min_width:
:vartype workspace_min_width: int
:ivar strip_workspace_numbers:
:vartype strip_workspace_numbers: bool
:ivar strip_workspace_name:
:vartype strip_workspace_name: bool
:ivar gaps: (sway only)
:vartype gaps: :class:`BarConfigGaps`
:ivar bar_height: (sway only)
:vartype bar_height: int
:ivar status_padding: (sway only)
:vartype status_padding: int
:ivar status_edge_padding: (sway only)
:vartype status_edge_padding: int
:ivar ipc_data: The raw data from the i3 ipc.
:vartype ipc_data: dict
"""
_members = [
('id', str),
('tray_padding', int),
('hidden_state', str),
('mode', str),
('modifier', int),
('position', str),
('status_command', str),
('font', str),
('workspace_buttons', bool),
('workspace_min_width', int),
('strip_workspace_numbers', bool),
('strip_workspace_name', bool),
('binding_mode_indicator', bool),
('verbose', bool),
('colors', dict),
('gaps', BarConfigGaps),
('bar_height', int),
('status_padding', int),
('status_edge_padding', int),
]


Expand Down

0 comments on commit e6c7f1b

Please sign in to comment.