mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Let segment_info overwrite i3wm workspace output
This commit is contained in:
parent
b40119a187
commit
7b60b941fd
@ -19,7 +19,8 @@ def calcgrp(w):
|
|||||||
return group
|
return group
|
||||||
|
|
||||||
|
|
||||||
def workspaces(pl, only_show=None, output=None, strip=0):
|
@requires_segment_info
|
||||||
|
def workspaces(pl, segment_info, only_show=None, output=None, strip=0):
|
||||||
'''Return list of used workspaces
|
'''Return list of used workspaces
|
||||||
|
|
||||||
:param list only_show:
|
:param list only_show:
|
||||||
@ -28,7 +29,8 @@ def workspaces(pl, only_show=None, output=None, strip=0):
|
|||||||
are shown.
|
are shown.
|
||||||
|
|
||||||
:param str output:
|
:param str output:
|
||||||
If specified, only workspaces on this output are shown.
|
If specified, only workspaces on this output are shown. If unspecified,
|
||||||
|
may be set by the lemonbar renderer and bindings.
|
||||||
|
|
||||||
:param int strip:
|
:param int strip:
|
||||||
Specifies how many characters from the front of each workspace name
|
Specifies how many characters from the front of each workspace name
|
||||||
@ -45,6 +47,8 @@ def workspaces(pl, only_show=None, output=None, strip=0):
|
|||||||
else:
|
else:
|
||||||
conn = i3ipc.Connection()
|
conn = i3ipc.Connection()
|
||||||
|
|
||||||
|
output = output or ('output' in segment_info and segment_info['output'])
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'contents': w['name'][min(len(w['name']), strip):],
|
'contents': w['name'][min(len(w['name']), strip):],
|
||||||
'highlight_groups': calcgrp(w)
|
'highlight_groups': calcgrp(w)
|
||||||
|
@ -891,39 +891,48 @@ class TestI3WM(TestCase):
|
|||||||
{'name': '3: w3', 'output': 'HDMI1', 'focused': False, 'urgent': True, 'visible': True},
|
{'name': '3: w3', 'output': 'HDMI1', 'focused': False, 'urgent': True, 'visible': True},
|
||||||
{'name': '4: w4', 'output': 'DVI01', 'focused': True, 'urgent': True, 'visible': True},
|
{'name': '4: w4', 'output': 'DVI01', 'focused': True, 'urgent': True, 'visible': True},
|
||||||
]))):
|
]))):
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl), [
|
segment_info = {}
|
||||||
|
|
||||||
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info), [
|
||||||
{'contents': '1: w1', 'highlight_groups': ['workspace']},
|
{'contents': '1: w1', 'highlight_groups': ['workspace']},
|
||||||
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=None), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=None), [
|
||||||
{'contents': '1: w1', 'highlight_groups': ['workspace']},
|
{'contents': '1: w1', 'highlight_groups': ['workspace']},
|
||||||
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['focused', 'urgent']), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['focused', 'urgent']), [
|
||||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible']), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible']), [
|
||||||
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
{'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible'], strip=3), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible'], strip=3), [
|
||||||
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
{'contents': 'w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': 'w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
{'contents': 'w4', 'highlight_groups': ['w_focused', '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'), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['focused', 'urgent'], output='DVI01'), [
|
||||||
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
{'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible'], output='HDMI1'), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible'], output='HDMI1'), [
|
||||||
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
self.assertEqual(i3wm.workspaces(pl=pl, only_show=['visible'], strip=3, output='LVDS1'), [
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible'], strip=3, output='LVDS1'), [
|
||||||
|
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
|
])
|
||||||
|
segment_info['output'] = 'LVDS1'
|
||||||
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible'], output='HDMI1'), [
|
||||||
|
{'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']},
|
||||||
|
])
|
||||||
|
self.assertEqual(i3wm.workspaces(pl=pl, segment_info=segment_info, only_show=['visible'], strip=3), [
|
||||||
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
{'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user