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 048cc24b..84fc1355 100644 Binary files a/nixosModules/ags/v2/package-lock.json and b/nixosModules/ags/v2/package-lock.json differ diff --git a/nixosModules/ags/v2/package.json b/nixosModules/ags/v2/package.json index 64ba3347..b42f2c9e 100644 --- a/nixosModules/ags/v2/package.json +++ b/nixosModules/ags/v2/package.json @@ -6,12 +6,12 @@ "@eslint/js": "9.13.0", "@stylistic/eslint-plugin": "2.9.0", "@types/eslint__js": "8.42.3", - "@types/node": "22.7.7", + "@types/node": "22.8.1", "eslint": "9.13.0", "eslint-plugin-jsdoc": "50.4.3", "fzf": "0.5.2", "jiti": "2.3.3", "typescript": "5.6.3", - "typescript-eslint": "8.10.0" + "typescript-eslint": "8.11.0" } } diff --git a/nixosModules/ags/v2/services/monitor-clicks.ts b/nixosModules/ags/v2/services/monitor-clicks.ts index f4b2850f..c207b9f1 100644 --- a/nixosModules/ags/v2/services/monitor-clicks.ts +++ b/nixosModules/ags/v2/services/monitor-clicks.ts @@ -134,23 +134,25 @@ export default class MonitorClicks extends GObject.Object { overlayLayer.find( (n) => 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; + } + } + } +}