From 4a1a3a6d8915474c2e25f2f1f5e3ec8c84543081 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Mon, 7 Apr 2025 13:38:23 +1000
Subject: bar: add optional labels for workspaces
Also can customise labels
---
src/modules/bar.tsx | 51 ++++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 21 deletions(-)
(limited to 'src/modules/bar.tsx')
diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx
index 998a442..97ce4d5 100644
--- a/src/modules/bar.tsx
+++ b/src/modules/bar.tsx
@@ -209,6 +209,7 @@ const Workspace = ({ idx }: { idx: number }) => {
config.modules.workspaces.shown.get() +
idx
: idx;
+
return (
);
};
-const Workspaces = ({ monitor, ...props }: ModuleProps) => (
- {
- const activeWs = hyprland.focusedClient?.workspace.name;
- if (activeWs?.startsWith("special:")) hyprland.dispatch("togglespecialworkspace", activeWs.slice(8));
- else if (event.delta_y > 0 || hyprland.focusedWorkspace?.id > 1)
- hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1);
- }}
- >
- `module workspaces ${s % 2 === 0 ? "even" : "odd"} ${getClassName(props)}`
- )}
+const Workspaces = ({ monitor, ...props }: ModuleProps) => {
+ const className = Variable.derive(
+ [config.modules.workspaces.shown, config.modules.workspaces.showLabels],
+ (s, l) => `module workspaces ${s % 2 === 0 ? "even" : "odd"} ${l ? "labels-shown" : ""} ${getClassName(props)}`
+ );
+
+ return (
+ {
+ const activeWs = hyprland.focusedClient?.workspace.name;
+ if (activeWs?.startsWith("special:")) hyprland.dispatch("togglespecialworkspace", activeWs.slice(8));
+ else if (event.delta_y > 0 || hyprland.focusedWorkspace?.id > 1)
+ hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1);
+ }}
>
- {bind(config.modules.workspaces.shown).as(
- n => Array.from({ length: n }).map((_, idx) => ) // Start from 1
- )}
-
-
-);
+ className.drop()}>
+ {bind(config.modules.workspaces.shown).as(
+ n => Array.from({ length: n }).map((_, idx) => ) // Start from 1
+ )}
+
+
+ );
+};
const TrayItem = (item: AstalTray.TrayItem) => (