Skip to content

Commit e8b57cf

Browse files
committed
Refactoring a bit
1 parent 4d21b01 commit e8b57cf

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

bar.py

+17-25
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import time
55
import sys
66

7-
seperator = " %{FYellow}»%{F-} "
87
seperator = " "
98

109
def get_date():
@@ -39,12 +38,10 @@ def get_workspaces(monitor):
3938
print(type(workspaces))
4039
for workspace in workspaces:
4140
workspace = int(workspace)
42-
if monitor == 0:
43-
if workspace >= 0 and workspace <= 5:
44-
line += str(workspace) + " "
45-
if monitor == 1:
46-
if workspace > 0 and workspace >= 6:
47-
line += str(workspace) + " "
41+
if monitor == 0 and workspace in range(1,6):
42+
line += str(workspace) + " "
43+
if monitor == 1 and workspace in range(6, 11):
44+
line += str(workspace) + " "
4845
return line
4946

5047
def get_active_workspace(monitor):
@@ -53,36 +50,31 @@ def get_active_workspace(monitor):
5350
for line in tree:
5451
if "DVI-" + str(monitor) in line:
5552
flag = True
56-
if flag:
57-
if line.startswith("\t") and not line.startswith("\t\t"):
58-
workspace = int(line.split(" ")[0].strip())
59-
if monitor == 0:
60-
if workspace > 0 and workspace <= 5:
61-
if "*" in line:
62-
return workspace
63-
if monitor == 1:
64-
if workspace > 1 and workspace >= 6:
65-
if "*" in line:
66-
return workspace
53+
if flag and line.startswith("\t") and not line.startswith("\t\t"):
54+
workspace = int(line.split(" ")[0].strip())
55+
if monitor == 0 and workspace in range(0, 6) and "*" in line:
56+
return workspace
57+
if monitor == 1 and workspace in range(6,11) and "*" in line:
58+
return workspace
6759

6860
def get_workspace_text(monitor):
6961
focused_color = "%{F#0066FF}"
7062
unfocused_color = "%{F#66CCFF}"
7163
window_icon = "\ue056"
72-
command = "bspc desktop -f "
73-
active_workspace = get_active_workspace(monitor)
7464
lines = ""
65+
66+
active_workspace = get_active_workspace(monitor)
7567
if monitor == 0:
76-
lower_bound = 1
77-
upper_bound = 6
68+
workspace_range = range(1,6)
7869
if monitor == 1:
79-
lower_bound = 6
80-
upper_bound = 11
81-
for num in range(lower_bound, upper_bound):
70+
workspace_range = range(6, 11)
71+
72+
for num in workspace_range:
8273
if num == active_workspace:
8374
lines += focused_color + "%{A:bspc desktop -f " + str(num) + ":}" + window_icon + "%{A}%{F-} "
8475
else:
8576
lines += unfocused_color + "%{A:bspc desktop -f " + str(num) + ":}" + window_icon + "%{A}%{F-} "
77+
8678
return lines.strip()
8779

8880
def get_text():

0 commit comments

Comments
 (0)