nixos-configs/config/ags/js/misc/closer.js

35 lines
774 B
JavaScript
Raw Normal View History

const { Window, EventBox } = ags.Widget;
const { closeWindow } = ags.App;
const ALWAYS_OPEN = [
'closer',
'bar',
'notifications',
];
2023-09-14 13:33:59 -04:00
// TODO: close on scroll event too?
export const closeAll = () => {
ags.App.windows.forEach(w => {
if (!ALWAYS_OPEN.some(window => window === w.name))
ags.App.closeWindow(w.name)
});
closeWindow('closer');
};
export const Closer = Window({
2023-09-11 19:57:21 -04:00
name: 'closer',
popup: true,
layer: 'top',
anchor: 'top bottom left right',
child: EventBox({
onPrimaryClickRelease: () => closeAll(),
connections: [[ags.App, (_b, _w, _v) => {
if (!Array.from(ags.App.windows).some(w => w[1].visible &&
!ALWAYS_OPEN.some(window => window === w[0]))) {
closeWindow('closer');
}
}]],
2023-09-11 19:57:21 -04:00
}),
});