2023-10-31 08:32:40 -04:00
|
|
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
|
|
|
import { Box } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-10-30 22:00:46 -04:00
|
|
|
import * as VARS from './variables.js';
|
|
|
|
|
|
|
|
const DEFAULT_STYLE = `
|
|
|
|
min-width: ${VARS.SCREEN.X * VARS.SCALE}px;
|
|
|
|
min-height: ${VARS.SCREEN.Y * VARS.SCALE - 4}px;
|
|
|
|
border-radius: 10px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
export const Highlighter = () => Box({
|
2023-11-07 10:56:12 -05:00
|
|
|
vpack: 'start',
|
|
|
|
hpack: 'start',
|
2023-10-30 22:00:46 -04:00
|
|
|
className: 'workspace active',
|
2023-11-07 10:56:12 -05:00
|
|
|
css: DEFAULT_STYLE,
|
2023-10-30 22:00:46 -04:00
|
|
|
});
|
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
export const updateCurrentWorkspace = (main, highlighter) => {
|
2023-10-30 22:00:46 -04:00
|
|
|
const currentId = Hyprland.active.workspace.id;
|
|
|
|
const row = Math.floor((currentId - 1) / VARS.WORKSPACE_PER_ROW);
|
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
const rowObject = main.children[0].children[row];
|
2023-10-30 22:00:46 -04:00
|
|
|
const workspaces = rowObject.child.centerWidget.child.get_children().filter(w => w.revealChild);
|
|
|
|
|
|
|
|
const height = row * (VARS.SCREEN.Y * VARS.SCALE + 17);
|
|
|
|
const currentIndex = workspaces.findIndex(w => w._id == currentId);
|
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
highlighter.setCss(`
|
2023-10-30 22:00:46 -04:00
|
|
|
${DEFAULT_STYLE}
|
|
|
|
margin-left: ${9 + currentIndex * (VARS.SCREEN.X * VARS.SCALE + 34)}px;
|
|
|
|
margin-top: ${9 + height}px;
|
|
|
|
`);
|
|
|
|
};
|