nixos-configs/modules/ags/config/ts/bar/fullscreen.ts

87 lines
2.2 KiB
TypeScript
Raw Normal View History

const Hyprland = await Service.import('hyprland');
2023-11-16 00:48:50 -05:00
const { Box, EventBox, Revealer, Window } = Widget;
2023-11-16 00:48:50 -05:00
2024-01-13 11:15:08 -05:00
// Types
import { Variable as Var } from 'types/variable';
import { BoxGeneric, DefaultProps } from 'global-types';
2023-11-16 00:48:50 -05:00
2024-01-13 11:15:08 -05:00
const BarCloser = (variable: Var<boolean>) => Window({
2023-11-16 00:48:50 -05:00
name: 'bar-closer',
visible: false,
anchor: ['top', 'bottom', 'left', 'right'],
layer: 'overlay',
2023-11-16 00:48:50 -05:00
child: EventBox({
2023-12-18 18:00:30 -05:00
on_hover: (self) => {
2024-02-11 02:18:59 -05:00
variable.setValue(false);
const parent = self.get_parent();
if (parent) {
parent.visible = false;
}
2023-11-16 00:48:50 -05:00
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'padding: 1px',
}),
}),
});
export default (props?: DefaultProps) => {
2023-11-16 00:48:50 -05:00
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) {
2024-02-11 02:18:59 -05:00
Revealed.setValue(!workspace['hasfullscreen']);
}
};
const checkGlobalFsState = (_: BoxGeneric, fullscreen: boolean) => {
2024-02-11 02:18:59 -05:00
Revealed.setValue(!fullscreen);
};
self
.hook(Hyprland.active, checkCurrentWsFsState)
.hook(Hyprland, checkGlobalFsState, 'fullscreen');
},
2023-11-16 00:48:50 -05:00
children: [
Revealer({
...props,
2023-11-16 00:48:50 -05:00
transition: 'slide_down',
2023-12-18 18:00:30 -05:00
reveal_child: true,
}).bind('reveal_child', Revealed),
2023-11-16 00:48:50 -05:00
Revealer({
reveal_child: Revealed.bind()
.transform((v) => !v),
2023-11-16 00:48:50 -05:00
child: EventBox({
2023-12-18 18:00:30 -05:00
on_hover: () => {
2023-11-16 00:48:50 -05:00
barCloser.visible = true;
2024-02-11 02:18:59 -05:00
Revealed.setValue(true);
2023-11-16 00:48:50 -05:00
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
2023-11-16 00:48:50 -05:00
],
});
};