feat(agsV2): separate configs using async imports
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-01 18:16:43 -04:00
parent 07474f1209
commit 2082a2aeb4
7 changed files with 292 additions and 290 deletions

View file

@ -1,89 +1,4 @@
import { execAsync } from 'astal';
import { App } from 'astal/gtk3';
import GLib from 'gi://GLib'; import GLib from 'gi://GLib';
import style from './style/main.scss';
import AppLauncher from './widgets/applauncher/main'; (await import(`./configurations/${GLib.getenv('CONF')}.ts`)).default();
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;
}
}

View file

@ -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();
},
});
};

View file

@ -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);
},
});
};

View file

@ -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; const SRC: string;
var Brightness: import('./services/brightness').default;
function closeAll(): void;
declare module 'inline:*' { declare module 'inline:*' {
const content: string; const content: string;

View file

@ -0,0 +1,3 @@
@use 'common';
@use '../widgets/lockscreen';

View file

@ -5,7 +5,6 @@
@use '../widgets/clipboard'; @use '../widgets/clipboard';
@use '../widgets/date'; @use '../widgets/date';
@use '../widgets/icon-browser'; @use '../widgets/icon-browser';
@use '../widgets/lockscreen';
@use '../widgets/misc'; @use '../widgets/misc';
@use '../widgets/notifs'; @use '../widgets/notifs';
@use '../widgets/osd'; @use '../widgets/osd';

View file

@ -8,22 +8,20 @@ import Lock from 'gi://GtkSessionLock';
import Separator from '../misc/separator'; import Separator from '../misc/separator';
import { get_hyprland_monitor_desc } from '../../lib'; import { get_hyprland_monitor_desc } from '../../lib';
declare global {
function authFinger(): void;
}
// This file is generated by Nix // This file is generated by Nix
import Vars from './vars'; import Vars from './vars';
/* Types */
export default () => { declare global {
const lock = Lock.prepare_lock(); function authFinger(): void;
const windows = new Map<Gdk.Monitor, Gtk.Window>(); }
@register() @register()
class BlurredBox extends Widget.Box { class BlurredBox extends Widget.Box {
geometry = {} as { w: number, h: number }; geometry = {} as { w: number, h: number };
} }
const windows = new Map<Gdk.Monitor, Gtk.Window>();
const blurBGs: BlurredBox[] = []; const blurBGs: BlurredBox[] = [];
const transition_duration = 1000; const transition_duration = 1000;
@ -40,6 +38,8 @@ export default () => {
min-width ${transition_duration / 2}ms; min-width ${transition_duration / 2}ms;
`; `;
const lock = Lock.prepare_lock();
const unlock = () => { const unlock = () => {
blurBGs.forEach((b) => { blurBGs.forEach((b) => {
b.css = bgCSS({ b.css = bgCSS({
@ -102,8 +102,6 @@ export default () => {
}); });
}); });
blurBGs.push(rev); blurBGs.push(rev);
<window <window
@ -205,10 +203,13 @@ export default () => {
createWindow(monitor); createWindow(monitor);
} }
} }
display?.connect('monitor-added', (_, monitor) => { display?.connect('monitor-added', (_, monitor) => {
createWindow(monitor); createWindow(monitor);
}); });
lock.lock_lock(); lock.lock_lock();
windows.forEach((win, monitor) => { windows.forEach((win, monitor) => {
lock.new_surface(win, monitor); lock.new_surface(win, monitor);
win.show(); win.show();
@ -236,5 +237,6 @@ export default () => {
globalThis.authFinger(); globalThis.authFinger();
} }
export default () => {
lock_screen(); lock_screen();
}; };