fix: only show workspaces on monitors they belong to

This commit is contained in:
2025-06-28 01:32:27 -07:00
parent d840dc3e4a
commit 78ca57e491
2 changed files with 27 additions and 13 deletions

14
astal/bun.lock Normal file
View File

@@ -0,0 +1,14 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "astal-shell",
"dependencies": {
"astal": "/nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs",
},
},
},
"packages": {
"astal": ["astal@file:../../../../nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs", {}],
}
}

View File

@@ -7,23 +7,23 @@ import GTop from "gi://GTop"
import { calc_cpu_usage, get_cpu_snapshot, get_disk_space, get_ram_info } from "./cpu" import { calc_cpu_usage, get_cpu_snapshot, get_disk_space, get_ram_info } from "./cpu"
import AstalBattery from "gi://AstalBattery" import AstalBattery from "gi://AstalBattery"
const time = Variable("").poll(1000, "date") function Workspaces({ monitor }: { monitor: Gdk.Monitor }) {
function Workspaces() {
const hypr = Hyprland.get_default() const hypr = Hyprland.get_default()
return <box className="workspaces"> return <box className="workspaces">
{bind(hypr, "workspaces").as(wss => wss.filter(ws => !(ws.id >= -99 && ws.id <= -2)) {bind(hypr, "workspaces").as(wss => wss.filter(ws => !(ws.id >= -99 && ws.id <= -2))
.sort((a, b) => a.id - b.id) .sort((a, b) => a.id - b.id)
.map(ws => ( .map(ws => {
//@ts-ignore if (ws.monitor.model !== monitor.model) return <></>
<button return (
className={bind(hypr, "focusedWorkspace").as(fw => <button
ws === fw ? "focused" : "")} className={bind(hypr, "focusedWorkspace").as(fw =>
onClicked={() => ws.focus()}> ws === fw ? "focused" : "")}
{ws.id} onClicked={() => ws.focus()}>
</button> {ws.id}
)))} </button>
)
}))}
</box> </box>
} }
@@ -145,7 +145,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
<box className="nix-icon"> <box className="nix-icon">
<icon icon="nixos-3" /> <icon icon="nixos-3" />
</box> </box>
<Workspaces /> <Workspaces monitor={gdkmonitor} />
</box> </box>
<box></box> <box></box>
<box hexpand halign={Gtk.Align.END}> <box hexpand halign={Gtk.Align.END}>