diff --git a/nixosModules/ags-v2/config/app.ts b/nixosModules/ags-v2/config/app.ts index e0b43005..b3b184a2 100644 --- a/nixosModules/ags-v2/config/app.ts +++ b/nixosModules/ags-v2/config/app.ts @@ -1,89 +1,4 @@ -import { execAsync } from 'astal'; -import { App } from 'astal/gtk3'; - import GLib from 'gi://GLib'; -import style from './style/main.scss'; -import AppLauncher from './widgets/applauncher/main'; -import Bar from './widgets/bar/wim'; -import BgFade from './widgets/bg-fade/main'; -import Calendar from './widgets/date/main'; -import Clipboard from './widgets/clipboard/main'; -import Corners from './widgets/corners/main'; -import IconBrowser from './widgets/icon-browser/main'; -import { NotifPopups, NotifCenter } from './widgets/notifs/main'; -import OSD from './widgets/osd/main'; -import PowerMenu from './widgets/powermenu/main'; -import Screenshot from './widgets/screenshot/main'; - -import { closeAll as closeAllFunc } from './lib'; -import BrightnessService from './services/brightness'; -import MonitorClicks from './services/monitor-clicks'; - -import Lockscreen from './widgets/lockscreen/main'; - -declare global { - function closeAll(): void; - // eslint-disable-next-line - var Brightness: typeof BrightnessService; -} -globalThis.closeAll = closeAllFunc; -globalThis.Brightness = BrightnessService; - - -const CONF = GLib.getenv('CONF'); - -switch (CONF) { - case 'lock': { - App.start({ - css: style, - instanceName: CONF, - - main: () => { - Lockscreen(); - }, - }); - - break; - } - - case 'wim': { - App.start({ - css: style, - - requestHandler(js, res) { - App.eval(js).then(res).catch(res); - }, - - main: () => { - execAsync('hyprpaper').catch(print); - - AppLauncher(); - Bar(); - BgFade(); - Calendar(); - Clipboard(); - Corners(); - IconBrowser(); - NotifPopups(); - NotifCenter(); - OSD(); - PowerMenu(); - Screenshot(); - - Brightness.initService({ - kbd: 'tpacpi::kbd_backlight', - caps: 'input1::capslock', - }); - new MonitorClicks(); - - setTimeout(() => { - App.get_window('win-applauncher')?.set_visible(true); - }, 3 * 1000); - }, - }); - - break; - } -} +(await import(`./configurations/${GLib.getenv('CONF')}.ts`)).default(); diff --git a/nixosModules/ags-v2/config/configurations/lock.ts b/nixosModules/ags-v2/config/configurations/lock.ts new file mode 100644 index 00000000..63e8acf7 --- /dev/null +++ b/nixosModules/ags-v2/config/configurations/lock.ts @@ -0,0 +1,17 @@ +export default async() => { + const { App } = await import('astal/gtk3'); + + const Lockscreen = (await import('../widgets/lockscreen/main')).default; + + const style = (await import('../style/lock.scss')).default; + + + App.start({ + css: style, + instanceName: 'lock', + + main: () => { + Lockscreen(); + }, + }); +}; diff --git a/nixosModules/ags-v2/config/configurations/wim.ts b/nixosModules/ags-v2/config/configurations/wim.ts new file mode 100644 index 00000000..db6a2190 --- /dev/null +++ b/nixosModules/ags-v2/config/configurations/wim.ts @@ -0,0 +1,61 @@ +export default async() => { + const { execAsync } = await import('astal'); + const { App } = await import('astal/gtk3'); + + const style = (await import('../style/main.scss')).default; + + 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 Calendar = (await import('../widgets/date/main')).default; + const Clipboard = (await import('../widgets/clipboard/main')).default; + const Corners = (await import('../widgets/corners/main')).default; + const IconBrowser = (await import('../widgets/icon-browser/main')).default; + const { NotifPopups, NotifCenter } = await import('../widgets/notifs/main'); + const OSD = (await import('../widgets/osd/main')).default; + const PowerMenu = (await import('../widgets/powermenu/main')).default; + const Screenshot = (await import('../widgets/screenshot/main')).default; + + const { closeAll } = await import('../lib'); + const Brightness = (await import('../services/brightness')).default; + const MonitorClicks = (await import('../services/monitor-clicks')).default; + + globalThis.closeAll = closeAll; + globalThis.Brightness = Brightness; + + + App.start({ + css: style, + + requestHandler(js, res) { + App.eval(js).then(res).catch(res); + }, + + main: () => { + execAsync('hyprpaper').catch(print); + + AppLauncher(); + Bar(); + BgFade(); + Calendar(); + Clipboard(); + Corners(); + IconBrowser(); + NotifPopups(); + NotifCenter(); + OSD(); + PowerMenu(); + Screenshot(); + + Brightness.initService({ + kbd: 'tpacpi::kbd_backlight', + caps: 'input1::capslock', + }); + new MonitorClicks(); + + setTimeout(() => { + App.get_window('win-applauncher')?.set_visible(true); + }, 3 * 1000); + }, + }); +}; diff --git a/nixosModules/ags-v2/config/env.d.ts b/nixosModules/ags-v2/config/env.d.ts index 0c89cd4b..309b1573 100644 --- a/nixosModules/ags-v2/config/env.d.ts +++ b/nixosModules/ags-v2/config/env.d.ts @@ -1,6 +1,11 @@ -/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars, no-var */ + const SRC: string; +var Brightness: import('./services/brightness').default; + +function closeAll(): void; + declare module 'inline:*' { const content: string; diff --git a/nixosModules/ags-v2/config/style/lock.scss b/nixosModules/ags-v2/config/style/lock.scss new file mode 100644 index 00000000..853a0dce --- /dev/null +++ b/nixosModules/ags-v2/config/style/lock.scss @@ -0,0 +1,3 @@ +@use 'common'; + +@use '../widgets/lockscreen'; diff --git a/nixosModules/ags-v2/config/style/main.scss b/nixosModules/ags-v2/config/style/main.scss index 8449c5dd..f8aa1342 100644 --- a/nixosModules/ags-v2/config/style/main.scss +++ b/nixosModules/ags-v2/config/style/main.scss @@ -5,7 +5,6 @@ @use '../widgets/clipboard'; @use '../widgets/date'; @use '../widgets/icon-browser'; -@use '../widgets/lockscreen'; @use '../widgets/misc'; @use '../widgets/notifs'; @use '../widgets/osd'; diff --git a/nixosModules/ags-v2/config/widgets/lockscreen/main.tsx b/nixosModules/ags-v2/config/widgets/lockscreen/main.tsx index f985dcda..925cd1d2 100644 --- a/nixosModules/ags-v2/config/widgets/lockscreen/main.tsx +++ b/nixosModules/ags-v2/config/widgets/lockscreen/main.tsx @@ -8,30 +8,28 @@ import Lock from 'gi://GtkSessionLock'; import Separator from '../misc/separator'; import { get_hyprland_monitor_desc } from '../../lib'; -declare global { - function authFinger(): void; -} - // This file is generated by Nix import Vars from './vars'; +/* Types */ +declare global { + function authFinger(): void; +} +@register() +class BlurredBox extends Widget.Box { + geometry = {} as { w: number, h: number }; +} -export default () => { - const lock = Lock.prepare_lock(); - const windows = new Map(); - @register() - class BlurredBox extends Widget.Box { - geometry = {} as { w: number, h: number }; - } - const blurBGs: BlurredBox[] = []; +const windows = new Map(); +const blurBGs: BlurredBox[] = []; - const transition_duration = 1000; - const WINDOW_MARGINS = -2; - const ENTRY_SPACING = 20; - const CLOCK_SPACING = 60; +const transition_duration = 1000; +const WINDOW_MARGINS = -2; +const ENTRY_SPACING = 20; +const CLOCK_SPACING = 60; - const bgCSS = ({ w = 1, h = 1 } = {}) => ` +const bgCSS = ({ w = 1, h = 1 } = {}) => ` border: 2px solid rgba(189, 147, 249, 0.8); background: rgba(0, 0, 0, 0.2); min-height: ${h}px; @@ -40,201 +38,205 @@ export default () => { min-width ${transition_duration / 2}ms; `; - const unlock = () => { - blurBGs.forEach((b) => { +const lock = Lock.prepare_lock(); + +const unlock = () => { + blurBGs.forEach((b) => { + b.css = bgCSS({ + w: b.geometry.w, + h: 1, + }); + + timeout(transition_duration / 2, () => { b.css = bgCSS({ - w: b.geometry.w, + w: 1, h: 1, }); - - timeout(transition_duration / 2, () => { - b.css = bgCSS({ - w: 1, - h: 1, - }); - }); }); - timeout(transition_duration, () => { - lock.unlock_and_destroy(); - Gdk.Display.get_default()?.sync(); - App.quit(); - }); - }; - - const Clock = () => { - const time = Variable('').poll(1000, () => { - return (new Date().toLocaleString([], { - hour: 'numeric', - minute: 'numeric', - hour12: true, - }) ?? '') - .replace('a.m.', 'AM') - .replace('p.m.', 'PM'); - }); - - return ( -