Skip to content

Commit 13165e6

Browse files
committed
basic support for custom workspace icons
1 parent 8e0be5e commit 13165e6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

config/data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def load_config():
7575
"bar_workspace_use_chinese_numerals", False
7676
)
7777
BAR_HIDE_SPECIAL_WORKSPACE = config.get("bar_hide_special_workspace", True)
78+
BAR_WORKSPACE_ICONS = config.get("bar_workspace_icons", {})
7879
BAR_THEME = config.get("bar_theme", "Pills")
7980
DOCK_THEME = config.get("dock_theme", "Pills")
8081
PANEL_THEME = config.get("panel_theme", "Pills")

modules/bar.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@
4545
tooltip_overview = """<b>Overview</b>"""
4646

4747

48+
def build_caption(i: int):
49+
"""Build the label for a given workspace number"""
50+
label = data.BAR_WORKSPACE_ICONS.get(str(i))
51+
if label is None:
52+
return (
53+
CHINESE_NUMERALS[i - 1]
54+
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS
55+
and 1 <= i <= len(CHINESE_NUMERALS)
56+
else str(i)
57+
)
58+
else:
59+
return label
60+
61+
4862
class Bar(Window):
4963
def __init__(self, **kwargs):
5064
super().__init__(
@@ -135,12 +149,7 @@ def __init__(self, **kwargs):
135149
h_align="center",
136150
v_align="center",
137151
id=i,
138-
label=(
139-
CHINESE_NUMERALS[i - 1]
140-
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS
141-
and 1 <= i <= len(CHINESE_NUMERALS)
142-
else str(i)
143-
),
152+
label=build_caption(i),
144153
)
145154
for i in range(1, 11)
146155
],
@@ -155,7 +164,7 @@ def __init__(self, **kwargs):
155164
name="workspaces-container",
156165
children=(
157166
self.workspaces
158-
if not data.BAR_WORKSPACE_SHOW_NUMBER
167+
if not (data.BAR_WORKSPACE_SHOW_NUMBER or data.BAR_WORKSPACE_ICONS)
159168
else self.workspaces_num
160169
),
161170
)
@@ -603,7 +612,7 @@ def toggle_hidden(self):
603612
self.bar_inner.remove_style_class("hidden")
604613

605614
def chinese_numbers(self):
606-
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS:
615+
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS or data.BAR_WORKSPACE_ICONS:
607616
self.workspaces_num.add_style_class("chinese")
608617
else:
609618
self.workspaces_num.remove_style_class("chinese")

0 commit comments

Comments
 (0)