Skip to content

Commit

Permalink
Change Con.mark to marks
Browse files Browse the repository at this point in the history
In newer versions of i3 containers can have multiple marks, so the property
name has changed form mark to marks.
  • Loading branch information
xenomachina committed Apr 22, 2016
1 parent 48064e5 commit c7a3fee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions i3ipc.py
Expand Up @@ -404,7 +404,7 @@ def __init__(self, data, parent, conn):

# set simple properties
ipc_properties = ['border', 'current_border_width', 'focused',
'fullscreen_mode', 'id', 'layout', 'mark', 'name',
'fullscreen_mode', 'id', 'layout', 'mark', 'marks', 'name',
'orientation', 'percent', 'type', 'urgent', 'window',
'num', 'scratchpad_state']
for attr in ipc_properties:
Expand All @@ -413,6 +413,15 @@ def __init__(self, data, parent, conn):
else:
setattr(self, attr, None)

# Make sure marks is never None (use []) to simplify client code. Older
# versions of i3 used mark instead of marks, so collapse that into
# marks to provide a consistent API.
if not self.marks:
self.marks = []
if self.mark:
self.marks.append(mark)
del self.mark

# XXX this is for compatability with 4.8
if isinstance(self.type, int):
if self.type == 0:
Expand Down Expand Up @@ -540,8 +549,9 @@ def find_classed(self, pattern):
if c.window_class and re.search(pattern, c.window_class)]

def find_marked(self, pattern=".*"):
pattern = re.compile(pattern)
return [c for c in self.descendents()
if c.mark and re.search(pattern, c.mark)]
if any(pattern.search(mark) for mark in c.marks)]

def find_fullscreen(self):
return [c for c in self.descendents()
Expand Down

0 comments on commit c7a3fee

Please sign in to comment.