diff --git a/nixosModules/ags/config/app.ts b/nixosModules/ags/config/app.ts index 460fdcd0..ac690a4c 100644 --- a/nixosModules/ags/config/app.ts +++ b/nixosModules/ags/config/app.ts @@ -2,7 +2,6 @@ // TODO: quick-settings // TODO: music player stuff // TODO: on-screen-keyboard -// TODO: GSR import GLib from 'gi://GLib'; diff --git a/nixosModules/ags/config/configurations/binto.ts b/nixosModules/ags/config/configurations/binto.ts index 3ffbfa21..db27ec3d 100644 --- a/nixosModules/ags/config/configurations/binto.ts +++ b/nixosModules/ags/config/configurations/binto.ts @@ -6,6 +6,7 @@ export default async() => { const AppLauncher = (await import('../widgets/applauncher/main')).default; const Bar = (await import('../widgets/bar/binto')).default; + const BgLayer = (await import('../widgets/bg-layer/main')).default; const Calendar = (await import('../widgets/date/binto')).default; const Clipboard = (await import('../widgets/clipboard/main')).default; const { NotifPopups, NotifCenter } = await import('../widgets/notifs/binto'); @@ -13,7 +14,7 @@ export default async() => { const PowerMenu = (await import('../widgets/powermenu/main')).default; const Screenshot = (await import('../widgets/screenshot/main')).default; - const { closeAll } = await import('../lib'); + const { closeAll, perMonitor } = await import('../lib'); const Brightness = (await import('../services/brightness')).default; const GSR = (await import('../services/gpu-screen-recorder')).default; const MonitorClicks = (await import('../services/monitor-clicks')).default; @@ -48,6 +49,8 @@ export default async() => { main: () => { execAsync('hyprpaper').catch(() => { /**/ }); + perMonitor((monitor) => BgLayer(monitor, false)); + AppLauncher(); Bar(); Calendar(); diff --git a/nixosModules/ags/config/configurations/wim.ts b/nixosModules/ags/config/configurations/wim.ts index 3478fb0a..2f0aceb3 100644 --- a/nixosModules/ags/config/configurations/wim.ts +++ b/nixosModules/ags/config/configurations/wim.ts @@ -6,7 +6,7 @@ export default async() => { const AppLauncher = (await import('../widgets/applauncher/main')).default; const Bar = (await import('../widgets/bar/wim')).default; - const BgFade = (await import('../widgets/bg-fade/main')).default; + const BgLayer = (await import('../widgets/bg-layer/main')).default; const Calendar = (await import('../widgets/date/wim')).default; const Clipboard = (await import('../widgets/clipboard/main')).default; const Corners = (await import('../widgets/corners/main')).default; @@ -16,7 +16,7 @@ export default async() => { const PowerMenu = (await import('../widgets/powermenu/main')).default; const Screenshot = (await import('../widgets/screenshot/main')).default; - const { closeAll } = await import('../lib'); + const { closeAll, perMonitor } = await import('../lib'); const Brightness = (await import('../services/brightness')).default; const MonitorClicks = (await import('../services/monitor-clicks')).default; @@ -54,9 +54,10 @@ export default async() => { main: () => { execAsync('hyprpaper').catch(() => { /**/ }); + perMonitor((monitor) => BgLayer(monitor, true)); + AppLauncher(); Bar(); - BgFade(); Calendar(); Clipboard(); Corners(); diff --git a/nixosModules/ags/config/lib.ts b/nixosModules/ags/config/lib.ts index 789dec67..e23b29e6 100644 --- a/nixosModules/ags/config/lib.ts +++ b/nixosModules/ags/config/lib.ts @@ -1,4 +1,4 @@ -import { App, Gdk } from 'astal/gtk3'; +import { App, Gdk, Gtk } from 'astal/gtk3'; import AstalHyprland from 'gi://AstalHyprland'; const Hyprland = AstalHyprland.get_default(); @@ -83,7 +83,7 @@ export const hyprMessage = (message: string) => new Promise(( export const centerCursor = (): void => { let x: number; let y: number; - const monitor = Hyprland.get_monitors().find((m) => m.focused) as AstalHyprland.Monitor; + const monitor = Hyprland.get_focused_monitor(); switch (monitor.transform) { case 1: @@ -119,3 +119,29 @@ export const closeAll = () => { App.get_window(w.name)?.set_visible(false); }); }; + +export const perMonitor = (window: (monitor: Gdk.Monitor) => Gtk.Widget) => { + const display = Gdk.Display.get_default(); + const windows = new Map(); + + const createWindow = (monitor: Gdk.Monitor) => { + windows.set(monitor, window(monitor)); + }; + + for (let m = 0; m < (display?.get_n_monitors() ?? 0); m++) { + const monitor = display?.get_monitor(m); + + if (monitor) { + createWindow(monitor); + } + } + + display?.connect('monitor-added', (_, monitor) => { + createWindow(monitor); + }); + + display?.connect('monitor-removed', (_, monitor) => { + windows.get(monitor)?.destroy(); + windows.delete(monitor); + }); +}; diff --git a/nixosModules/ags/config/widgets/bg-fade/main.tsx b/nixosModules/ags/config/widgets/bg-fade/main.tsx deleted file mode 100644 index 2f53a00f..00000000 --- a/nixosModules/ags/config/widgets/bg-fade/main.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Astal } from 'astal/gtk3'; - - -export default () => { - return ( - - ); -}; diff --git a/nixosModules/ags/config/widgets/bg-layer/main.tsx b/nixosModules/ags/config/widgets/bg-layer/main.tsx new file mode 100644 index 00000000..345e70d6 --- /dev/null +++ b/nixosModules/ags/config/widgets/bg-layer/main.tsx @@ -0,0 +1,35 @@ +import { Astal, Gdk } from 'astal/gtk3'; + + +export default ( + monitor = Gdk.Display.get_default()?.get_monitor(0) as Gdk.Monitor, + gradient = true, +) => { + return ( + + ); +};