nixos-configs/devices/wim/config/ags/js/bar/fullscreen.js

74 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-11-16 00:48:50 -05:00
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';
const BarCloser = (variable) => 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({
onHover: (self) => {
2023-11-16 00:48:50 -05:00
variable.value = false;
self.get_parent().visible = false;
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'padding: 1px',
}),
}),
});
export default (props) => {
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,
2023-11-16 00:48:50 -05:00
connections: [
[Hyprland.active, () => {
const workspace = Hyprland.getWorkspace(
Hyprland.active.workspace.id,
);
2023-11-16 00:48:50 -05:00
Revealed.value = !workspace?.hasfullscreen;
}],
[Hyprland, (_, fullscreen) => {
Revealed.value = !fullscreen;
}, 'fullscreen'],
2023-11-16 00:48:50 -05:00
],
2023-11-16 00:48:50 -05:00
children: [
Revealer({
...props,
2023-11-16 00:48:50 -05:00
transition: 'slide_down',
revealChild: true,
2023-11-16 00:48:50 -05:00
binds: [['revealChild', Revealed, 'value']],
}),
2023-11-16 00:48:50 -05:00
Revealer({
binds: [['revealChild', Revealed, 'value', (v) => !v]],
2023-11-16 00:48:50 -05:00
child: EventBox({
onHover: () => {
barCloser.visible = true;
Revealed.value = true;
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
2023-11-16 00:48:50 -05:00
],
});
};