nixos-configs/modules/ags/config/ts/bar/fullscreen.ts
matt1432 a0014161ce
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags): move wim and binto configs together under modules
2024-01-17 19:18:41 -05:00

87 lines
2.3 KiB
TypeScript

import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import { Box, EventBox, Revealer, Window } from 'resource:///com/github/Aylur/ags/widget.js';
// Types
import { Variable as Var } from 'types/variable';
import AgsBox from 'types/widgets/box';
import { RevealerProps } from 'types/widgets/revealer';
const BarCloser = (variable: Var<boolean>) => Window({
name: 'bar-closer',
visible: false,
anchor: ['top', 'bottom', 'left', 'right'],
layer: 'overlay',
child: EventBox({
on_hover: (self) => {
variable.value = false;
const parent = self.get_parent();
if (parent) {
parent.visible = false;
}
},
child: Box({
css: 'padding: 1px',
}),
}),
});
export default (props: RevealerProps) => {
const Revealed = Variable(true);
const barCloser = BarCloser(Revealed);
return Box({
css: 'min-height: 1px',
hexpand: true,
vertical: true,
setup: (self) => {
const checkCurrentWsFsState = () => {
const workspace = Hyprland.getWorkspace(
Hyprland.active.workspace.id,
);
if (workspace) {
Revealed.value = !workspace['hasfullscreen'];
}
};
const checkGlobalFsState = (_: AgsBox, fullscreen: boolean) => {
Revealed.value = !fullscreen;
};
self
.hook(Hyprland.active, checkCurrentWsFsState)
.hook(Hyprland, checkGlobalFsState, 'fullscreen');
},
children: [
Revealer({
...props,
transition: 'slide_down',
reveal_child: true,
}).bind('reveal_child', Revealed),
Revealer({
reveal_child: Revealed.bind()
.transform((v) => !v),
child: EventBox({
on_hover: () => {
barCloser.visible = true;
Revealed.value = true;
},
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
],
});
};