feat: show visible and active workspaces
This commit is contained in:
@@ -20,8 +20,9 @@
|
|||||||
--window-bg: alpha(var(--background), 0.9);
|
--window-bg: alpha(var(--background), 0.9);
|
||||||
--module-bg: alpha(var(--mid-bg), 0.8);
|
--module-bg: alpha(var(--mid-bg), 0.8);
|
||||||
--border-color: var(--light-bg);
|
--border-color: var(--light-bg);
|
||||||
--ws-active: var(--pink);
|
--ws-active: var(--blue);
|
||||||
--ws-inactive: var(--blue);
|
--ws-visible: var(--violet);
|
||||||
|
--ws-inactive: var(--light-grey);
|
||||||
--ws-empty: var(--dark-grey);
|
--ws-empty: var(--dark-grey);
|
||||||
--ws-hover: var(--turquoise);
|
--ws-hover: var(--turquoise);
|
||||||
--ws-urgent: var(--red);
|
--ws-urgent: var(--red);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#workspaces>button {
|
#workspaces>button {
|
||||||
padding: 0px 8px;
|
padding: 0px 8px;
|
||||||
transition: padding 0.05s steps(8);
|
transition: padding 0.05s steps(8), background-color 0.15s ease;
|
||||||
background-color: var(--foreground);
|
background-color: var(--ws-inactive);
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,11 +15,24 @@
|
|||||||
font-size: 0px;
|
font-size: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button.hover {
|
#workspaces>button:hover {
|
||||||
background-color: var(--ws-hover);
|
background-color: var(--ws-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button.urgent {
|
#workspaces>button.empty {
|
||||||
|
background-color: var(--ws-empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
#workspaces>button.visible {
|
||||||
|
background-color: var(--ws-visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
#workspaces>button.active {
|
||||||
|
padding: 0px 32px;
|
||||||
|
background-color: var(--ws-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
#workspaces>button.urgent {
|
||||||
background-color: var(--ws-urgent);
|
background-color: var(--ws-urgent);
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -31,12 +44,3 @@
|
|||||||
50% { opacity: 0.5; }
|
50% { opacity: 0.5; }
|
||||||
100% { opacity: 1.0; }
|
100% { opacity: 1.0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces>button.empty {
|
|
||||||
background-color: var(--ws-empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
#workspaces>button.active {
|
|
||||||
padding: 0px 32px;
|
|
||||||
background-color: var(--ws-active);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,23 +41,23 @@ class FensterWorkspaceButton(Button):
|
|||||||
def _on_clicked(self, *args):
|
def _on_clicked(self, *args):
|
||||||
self._i3.send_command(f"workspace {self._workspace_num}")
|
self._i3.send_command(f"workspace {self._workspace_num}")
|
||||||
|
|
||||||
def set_focused(self, focused: bool):
|
def _toggle_class(self, name: str, on: bool):
|
||||||
if focused:
|
if on:
|
||||||
self.add_style_class("focused")
|
self.add_style_class(name)
|
||||||
else:
|
else:
|
||||||
self.remove_style_class("focused")
|
self.remove_style_class(name)
|
||||||
|
|
||||||
def set_visible_on_output(self, visible: bool):
|
def set_active(self, active: bool):
|
||||||
if visible:
|
self._toggle_class("active", active)
|
||||||
self.add_style_class("visible")
|
|
||||||
else:
|
|
||||||
self.remove_style_class("visible")
|
|
||||||
|
|
||||||
def set_has_windows(self, has_windows: bool):
|
def set_visible_other(self, visible: bool):
|
||||||
if has_windows:
|
self._toggle_class("visible", visible)
|
||||||
self.add_style_class("has-windows")
|
|
||||||
else:
|
def set_empty(self, empty: bool):
|
||||||
self.remove_style_class("has-windows")
|
self._toggle_class("empty", empty)
|
||||||
|
|
||||||
|
def set_urgent(self, urgent: bool):
|
||||||
|
self._toggle_class("urgent", urgent)
|
||||||
|
|
||||||
|
|
||||||
class FensterWorkspaces(Box):
|
class FensterWorkspaces(Box):
|
||||||
@@ -114,14 +114,7 @@ class FensterWorkspaces(Box):
|
|||||||
self._update_workspaces(reply.reply)
|
self._update_workspaces(reply.reply)
|
||||||
|
|
||||||
def _update_workspaces(self, workspaces: list):
|
def _update_workspaces(self, workspaces: list):
|
||||||
focused_ws = None
|
workspace_nums = {ws["num"] for ws in workspaces if ws.get("num") is not None}
|
||||||
workspace_nums = set()
|
|
||||||
for ws in workspaces:
|
|
||||||
ws_num = ws.get("num")
|
|
||||||
if ws_num is not None:
|
|
||||||
workspace_nums.add(ws_num)
|
|
||||||
if ws.get("focused"):
|
|
||||||
focused_ws = ws_num
|
|
||||||
|
|
||||||
# Remove buttons for workspaces that no longer exist
|
# Remove buttons for workspaces that no longer exist
|
||||||
for ws_num in list(self._buttons.keys()):
|
for ws_num in list(self._buttons.keys()):
|
||||||
@@ -141,14 +134,17 @@ class FensterWorkspaces(Box):
|
|||||||
self.add(button)
|
self.add(button)
|
||||||
|
|
||||||
button = self._buttons[ws_num]
|
button = self._buttons[ws_num]
|
||||||
button.set_focused(ws_num == focused_ws)
|
|
||||||
|
|
||||||
ws_output = ws.get("output")
|
|
||||||
is_visible = ws_output == self._output if self._output is not None else False
|
|
||||||
button.set_visible_on_output(is_visible)
|
|
||||||
|
|
||||||
|
focused = bool(ws.get("focused"))
|
||||||
|
visible = bool(ws.get("visible"))
|
||||||
|
urgent = bool(ws.get("urgent"))
|
||||||
window_count = ws.get("window_count", 0)
|
window_count = ws.get("window_count", 0)
|
||||||
button.set_has_windows(window_count > 0)
|
|
||||||
|
button.set_active(focused)
|
||||||
|
# "visible on another output": shown on its output but not the focused one
|
||||||
|
button.set_visible_other(visible and not focused)
|
||||||
|
button.set_urgent(urgent)
|
||||||
|
button.set_empty(window_count == 0)
|
||||||
|
|
||||||
# Sort buttons by workspace number
|
# Sort buttons by workspace number
|
||||||
sorted_buttons = sorted(self._buttons.values(), key=lambda b: b.workspace_num)
|
sorted_buttons = sorted(self._buttons.values(), key=lambda b: b.workspace_num)
|
||||||
|
|||||||
Reference in New Issue
Block a user