From a7fdacd25231a07f15351be616aad5bd4440fc6c Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 7 Oct 2023 20:41:24 -0400 Subject: [PATCH] feat(ags bar): disappear on fullscreen --- config/ags/js/bar/fullscreen.js | 81 +++++++++++++++++++++++++++++++++ config/ags/js/bar/main.js | 11 +++-- 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 config/ags/js/bar/fullscreen.js diff --git a/config/ags/js/bar/fullscreen.js b/config/ags/js/bar/fullscreen.js new file mode 100644 index 00000000..d73a2e7b --- /dev/null +++ b/config/ags/js/bar/fullscreen.js @@ -0,0 +1,81 @@ +import { Widget, Hyprland, Utils, Variable } from '../../imports.js'; +const { Box, EventBox } = Widget; + +const Revealed = Variable(true); +const Hovering = Variable(false); + +import { Gesture } from './gesture.js'; + + +export const Revealer = params => Box({ + style: 'min-height: 1px', + vertical: true, + children: [ + Widget.Revealer({ + transition: 'slide_down', + setup: self => self.revealChild = true, + properties: [ + ['timeouts', []], + ], + connections: [[Hyprland, self => { + Utils.execAsync('hyprctl activewindow -j') + .then(result => { + let client = JSON.parse(result); + if (client.fullscreen === Revealed.value) return; + + Revealed.value = client.fullscreen; + + if (Revealed.value) { + setTimeout(() => { + if (Revealed.value) + self.revealChild = false + }, 2000); + } + else { + self.revealChild = true; + } + }).catch(print); + }]], + + child: Gesture({ + onHover: () => Hovering.value = true, + onHoverLost: self => { + Hovering.value = false; + if (Revealed.value) { + setTimeout(() => { + if (!Hovering.value) { + self.get_parent().get_parent().children[1].revealChild = true; + self.get_parent().revealChild = false; + } + }, 2000); + } + }, + ...params, + }), + }), + + Widget.Revealer({ + connections: [[Revealed, self => { + if (Revealed.value) { + setTimeout(() => { + if (Revealed.value) + self.revealChild = true; + }, 2000); + } + else { + self.revealChild = false; + } + }]], + child: EventBox({ + onHover: self => { + Hovering.value = true; + self.get_parent().get_parent().children[0].revealChild = true; + self.get_parent().revealChild = false; + }, + child: Box({ + style: 'min-height: 50px;', + }), + }), + }), + ], +}); diff --git a/config/ags/js/bar/main.js b/config/ags/js/bar/main.js index 0e79b9fb..193e9e9e 100644 --- a/config/ags/js/bar/main.js +++ b/config/ags/js/bar/main.js @@ -13,7 +13,7 @@ import { SysTray } from './systray.js'; import { BatteryIndicator } from './battery.js'; import { Brightness } from './brightness.js'; import { AudioIndicator } from './audio.js'; -import { Gesture } from './gesture.js'; +import { Revealer } from './fullscreen.js'; export const Bar = Window({ @@ -21,8 +21,7 @@ export const Bar = Window({ layer: 'overlay', anchor: 'top left right', exclusive: true, - - child: Gesture({ + child: Revealer({ child: CenterBox({ className: 'transparent', halign: 'fill', @@ -56,7 +55,11 @@ export const Bar = Window({ ], }), - centerWidget: CurrentWindow, + centerWidget: Box({ + children: [ + CurrentWindow, + ], + }), endWidget: Box({ halign: 'end',