config/ags: workspace shennanigans 1

This commit is contained in:
Sakooooo 2024-09-20 22:29:30 +04:00
parent 6284431c91
commit 239c068593
Signed by: sako
GPG key ID: FE52FD65B76E4751
2 changed files with 73 additions and 16 deletions

View file

@ -15,20 +15,53 @@ const date = Variable("", {
// so to make a reuseable widget, make it a function // so to make a reuseable widget, make it a function
// then you can simply instantiate one by calling it // then you can simply instantiate one by calling it
function Workspaces() { // function Workspaces() {
const activeId = hyprland.active.workspace.bind("id") // const activeId = hyprland.active.workspace.bind("id")
const workspaces = hyprland.bind("workspaces") // const workspaces = hyprland.bind("workspaces")
.as(ws => ws.map(({ id }) => Widget.Button({ // .as(ws => ws.map(({ id }) => Widget.Button({
on_clicked: () => hyprland.messageAsync(`dispatch workspace ${id}`), // on_clicked: () => hyprland.messageAsync(`dispatch workspace ${id}`),
child: Widget.Label(`${id}`), // child: Widget.Label(`${id}`),
class_name: activeId.as(i => `${i === id ? "focused" : ""}`), // class_name: activeId.as(i => `${i === id ? "focused" : ""}`),
}))) // })))
return Widget.Box({ // return Widget.Box({
class_name: "workspaces", // class_name: "workspaces",
children: workspaces, // children: workspaces,
}) // })
} // }
const dispatch = ws => hyprland.sendMessage(`dispatch workspace ${ws}`);
export const Workspaces = () => Widget.EventBox({
child: Widget.Box({
children: Array.from({ length: 10 }, (_, i) => i + 1).map(i => Widget.Button({
class_name: "workspace-buttons",
attribute: i,
// Keeps button from expanding to fit its container
onClicked: () => dispatch(i),
child: Widget.Box({
class_name: "workspace-indicator",
// vpack: "start",
vpack: "center",
hpack: "center",
children: [
Widget.Label({
label: `${i}`,
justification: "center",
})
],
setup: self => self.hook(hyprland, () => {
// The "?" is used here to return "undefined" if the workspace doesn't exist
self.toggleClassName('workspace-inactive', (hyprland.getWorkspace(i)?.windows || 0) === 0);
self.toggleClassName('workspace-occupied', (hyprland.getWorkspace(i)?.windows || 0) > 0);
self.toggleClassName('workspace-active', hyprland.active.workspace.id === i);
// self.toggleClassName('workspace-large', (hyprland.getWorkspace(i)?.windows || 0) > 1);
}),
}),
})),
}),
});
function ClientTitle() { function ClientTitle() {

View file

@ -13,7 +13,6 @@ button {
padding-bottom: 0; padding-bottom: 0;
border: none; border: none;
background-color: transparent; background-color: transparent;
border-bottom: 3px solid transparent;
} }
button:active { button:active {
@ -21,7 +20,7 @@ button:active {
} }
button:hover { button:hover {
border-bottom: 3px solid @theme_fg_color; border-bottom: 1px solid @theme_fg_color;
} }
label { label {
@ -29,7 +28,7 @@ label {
} }
.workspaces button.focused { .workspaces button.focused {
border-bottom: 3px solid @theme_selected_bg_color; border-bottom: 1px solid @theme_selected_bg_color;
} }
.client-title { .client-title {
@ -40,6 +39,31 @@ label {
color: yellow; color: yellow;
} }
.workspace-buttons {
min-width: 0;
padding-top: 0;
padding-bottom: 0;
outline-width: 0;
border: none;
background-color: transparent;
}
.workspace-inactive {
opacity: 0.5;
border-bottom: 3px transparent;
}
.workspace-occupied {
opacity: 1;
border-bottom: 3px transparent;
}
.workspace-active {
outline-width: 0;
border-bottom: 3px solid @theme_selected_bg_color;
}
levelbar block, levelbar block,
highlight { highlight {
min-height: 10px; min-height: 10px;