From a2e9b4f2ed9c87d603811b0d146e480f45f0756a Mon Sep 17 00:00:00 2001 From: SuperSuslik312 Date: Thu, 10 Oct 2024 23:29:41 +0300 Subject: [PATCH] Added an option to appear tray on mouse hover --- .../ags/modules/.configuration/user_options.js | 4 ++++ .config/ags/modules/bar/normal/spaceright.js | 16 ++++++++++++++-- .config/ags/modules/bar/normal/tray.js | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 13be1e91d..8d6377523 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -31,6 +31,10 @@ let configOptions = { 'layerSmokeStrength': 0.2, 'barRoundCorners': 1, // 0: No, 1: Yes 'fakeScreenRounding': 1, // 0: None | 1: Always | 2: When not fullscreen + 'onHoverTray': { // Appears the tray only on mouse hover + 'enabled': false, + 'delay': 5000, // Delay, in milliseconds, before the tray disappears again + }, }, 'apps': { 'bluetooth': "blueberry", diff --git a/.config/ags/modules/bar/normal/spaceright.js b/.config/ags/modules/bar/normal/spaceright.js index 626663894..285adc3aa 100644 --- a/.config/ags/modules/bar/normal/spaceright.js +++ b/.config/ags/modules/bar/normal/spaceright.js @@ -40,8 +40,20 @@ export default (monitor = 0) => { }), }, monitor); const SpaceRightDefaultClicks = (child) => Widget.EventBox({ - onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) }, - onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) }, + onHover: () => { + barStatusIcons.toggleClassName('bar-statusicons-hover', true); + if (userOptions.appearance.onHoverTray.enabled == true) { + barTray.children[0].revealChild = true; + } + }, + onHoverLost: () => { + barStatusIcons.toggleClassName('bar-statusicons-hover', false); + if (userOptions.appearance.onHoverTray.enabled == true) { + setTimeout(() => { + barTray.children[0].revealChild = false; + }, userOptions.appearance.onHoverTray.delay) + } + }, onPrimaryClick: () => App.toggleWindow('sideright'), onSecondaryClick: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print), onMiddleClick: () => execAsync('playerctl play-pause').catch(print), diff --git a/.config/ags/modules/bar/normal/tray.js b/.config/ags/modules/bar/normal/tray.js index d568bc769..8475380ff 100644 --- a/.config/ags/modules/bar/normal/tray.js +++ b/.config/ags/modules/bar/normal/tray.js @@ -24,7 +24,7 @@ export const Tray = (props = {}) => { , }); const trayRevealer = Widget.Revealer({ - revealChild: true, + revealChild: !userOptions.appearance.onHoverTray.enabled, transition: 'slide_left', transitionDuration: userOptions.animations.durationLarge, child: trayContent,