bar: show windows on each workspace
This commit is contained in:
parent
5d5bea5758
commit
d49a811d16
4 changed files with 71 additions and 30 deletions
|
|
@ -70,12 +70,21 @@
|
||||||
&.labels-shown > button {
|
&.labels-shown > button {
|
||||||
color: color.change(scheme.$overlay1, $alpha: 1);
|
color: color.change(scheme.$overlay1, $alpha: 1);
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
font-size: lib.s(13);
|
||||||
|
color: color.change(scheme.$subtext0, $alpha: 1);
|
||||||
|
}
|
||||||
|
|
||||||
&.occupied {
|
&.occupied {
|
||||||
color: color.mix(scheme.$text, scheme.$mauve, 50%);
|
color: color.mix(scheme.$text, scheme.$mauve, 50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.focused {
|
&.focused {
|
||||||
color: color.change(scheme.$base, $alpha: 1);
|
color: color.change(scheme.$base, $alpha: 1);
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
color: color.change(scheme.$surface0, $alpha: 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -163,6 +172,14 @@
|
||||||
padding-left: lib.s(20);
|
padding-left: lib.s(20);
|
||||||
padding-right: lib.s(20);
|
padding-right: lib.s(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-left: lib.s(5);
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
margin-left: lib.s(12);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +229,14 @@
|
||||||
padding-top: lib.s(15);
|
padding-top: lib.s(15);
|
||||||
padding-bottom: lib.s(15);
|
padding-bottom: lib.s(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-top: lib.s(2);
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
margin-top: lib.s(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ export default {
|
||||||
showLabels: false,
|
showLabels: false,
|
||||||
labels: ["", "", "", "", ""],
|
labels: ["", "", "", "", ""],
|
||||||
xalign: -1,
|
xalign: -1,
|
||||||
|
showWindows: false,
|
||||||
},
|
},
|
||||||
dateTime: {
|
dateTime: {
|
||||||
format: "%d/%m/%y %R",
|
format: "%d/%m/%y %R",
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ export default {
|
||||||
"bar.modules.workspaces.showLabels": BOOL,
|
"bar.modules.workspaces.showLabels": BOOL,
|
||||||
"bar.modules.workspaces.labels": ARR(STR),
|
"bar.modules.workspaces.labels": ARR(STR),
|
||||||
"bar.modules.workspaces.xalign": NUM,
|
"bar.modules.workspaces.xalign": NUM,
|
||||||
|
"bar.modules.workspaces.showWindows": BOOL,
|
||||||
"bar.modules.dateTime.format": STR,
|
"bar.modules.dateTime.format": STR,
|
||||||
"bar.modules.dateTime.detailedFormat": STR,
|
"bar.modules.dateTime.detailedFormat": STR,
|
||||||
// Launcher
|
// Launcher
|
||||||
|
|
|
||||||
|
|
@ -204,47 +204,61 @@ const MediaPlaying = ({ monitor, ...props }: ModuleProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Workspace = ({ idx }: { idx: number }) => {
|
const Workspace = ({ idx }: { idx: number }) => {
|
||||||
let wsId = hyprland.focusedWorkspace
|
const wsId = Variable.derive([bind(hyprland, "focusedWorkspace"), config.modules.workspaces.shown], (f, s) =>
|
||||||
? Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown.get()) *
|
f ? Math.floor((f.id - 1) / s) * s + idx : idx
|
||||||
config.modules.workspaces.shown.get() +
|
);
|
||||||
idx
|
|
||||||
: idx;
|
const label = (
|
||||||
|
<label
|
||||||
|
css={bind(config.modules.workspaces.xalign).as(a => `margin-left: ${a}px; margin-right: ${-a}px;`)}
|
||||||
|
label={bind(config.modules.workspaces.labels).as(l => l[idx - 1] ?? String(idx))}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
halign={Gtk.Align.CENTER}
|
halign={Gtk.Align.CENTER}
|
||||||
valign={Gtk.Align.CENTER}
|
valign={Gtk.Align.CENTER}
|
||||||
onClicked={() => hyprland.dispatch("workspace", String(wsId))}
|
onClicked={() => hyprland.dispatch("workspace", String(wsId.get()))}
|
||||||
setup={self => {
|
setup={self => {
|
||||||
const update = () =>
|
const updateOccupied = () => {
|
||||||
self.toggleClassName(
|
const occupied = hyprland.clients.some(c => c.workspace?.id === wsId.get());
|
||||||
"occupied",
|
self.toggleClassName("occupied", occupied);
|
||||||
hyprland.clients.some(c => c.workspace?.id === wsId)
|
};
|
||||||
);
|
const updateFocused = () => {
|
||||||
const updateWs = () => {
|
self.toggleClassName("focused", hyprland.focusedWorkspace?.id === wsId.get());
|
||||||
if (!hyprland.focusedWorkspace) return;
|
updateOccupied();
|
||||||
wsId =
|
|
||||||
Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown.get()) *
|
|
||||||
config.modules.workspaces.shown.get() +
|
|
||||||
idx;
|
|
||||||
self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId);
|
|
||||||
update();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.hook(config.modules.workspaces.shown, updateWs);
|
self.hook(hyprland, "client-added", updateOccupied);
|
||||||
self.hook(hyprland, "notify::focused-workspace", updateWs);
|
self.hook(hyprland, "client-moved", updateOccupied);
|
||||||
self.hook(hyprland, "client-added", update);
|
self.hook(hyprland, "client-removed", updateOccupied);
|
||||||
self.hook(hyprland, "client-moved", update);
|
self.hook(hyprland, "notify::focused-workspace", updateFocused);
|
||||||
self.hook(hyprland, "client-removed", update);
|
updateFocused();
|
||||||
|
|
||||||
self.toggleClassName("focused", hyprland.focusedWorkspace?.id === wsId);
|
|
||||||
update();
|
|
||||||
}}
|
}}
|
||||||
|
onDestroy={() => wsId.drop()}
|
||||||
>
|
>
|
||||||
<label
|
<box
|
||||||
visible={bind(config.modules.workspaces.showLabels)}
|
visible={bind(config.modules.workspaces.showLabels)}
|
||||||
css={bind(config.modules.workspaces.xalign).as(a => `margin-left: ${a}px; margin-right: ${-a}px;`)}
|
vertical={bind(config.vertical)}
|
||||||
label={bind(config.modules.workspaces.labels).as(l => l[idx - 1] ?? String(idx))}
|
setup={self => {
|
||||||
|
const update = () => {
|
||||||
|
if (config.modules.workspaces.showWindows.get()) {
|
||||||
|
const clients = hyprland.clients.filter(c => c.workspace?.id === wsId.get());
|
||||||
|
self.children = [
|
||||||
|
label,
|
||||||
|
...clients.map(c => (
|
||||||
|
<label className="icon" label={bind(c, "class").as(getAppCategoryIcon)} />
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
} else self.children = [label];
|
||||||
|
};
|
||||||
|
self.hook(wsId, update);
|
||||||
|
self.hook(hyprland, "client-added", update);
|
||||||
|
self.hook(hyprland, "client-moved", update);
|
||||||
|
self.hook(hyprland, "client-removed", update);
|
||||||
|
update();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue