2023-09-04 00:41:14 -04:00
|
|
|
const { Hyprland, Applications } = ags.Service;
|
2023-09-05 13:27:29 -04:00
|
|
|
const { execAsync } = ags.Utils;
|
|
|
|
const { Box, Button, Label, Revealer } = ags.Widget;
|
2023-09-04 00:41:14 -04:00
|
|
|
|
2023-09-11 19:57:21 -04:00
|
|
|
import { EventBox } from '../misc/cursorbox.js';
|
2023-09-05 13:27:29 -04:00
|
|
|
|
2023-09-10 23:15:11 -04:00
|
|
|
const Workspace = ({ i } = {}) =>
|
2023-09-05 13:27:29 -04:00
|
|
|
Revealer({
|
2023-09-04 12:44:14 -04:00
|
|
|
transition: "slide_right",
|
|
|
|
child: EventBox({
|
2023-09-10 23:15:11 -04:00
|
|
|
setup: widget => {
|
|
|
|
widget.set_tooltip_text(`${i}`);
|
|
|
|
},
|
2023-09-04 12:44:14 -04:00
|
|
|
onPrimaryClickRelease: () => execAsync(`hyprctl dispatch workspace ${i}`).catch(print),
|
|
|
|
child: Box({
|
|
|
|
className: 'button',
|
|
|
|
child: Label(`${i}`),
|
|
|
|
connections: [
|
|
|
|
[Hyprland, btn => {
|
2023-09-10 15:49:37 -04:00
|
|
|
const occupied = Hyprland.getWorkspace(i)?.windows > 0;
|
|
|
|
btn.toggleClassName('active', Hyprland.active.workspace.id === i);
|
2023-09-04 12:44:14 -04:00
|
|
|
btn.toggleClassName('occupied', occupied);
|
|
|
|
btn.toggleClassName('empty', !occupied);
|
|
|
|
}]
|
|
|
|
],
|
|
|
|
}),
|
2023-09-04 00:41:14 -04:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
2023-09-10 23:15:11 -04:00
|
|
|
export const Workspaces = Box({
|
2023-09-05 13:27:29 -04:00
|
|
|
className: 'workspaces',
|
2023-09-04 00:41:14 -04:00
|
|
|
children: [EventBox({
|
|
|
|
child: Box({
|
2023-09-10 23:15:11 -04:00
|
|
|
children: Array.from({ length: 15 }, (_, i) => i + 1).map(i => Workspace({ i: i})),
|
2023-09-04 00:41:14 -04:00
|
|
|
connections: [[Hyprland, box => {
|
|
|
|
let workspaces = [];
|
2023-09-05 13:27:29 -04:00
|
|
|
Hyprland.workspaces.forEach(ws => {
|
|
|
|
if (ws.id > 0) workspaces.push(ws);
|
|
|
|
});
|
2023-09-04 00:41:14 -04:00
|
|
|
|
2023-09-05 13:27:29 -04:00
|
|
|
box.children.forEach(rev => rev.reveal_child = false);
|
|
|
|
workspaces.forEach(ws => {
|
|
|
|
box.children[ws.id - 1].reveal_child = true;
|
2023-09-04 00:41:14 -04:00
|
|
|
});
|
|
|
|
}]],
|
|
|
|
}),
|
|
|
|
})],
|
|
|
|
});
|