Merge pull request #1432 from S0lll0s/new-workspace
Add 'output' option to segments.i3wm.workspaces
This commit is contained in:
commit
5905ac22bf
|
@ -19,7 +19,7 @@ def calcgrp(w):
|
|||
return group
|
||||
|
||||
|
||||
def workspaces(pl, only_show=None, strip=0):
|
||||
def workspaces(pl, only_show=None, output=None, strip=0):
|
||||
'''Return list of used workspaces
|
||||
|
||||
:param list only_show:
|
||||
|
@ -27,6 +27,9 @@ def workspaces(pl, only_show=None, strip=0):
|
|||
``"urgent"`` and ``"focused"``. If omitted or ``null`` all workspaces
|
||||
are shown.
|
||||
|
||||
:param str output:
|
||||
If specified, only workspaces on this output are shown.
|
||||
|
||||
:param int strip:
|
||||
Specifies how many characters from the front of each workspace name
|
||||
should be stripped (e.g. to remove workspace numbers). Defaults to zero.
|
||||
|
@ -45,7 +48,10 @@ def workspaces(pl, only_show=None, strip=0):
|
|||
return [{
|
||||
'contents': w['name'][min(len(w['name']), strip):],
|
||||
'highlight_groups': calcgrp(w)
|
||||
} for w in conn.get_workspaces() if not only_show or any((w[typ] for typ in only_show))]
|
||||
} for w in conn.get_workspaces()
|
||||
if (not only_show or any(w[typ] for typ in only_show))
|
||||
and (not output or w['output'] == output)
|
||||
]
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
|
|
|
@ -819,10 +819,10 @@ class TestI3WM(TestCase):
|
|||
def test_workspaces(self):
|
||||
pl = Pl()
|
||||
with replace_attr(i3wm, 'conn', Args(get_workspaces=lambda: iter([
|
||||
{'name': '1: w1', 'focused': False, 'urgent': False, 'visible': False},
|
||||
{'name': '2: w2', 'focused': False, 'urgent': False, 'visible': True},
|
||||
{'name': '3: w3', 'focused': False, 'urgent': True, 'visible': True},
|
||||
{'name': '4: w4', 'focused': True, 'urgent': True, 'visible': True},
|
||||
{'name': '1: w1', 'output': 'LVDS1', 'focused': False, 'urgent': False, 'visible': False},
|
||||
{'name': '2: w2', 'output': 'LVDS1', 'focused': False, 'urgent': False, 'visible': True},
|
||||
{'name': '3: w3', 'output': 'HDMI1', 'focused': False, 'urgent': True, 'visible': True},
|
||||
{'name': '4: w4', 'output': 'DVI01', 'focused': True, 'urgent': True, 'visible': True},
|
||||
]))):
|
||||
self.assertEqual(i3wm.workspaces(pl=pl), [
|
||||
{'contents': '1: w1', 'highlight_groups': ['workspace']},
|
||||
|
@ -850,6 +850,15 @@ class TestI3WM(TestCase):
|
|||
{'contents': 'w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||
{'contents': 'w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||
])
|
||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['focused', 'urgent'], output='DVI01'), [
|
||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||
])
|
||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible'], output='HDMI1'), [
|
||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||
])
|
||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible'], strip=3, output='LVDS1'), [
|
||||
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||
])
|
||||
|
||||
def test_mode(self):
|
||||
pl = Pl()
|
||||
|
|
Loading…
Reference in New Issue