Added workspace widget
This commit is contained in:
1 parent
fe35b5b10b
commit
01f10ccf92
3 files changed
+44
-1
No files matched your search
+15
@@ -24,4 +24,19 @@ window.Bar {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workspaces {
|
||||||
|
.workspace-btn {
|
||||||
|
min-width: 24px;
|
||||||
|
min-height: 24px;
|
||||||
|
padding: 0 4px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: #{"@theme_selected_bg_color"};
|
||||||
|
color: #{"@theme_selected_fg_color"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
import app from "ags/gtk4/app"
|
import app from "ags/gtk4/app"
|
||||||
import { Astal, Gtk, Gdk } from "ags/gtk4"
|
import { Astal, Gtk, Gdk } from "ags/gtk4"
|
||||||
|
import Workspaces from "./Workspaces"
|
||||||
|
|
||||||
function Left() {
|
function Left() {
|
||||||
return (
|
return (
|
||||||
<box $type="start" halign={Gtk.Align.START} cssClasses={["left-box"]}>
|
<box $type="start" halign={Gtk.Align.START} cssClasses={["left-box"]}>
|
||||||
<label label="Left Widget Area" />
|
<Workspaces />
|
||||||
</box>
|
</box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Gtk } from "ags/gtk4"
|
||||||
|
import { execAsync } from "ags/process"
|
||||||
|
import { createPoll } from "ags/time"
|
||||||
|
|
||||||
|
export default function Workspaces() {
|
||||||
|
// Poll the active workspace ID from Hyprland
|
||||||
|
const activeWs = createPoll(1, 250, (prev) =>
|
||||||
|
execAsync("hyprctl activeworkspace -j")
|
||||||
|
.then((out) => JSON.parse(out).id as number)
|
||||||
|
.catch(() => prev),
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<box cssClasses={["workspaces"]} spacing={4}>
|
||||||
|
{Array.from({ length: 9 }, (_, i) => i + 1).map((i) => (
|
||||||
|
<button
|
||||||
|
cssClasses={activeWs((active) =>
|
||||||
|
active === i ? ["workspace-btn", "active"] : ["workspace-btn"],
|
||||||
|
)}
|
||||||
|
onClicked={() => execAsync(`hyprctl dispatch workspace ${i}`)}
|
||||||
|
>
|
||||||
|
<label label={`${i}`} />
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</box>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user