From 461a77d9f0e6526699408ab8f58d6ab88c07d267 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 22 Sep 2023 22:39:43 -0400 Subject: [PATCH] feat(ags overview): add buttons on windows to focus --- config/ags/js/notifications/base.js | 2 +- config/ags/js/overview/main.js | 30 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/config/ags/js/notifications/base.js b/config/ags/js/notifications/base.js index abbd64a..8283d73 100644 --- a/config/ags/js/notifications/base.js +++ b/config/ags/js/notifications/base.js @@ -1,6 +1,6 @@ const { GLib } = imports.gi; const { Notifications, Applications } = ags.Service; -const { lookUpIcon, timeout, exec } = ags.Utils; +const { lookUpIcon, exec } = ags.Utils; const { Box, Icon, Label, Button } = ags.Widget; import { Draggable } from '../misc/drag.js'; diff --git a/config/ags/js/overview/main.js b/config/ags/js/overview/main.js index c11dcce..ff1d0b6 100644 --- a/config/ags/js/overview/main.js +++ b/config/ags/js/overview/main.js @@ -1,8 +1,10 @@ -const { Window, Box, CenterBox, Icon, Revealer } = ags.Widget; +const { Window, Box, CenterBox, Icon, Revealer, EventBox } = ags.Widget; +const { closeWindow } = ags.App; +const { execAsync } = ags.Utils; const { Hyprland, Applications } = ags.Service; const { Gtk } = imports.gi; -import { EventBox } from '../misc/cursorbox.js'; +import { Button } from '../misc/cursorbox.js'; import { PopUp } from '../misc/popup.js'; const WORKSPACE_PER_ROW = 6; @@ -167,8 +169,8 @@ const OverviewWidget = Box({ app.at[0] * SCALE, app.at[1] * SCALE, ); - existingApp.child.className = `window ${active}`; - existingApp.child.style = IconStyle(app); + existingApp.child.child.className = `window ${active}`; + existingApp.child.child.style = IconStyle(app); } else { fixed.put( @@ -181,10 +183,22 @@ const OverviewWidget = Box({ ['address', app.address], ['toDestroy', false] ], - child: Icon({ - className: `window ${active}`, - style: IconStyle(app), - icon: app.class, + child: Button({ + onPrimaryClickRelease: () => { + if (app.class === 'thunderbird' || app.class === 'Spotify') + execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${app.class}`]) + .then(() => closeWindow('overview')) + .catch(print); + else + execAsync(`hyprctl dispatch focuswindow address:${app.address}`) + .then(() => closeWindow('overview')) + .catch(print); + }, + child: Icon({ + className: `window ${active}`, + style: IconStyle(app), + icon: app.class, + }), }), }), app.at[0] * SCALE,