updates
This commit is contained in:
1 parent
3962056bf6
commit
9c3c90f35c
2 files changed
+90
-90
No files matched your search
+87
-87
@@ -94,97 +94,97 @@ function getIconNameFromClass(windowClass: string) {
|
||||
const dispatch = (ws: string) => hyprland.messageAsync(`dispatch workspace ${ws}`).catch(print);
|
||||
|
||||
function Workspaces() {
|
||||
return EventBox({
|
||||
onScrollUp: () => dispatch("+1"),
|
||||
onScrollDown: () => dispatch("-1"),
|
||||
className: "workspaces",
|
||||
child: Box({
|
||||
className: "outer-workspace",
|
||||
children: Array.from({ length: 9 }, (_, i) => i + 1).map(
|
||||
(i, index, array) =>
|
||||
Box({
|
||||
attribute: i,
|
||||
className:
|
||||
index === 0
|
||||
? "workspace first"
|
||||
: index === array.length - 1
|
||||
? "workspace last"
|
||||
: "workspace",
|
||||
})
|
||||
),
|
||||
}).hook(hyprland, (self) => {
|
||||
let previousWorkspace = {};
|
||||
previousWorkspace.className = "";
|
||||
self.children.forEach((box, index, array) => {
|
||||
const isActive = hyprland.active.workspace.id === box.attribute;
|
||||
const isOccupied = hyprland.workspaces.some(
|
||||
(item) => item.id === box.attribute
|
||||
);
|
||||
let buttonClassName;
|
||||
if (isActive) {
|
||||
buttonClassName = "focused";
|
||||
box.className = "workspace focused";
|
||||
} else if (isOccupied) {
|
||||
buttonClassName = "occupied";
|
||||
box.className = "workspace occupied";
|
||||
} else {
|
||||
buttonClassName = "normal";
|
||||
box.className = "workspace normal";
|
||||
}
|
||||
return EventBox({
|
||||
onScrollUp: () => dispatch("+1"),
|
||||
onScrollDown: () => dispatch("-1"),
|
||||
className: "workspaces",
|
||||
child: Box({
|
||||
className: "outer-workspace",
|
||||
children: Array.from({ length: 9 }, (_, i) => i + 1).map(
|
||||
(i, index, array) =>
|
||||
Box({
|
||||
attribute: i,
|
||||
className:
|
||||
index === 0
|
||||
? "workspace first"
|
||||
: index === array.length - 1
|
||||
? "workspace last"
|
||||
: "workspace",
|
||||
})
|
||||
),
|
||||
}).hook(hyprland, (self) => {
|
||||
let previousWorkspace = {};
|
||||
previousWorkspace.className = "";
|
||||
self.children.forEach((box, index, array) => {
|
||||
const isActive = hyprland.active.workspace.id === box.attribute;
|
||||
const isOccupied = hyprland.workspaces.some(
|
||||
(item) => item.id === box.attribute
|
||||
);
|
||||
let buttonClassName;
|
||||
if (isActive) {
|
||||
buttonClassName = "focused";
|
||||
box.className = "workspace focused";
|
||||
} else if (isOccupied) {
|
||||
buttonClassName = "occupied";
|
||||
box.className = "workspace occupied";
|
||||
} else {
|
||||
buttonClassName = "normal";
|
||||
box.className = "workspace normal";
|
||||
}
|
||||
|
||||
if (isOccupied || isActive) {
|
||||
if (index === 0) box.toggleClassName("occupied-start", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-start") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-single", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-middle") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-end", true);
|
||||
else if (
|
||||
previousWorkspace.className.indexOf("occupied-start") !== -1
|
||||
) {
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else if (
|
||||
previousWorkspace.className.indexOf("occupied-end") !== -1
|
||||
) {
|
||||
previousWorkspace.toggleClassName("occupied-middle", true);
|
||||
previousWorkspace.toggleClassName("occupied-end", false);
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else {
|
||||
box.toggleClassName("occupied-start", true);
|
||||
}
|
||||
} else {
|
||||
if (previousWorkspace.className.indexOf("occupied-start") !== -1) {
|
||||
previousWorkspace.toggleClassName("occupied-start", false);
|
||||
previousWorkspace.toggleClassName("occupied-single", true);
|
||||
}
|
||||
}
|
||||
if (isOccupied || isActive) {
|
||||
if (index === 0) box.toggleClassName("occupied-start", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-start") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-single", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-middle") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-end", true);
|
||||
else if (
|
||||
previousWorkspace.className.indexOf("occupied-start") !== -1
|
||||
) {
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else if (
|
||||
previousWorkspace.className.indexOf("occupied-end") !== -1
|
||||
) {
|
||||
previousWorkspace.toggleClassName("occupied-middle", true);
|
||||
previousWorkspace.toggleClassName("occupied-end", false);
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else {
|
||||
box.toggleClassName("occupied-start", true);
|
||||
}
|
||||
} else {
|
||||
if (previousWorkspace.className.indexOf("occupied-start") !== -1) {
|
||||
previousWorkspace.toggleClassName("occupied-start", false);
|
||||
previousWorkspace.toggleClassName("occupied-single", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
box.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
box.toggleClassName("last", true);
|
||||
}
|
||||
if (index === 0) {
|
||||
box.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
box.toggleClassName("last", true);
|
||||
}
|
||||
|
||||
box.child = Button({
|
||||
className: buttonClassName,
|
||||
label: box.attribute.toString(),
|
||||
onClicked: () => dispatch(box.attribute),
|
||||
setup: (self) => {
|
||||
if (index === 0) {
|
||||
self.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
self.toggleClassName("last", true);
|
||||
}
|
||||
},
|
||||
});
|
||||
box.child = Button({
|
||||
className: buttonClassName,
|
||||
label: isActive ? `•` : box.attribute.toString(),
|
||||
onClicked: () => dispatch(box.attribute),
|
||||
setup: (self) => {
|
||||
if (index === 0) {
|
||||
self.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
self.toggleClassName("last", true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Pass current workspace attributes as previousWorkspace
|
||||
previousWorkspace = box;
|
||||
// Pass current workspace attributes as previousWorkspace
|
||||
previousWorkspace = box;
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -135,13 +135,13 @@ separator {
|
||||
|
||||
.workspace button.normal:hover {
|
||||
border-radius: 20px;
|
||||
background-color: @secondary;
|
||||
background-color: @primary;
|
||||
color: @surfaceDim;
|
||||
}
|
||||
|
||||
.workspace button.focused {
|
||||
background-color: @secondary;
|
||||
color: @background;
|
||||
background-color: @outline;
|
||||
color: @secondary;
|
||||
font-weight: bold;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
|
||||
Reference in new issue
Block a user