Added AGS workspaces and clock

This commit is contained in:
Joshua Yuen 2026-09-12 01:33:41 -04:00
parent affd34475b
commit b38217ca75
Signed by: josh
GPG Key ID: 530DA0331EFE99F5
4 changed files with 55 additions and 2 deletions

View File

@ -17,3 +17,20 @@
padding: 4px 12px;
color: $base05;
}
.ws {
min-width: 20px;
border-radius: 6px;
margin: 0 2px;
padding: 0 6px;
}
.ws.active {
background: $base0D;
color: $base00;
}
.clock {
font-weight: bold;
margin: 0 8px;
}

View File

@ -1,4 +1,6 @@
import { App, Astal, Gdk, Gtk } from "astal/gtk3"
import Workspaces from "./Workspaces"
import Clock from "./Clock"
export default function Bar(gdkmonitor: Gdk.Monitor) {
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor
@ -17,12 +19,16 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
className="bar-left"
halign={Gtk.Align.START}
valign={Gtk.Align.CENTER}
/>
>
<Workspaces />
</box>
<box
className="bar-center"
halign={Gtk.Align.CENTER}
valign={Gtk.Align.CENTER}
/>
>
<Clock />
</box>
<box
className="bar-right"
halign={Gtk.Align.END}

View File

@ -0,0 +1,10 @@
import GLib from "gi://GLib"
import { Variable, bind } from "astal"
const time = Variable("").poll(1000, () =>
GLib.DateTime.new_now_local().format("%I:%M %p")!.replace(/^0/, "")
)
export default function Clock() {
return <label className="clock" label={bind(time)} />
}

View File

@ -0,0 +1,20 @@
import Hyprland from "gi://AstalHyprland"
import { bind } from "astal"
const hypr = Hyprland.get_default()
const focused = bind(hypr, "focused-workspace").as((ws) => ws?.id ?? -1)
export default function Workspaces() {
return (
<box className="workspaces">
{[1, 2, 3, 4, 5].map((i) => (
<button
className={focused.as((f) => (f === i ? "ws active" : "ws"))}
onClicked={() => hypr.dispatch("workspace", String(i))}
>
<label label={String(i)} />
</button>
))}
</box>
)
}