feat(ags): highlight current workspace

This commit is contained in:
matt1432 2023-09-20 21:52:04 -04:00
parent c057ebd15b
commit e971902e77
3 changed files with 29 additions and 4 deletions

View file

@ -6,6 +6,10 @@ import { EventBox } from '../misc/cursorbox.js';
const SCALE = 0.11; const SCALE = 0.11;
const MARGIN = 8; const MARGIN = 8;
const SCREEN = {
X: 1920,
Y: 1200,
}
const DEFAULT_SPECIAL = { const DEFAULT_SPECIAL = {
SIZE_X: 1524, SIZE_X: 1524,
SIZE_Y: 908, SIZE_Y: 908,
@ -54,20 +58,18 @@ export const Overview = Window({
}], }],
], ],
properties: [ properties: [
['canUpdate', true],
['workspaces'], ['workspaces'],
['clients'],
['updateApps', box => { ['updateApps', box => {
ags.Utils.execAsync('hyprctl clients -j') ags.Utils.execAsync('hyprctl clients -j')
.then(result => { .then(result => {
box._clients = JSON.parse(result).filter(client => client.class) let clients = JSON.parse(result).filter(client => client.class)
box._workspaces.forEach(workspace => { box._workspaces.forEach(workspace => {
let fixed = workspace.children[0].child; let fixed = workspace.children[0].child;
let toRemove = fixed.get_children(); let toRemove = fixed.get_children();
box._clients.filter(app => app.workspace.id == workspace._id).forEach(app => { clients.filter(app => app.workspace.id == workspace._id).forEach(app => {
let active = ''; let active = '';
if (app.address == Hyprland.active.client.address) { if (app.address == Hyprland.active.client.address) {
active = 'active'; active = 'active';
@ -148,6 +150,13 @@ export const Overview = Window({
['id', ws.id], ['id', ws.id],
], ],
className: 'workspace', className: 'workspace',
style: `min-width: ${SCREEN.X * SCALE}px;
min-height: ${SCREEN.Y * SCALE}px;`,
connections: [[Hyprland, box => {
let active = Hyprland.active.workspace.id === box._id;
box.toggleClassName('active', active);
box.visible = Hyprland.getWorkspace(box._id)?.windows > 0 || active;
}]],
child: EventBox({ child: EventBox({
tooltipText: `Workspace: ${ws.id}`, tooltipText: `Workspace: ${ws.id}`,
child: ags.Widget({ child: ags.Widget({

View file

@ -2,6 +2,16 @@
min-height: 1px; min-height: 1px;
min-width: 1px; min-width: 1px;
.workspace {
padding: 4px;
border: 2px solid transparent;
border-radius: 10px;
&.active {
border: 2px solid black;
}
}
.workspace .window { .workspace .window {
border-radius: 10px; border-radius: 10px;
margin: 0 10px; margin: 0 10px;

View file

@ -668,6 +668,12 @@ calendar:indeterminate {
.overview { .overview {
min-height: 1px; min-height: 1px;
min-width: 1px; } min-width: 1px; }
.overview .workspace {
padding: 4px;
border: 2px solid transparent;
border-radius: 10px; }
.overview .workspace.active {
border: 2px solid black; }
.overview .workspace .window { .overview .workspace .window {
border-radius: 10px; border-radius: 10px;
margin: 0 10px; margin: 0 10px;