make bar show workspaces 1-10

This commit is contained in:
Sakooooo 2024-11-26 10:21:55 +04:00
parent 86b08ef9ea
commit 608c48d139
Signed by: sako
GPG key ID: 3FD715D87D7725E0

View file

@ -79,21 +79,17 @@ function Media() {
} }
function Workspaces() { function Workspaces() {
const hypr = Hyprland.get_default() const hypr = Hyprland.get_default()
return <box className="Workspaces"> const workspaceButtons: number[] = (Array.from({ length: 10 }, (_, id) => id + 1))
{bind(hypr, "workspaces").as(wss => wss
.sort((a, b) => a.id - b.id) return <box className="Workspaces">
.map(ws => ( {workspaceButtons.map (workspace =>
<button <button
className={bind(hypr, "focusedWorkspace").as(fw => className={bind(hypr, "focusedWorkspace").as(fw => workspace === fw.id ? "focused" : "")}
ws === fw ? "focused" : "")} >{workspace}</button>
onClicked={() => ws.focus()}> )}
{ws.id} </box>
</button>
))
)}
</box>
} }
function FocusedClient() { function FocusedClient() {
@ -132,7 +128,7 @@ export default function Bar(monitor: Gdk.Monitor) {
anchor={anchor}> anchor={anchor}>
<centerbox> <centerbox>
<box hexpand halign={Gtk.Align.START}> <box hexpand halign={Gtk.Align.START}>
<Workspaces /> <Workspaces />
<FocusedClient /> <FocusedClient />
</box> </box>
<box> <box>