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

99 lines
3.5 KiB
JavaScript
Raw Normal View History

import App from 'resource:///com/github/Aylur/ags/app.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import { Box, EventBox, Overlay, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
2023-10-07 20:41:24 -04:00
import { RoundedCorner } from '../screen-corners.js';
2023-10-07 20:41:24 -04:00
2023-10-22 13:39:13 -04:00
const Revealed = Variable(true);
const Hovering = Variable(false);
const wStyle = 'background: rgba(0, 0, 0, 0.5);';
2023-10-07 20:41:24 -04:00
Hyprland.connect('changed', () => {
const workspace = Hyprland.getWorkspace(Hyprland.active.workspace.id);
if (workspace)
Revealed.value = workspace.hasfullscreen;
});
Hyprland.connect('fullscreen', (_, fullscreen) => Revealed.value = fullscreen);
2023-10-17 23:21:24 -04:00
export default props => Overlay({
overlays: [
RoundedCorner('topleft', { className: 'corner' }),
RoundedCorner('topright', { className: 'corner' }),
],
2023-10-16 13:55:31 -04:00
child: Box({
2023-11-06 18:37:23 -05:00
css: 'min-height: 1px',
hexpand: true,
vertical: true,
children: [
Revealer({
transition: 'slide_down',
setup: self => self.revealChild = true,
properties: [['timeouts', []]],
connections: [[Revealed, self => {
App.getWindow('bar').setCss(Revealed.value ? '' : wStyle);
App.getWindow('bg-gradient').visible = !Revealed.value;
2023-10-22 13:39:13 -04:00
if (Revealed.value) {
timeout(2000, () => {
if (Revealed.value)
self.revealChild = false;
});
}
else {
self.revealChild = true;
}
}]],
2023-10-16 13:55:31 -04:00
child: EventBox({
onHover: () => Hovering.value = true,
onHoverLost: self => {
Hovering.value = false;
if (Revealed.value) {
timeout(2000, () => {
if (!Hovering.value) {
// Replace bar with transparent eventbox
self.get_parent().get_parent().children[1].revealChild = true;
self.get_parent().revealChild = false;
}
});
}
},
...props,
}),
}),
2023-10-07 20:41:24 -04:00
Revealer({
connections: [[Revealed, self => {
if (Revealed.value) {
timeout(2000, () => {
if (Revealed.value)
self.revealChild = true;
});
}
else {
self.revealChild = false;
}
}]],
child: EventBox({
onHover: self => {
Hovering.value = true;
// Replace eventbox with bar
self.get_parent().get_parent().children[0].revealChild = true;
self.get_parent().revealChild = false;
},
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
],
}),
2023-10-07 20:41:24 -04:00
});