From 653961ada1347567aa9ce02de400e9849183ece1 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 28 Oct 2024 14:45:10 -0400 Subject: [PATCH] feat(agsV2): migrate screenshot window --- nixosModules/ags/v2/app.ts | 2 + nixosModules/ags/v2/default.nix | 2 +- nixosModules/ags/v2/lib.ts | 17 +- nixosModules/ags/v2/package-lock.json | Bin 74915 -> 74915 bytes nixosModules/ags/v2/package.json | 4 +- .../ags/v2/services/monitor-clicks.ts | 41 +++-- nixosModules/ags/v2/style.scss | 1 + .../ags/v2/widgets/applauncher/app-item.tsx | 21 +-- .../ags/v2/widgets/applauncher/main.tsx | 25 +-- nixosModules/ags/v2/widgets/bar/style.scss | 2 + nixosModules/ags/v2/widgets/date/style.scss | 5 - nixosModules/ags/v2/widgets/notifs/style.scss | 2 - .../ags/v2/widgets/powermenu/main.tsx | 3 + .../ags/v2/widgets/screenshot/main.tsx | 163 ++++++++++++++++++ .../ags/v2/widgets/screenshot/style.scss | 25 +++ 15 files changed, 259 insertions(+), 54 deletions(-) create mode 100644 nixosModules/ags/v2/widgets/screenshot/main.tsx create mode 100644 nixosModules/ags/v2/widgets/screenshot/style.scss diff --git a/nixosModules/ags/v2/app.ts b/nixosModules/ags/v2/app.ts index 89a525e5..828e52e3 100644 --- a/nixosModules/ags/v2/app.ts +++ b/nixosModules/ags/v2/app.ts @@ -12,6 +12,7 @@ import Corners from './widgets/corners/main'; import IconBrowser from './widgets/icon-browser/main'; import { NotifPopups, NotifCenter } from './widgets/notifs/main'; import PowerMenu from './widgets/powermenu/main'; +import Screenshot from './widgets/screenshot/main'; import MonitorClicks from './services/monitor-clicks'; @@ -48,6 +49,7 @@ switch (CONF) { NotifPopups(); NotifCenter(); PowerMenu(); + Screenshot(); new MonitorClicks(); }, diff --git a/nixosModules/ags/v2/default.nix b/nixosModules/ags/v2/default.nix index 9eea8d5f..89d69ec9 100644 --- a/nixosModules/ags/v2/default.nix +++ b/nixosModules/ags/v2/default.nix @@ -51,7 +51,7 @@ self: { }) // { "${configDir}/node_modules".source = - buildNodeModules ./. "sha256-f0hbPvHTqeFM7mfmV+sN4EEuE0F91f5kjJ/EHy0oU+Y="; + buildNodeModules ./. "sha256-pK9S6qUjTIL0JDegYJlHSY5XEpLFKfA98MfZ59Q3IL4="; "${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" { "$schema" = "https://json.schemastore.org/tsconfig"; diff --git a/nixosModules/ags/v2/lib.ts b/nixosModules/ags/v2/lib.ts index c5a54c71..e058d889 100644 --- a/nixosModules/ags/v2/lib.ts +++ b/nixosModules/ags/v2/lib.ts @@ -1,4 +1,6 @@ -import { Gdk } from 'astal/gtk3'; +import { App, Gdk, Widget } from 'astal/gtk3'; + +import AstalApps from 'gi://AstalApps'; import AstalHyprland from 'gi://AstalHyprland'; const Hyprland = AstalHyprland.get_default(); @@ -109,3 +111,16 @@ export const centerCursor = async(): Promise => { await hyprMessage(`dispatch movecursor ${x} ${y}`); }; + +export const get_app_icon = (app: AstalApps.Application): string => { + if (app.get_icon_name() && Widget.Icon.lookup_icon(app.get_icon_name())) { + return app.get_icon_name(); + } + else { + const iconString = app.get_key('Icon'); + + App.add_icons(iconString); + + return iconString; + } +}; diff --git a/nixosModules/ags/v2/package-lock.json b/nixosModules/ags/v2/package-lock.json index 048cc24b97efad49387fe2d8ef66dd008d90d77c..84fc13557c33a0ea9d446aeeac2d5ffe4c6b55ad 100644 GIT binary patch delta 1604 zcmZvcO>Em_7{`^h9b>GlgRQVJ7#(O53!T4e$LScuj+59)o%kbmoJdHE6FZLM*h%bs z`Lt@>hBUNSqL*n@ngkbwhAQATvEzh)kZ z$T@IxZCaTJ-=9AkRjHY?O5V!4=$c(dgj@-wpsdMsTa%(GuhhsfD-O}lM5#4PJRT2y zuiq(lXs6=4BGL8q9I1_S9gDDBc2q-o-M~zt&*VJD(l@@1MZdpvc?I0Rd>GvM;KS%{ zon8hXvoFq_j{eRLVDpT(zyetSKr=-j`*nmV+I$lyu9^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#K6Dy;xE`~fc zGqMGhh@|Tw6E1X8$rh5L{B9P*#B?<{(>oXI)%DCY7#dpE0$boSNj*iV= z+Cz90JdeLUGpewjCVQhy&KojK3=fSG#Uz|6u^G$g4Sk1gU}hc7!HSy5iXFbJMVewr z?G8q9%1aECB+?gKG)$^yHyF`kF2)3K2eHRSCv>O4l6-ha;cm^Br`9;}%wB8fW;}I- zC#YV~DT{12TZpAB&o&+32xG-gLl-f>*cuF!zHCzNK+*d6P>--hp(N6VGbDOq1CEsl z*dn@uT({Tz<4aYt6$b@>{FMeb*kAW3xwfO@pLAsQYh30-O}8k=EvcWOj9%EG%MyFoiH=gD#5WzC7#C_c zTz9p@y9L`x*;EJM#FN`!EBE#)Spau(M`vtuo9LOODELtuHG54S8TVbdvI- zBKSgOrfhF!eovrogV3iJK$APa$Kt}cdq3DQITmz~fuX+us-`f103dzF3A1eRUc-KVw)=^v1DPN@+5P23`;0 zyKOen%jV-shp6V n.namespace.startsWith(name), ) || - // Return an empty Layer if widget doesn't exist - { - address: '', - x: 0, - y: 0, - w: 0, - h: 0, - namespace: '', - }, + // Return an empty Layer if widget doesn't exist + { + address: '', + x: 0, + y: 0, + w: 0, + h: 0, + namespace: '', + }, ); }); return arr; }; const clickIsOnWidget = (w: Layer) => { - return pos.x > w.x && pos.x < w.x + w.w && - pos.y > w.y && pos.y < w.y + w.h; + return ( + pos.x > w.x && pos.x < w.x + w.w && + pos.y > w.y && pos.y < w.y + w.h + ); }; const noCloseWidgets = getNoCloseWidgets(noCloseWidgetsNames); @@ -158,24 +160,25 @@ export default class MonitorClicks extends GObject.Object { const widgets = overlayLayer.filter((n) => { let window = null as null | PopupWindow; - if (App.get_windows().some((win) => - win.name === n.namespace)) { + if (App.get_windows().some((win) => win.name === n.namespace)) { window = (App.get_window(n.namespace) as PopupWindow); } return window && - window.close_on_unfocus && - window.close_on_unfocus === - clickStage; + window.close_on_unfocus && + window.close_on_unfocus === + clickStage; }); if (noCloseWidgets.some(clickIsOnWidget)) { - // Don't handle clicks when on certain widgets + // Don't handle clicks when on certain widgets } else { widgets.forEach((w) => { - if (!(pos.x > w.x && pos.x < w.x + w.w && - pos.y > w.y && pos.y < w.y + w.h)) { + if (!( + pos.x > w.x && pos.x < w.x + w.w && + pos.y > w.y && pos.y < w.y + w.h + )) { App.get_window(w.namespace)?.set_visible(false); } }); diff --git a/nixosModules/ags/v2/style.scss b/nixosModules/ags/v2/style.scss index e8dc409f..fbbbb6e0 100644 --- a/nixosModules/ags/v2/style.scss +++ b/nixosModules/ags/v2/style.scss @@ -19,3 +19,4 @@ window, viewport { @import 'widgets/lockscreen/style.scss'; @import 'widgets/notifs/style.scss'; @import 'widgets/powermenu/style.scss'; +@import 'widgets/screenshot/style.scss'; diff --git a/nixosModules/ags/v2/widgets/applauncher/app-item.tsx b/nixosModules/ags/v2/widgets/applauncher/app-item.tsx index e21141e3..9677ef35 100644 --- a/nixosModules/ags/v2/widgets/applauncher/app-item.tsx +++ b/nixosModules/ags/v2/widgets/applauncher/app-item.tsx @@ -1,6 +1,8 @@ -import { App, Gtk, Widget } from 'astal/gtk3'; +import { Gtk, Widget } from 'astal/gtk3'; import { register } from 'astal/gobject'; +import { get_app_icon } from '../../lib'; + /* Types */ import AstalApps from 'gi://AstalApps'; type AppItemProps = Widget.BoxProps & { @@ -26,18 +28,11 @@ export class AppItem extends Widget.Box { this.app = app; const icon = ( - - ) as Widget.Icon; - - if (app.get_icon_name() && Widget.Icon.lookup_icon(app.get_icon_name())) { - icon.icon = this.app.get_icon_name(); - } - else { - const iconString = this.app.get_key('Icon'); - - App.add_icons(iconString); - icon.icon = iconString; - } + + ); const textBox = ( { + )); + }; + + Hyprland.connect('notify::clients', updateWindows); + Hyprland.connect('notify::focused-workspace', updateWindows); + + const Shown = Variable('monitors'); + + const stack = ( + + + + {bind(Hyprland, 'monitors').as((monitors) => monitors.map((monitor) => ( + + )))} + + + + + {windowList} + + + ) as Widget.Stack; + + const StackButton = ({ label = '', iconName = '' }) => ( + + ) as Widget.Button; + + const regionButton = ( + + ) as Widget.Button; + + return ( + { + updateWindows(); + }} + > + + + + + {regionButton} + + + {stack} + + + ); +}; diff --git a/nixosModules/ags/v2/widgets/screenshot/style.scss b/nixosModules/ags/v2/widgets/screenshot/style.scss new file mode 100644 index 00000000..735dcfab --- /dev/null +++ b/nixosModules/ags/v2/widgets/screenshot/style.scss @@ -0,0 +1,25 @@ +.screenshot { + font-size: 30px; + + .header { + .header-btn { + margin: 5px; + transition: background 400ms; + + &.active { + background: $window_bg_color; + } + } + } + + scrollable { + margin: 5px; + min-height: 400px; + + box { + .item-btn { + margin: 3px; + } + } + } +}