From bfaaed692460ba86908593177717592b842cc737 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 11 Nov 2024 20:33:44 -0500 Subject: [PATCH] feat(desktop): move greetd to agsV2 --- nixosModules/ags-v2/config/app.ts | 1 - .../ags-v2/config/configurations/greeter.ts | 20 +++ nixosModules/ags-v2/config/style/greeter.scss | 18 +++ .../ags-v2/config/widgets/greeter/main.tsx | 118 ++++++++++++++++++ nixosModules/desktop/manager/ags.nix | 112 +++++++++++++++++ nixosModules/desktop/manager/ags/.envrc | 1 - nixosModules/desktop/manager/ags/default.nix | 90 ------------- .../desktop/manager/ags/eslint.config.ts | 1 - nixosModules/desktop/manager/ags/greeter.ts | 11 -- .../desktop/manager/ags/package-lock.json | 1 - nixosModules/desktop/manager/ags/package.json | 1 - .../desktop/manager/ags/scss/greeter.scss | 16 --- .../desktop/manager/ags/ts/greetd/main.ts | 103 --------------- .../desktop/manager/ags/tsconfig.json | 25 ---- nixosModules/desktop/manager/default.nix | 2 +- nixosModules/desktop/manager/hyprland.nix | 2 +- 16 files changed, 270 insertions(+), 252 deletions(-) create mode 100644 nixosModules/ags-v2/config/configurations/greeter.ts create mode 100644 nixosModules/ags-v2/config/style/greeter.scss create mode 100644 nixosModules/ags-v2/config/widgets/greeter/main.tsx create mode 100644 nixosModules/desktop/manager/ags.nix delete mode 120000 nixosModules/desktop/manager/ags/.envrc delete mode 100644 nixosModules/desktop/manager/ags/default.nix delete mode 120000 nixosModules/desktop/manager/ags/eslint.config.ts delete mode 100644 nixosModules/desktop/manager/ags/greeter.ts delete mode 120000 nixosModules/desktop/manager/ags/package-lock.json delete mode 120000 nixosModules/desktop/manager/ags/package.json delete mode 100644 nixosModules/desktop/manager/ags/scss/greeter.scss delete mode 100644 nixosModules/desktop/manager/ags/ts/greetd/main.ts delete mode 100644 nixosModules/desktop/manager/ags/tsconfig.json diff --git a/nixosModules/ags-v2/config/app.ts b/nixosModules/ags-v2/config/app.ts index 1b056979..460fdcd0 100644 --- a/nixosModules/ags-v2/config/app.ts +++ b/nixosModules/ags-v2/config/app.ts @@ -2,7 +2,6 @@ // TODO: quick-settings // TODO: music player stuff // TODO: on-screen-keyboard -// TODO: Greetd // TODO: GSR import GLib from 'gi://GLib'; diff --git a/nixosModules/ags-v2/config/configurations/greeter.ts b/nixosModules/ags-v2/config/configurations/greeter.ts new file mode 100644 index 00000000..3403d29b --- /dev/null +++ b/nixosModules/ags-v2/config/configurations/greeter.ts @@ -0,0 +1,20 @@ +export default async() => { + const { execAsync } = await import('astal'); + const { App } = await import('astal/gtk3'); + + const Greeter = (await import('../widgets/greeter/main')).default; + + const style = (await import('../style/greeter.scss')).default; + + + App.start({ + css: style, + instanceName: 'greeter', + + main: () => { + execAsync('hyprpaper').catch(() => { /**/ }); + + Greeter(); + }, + }); +}; diff --git a/nixosModules/ags-v2/config/style/greeter.scss b/nixosModules/ags-v2/config/style/greeter.scss new file mode 100644 index 00000000..823e51ca --- /dev/null +++ b/nixosModules/ags-v2/config/style/greeter.scss @@ -0,0 +1,18 @@ +@use 'colors'; + +window { + all: unset; + background-color: transparent; +} + + +.base { + background-color: colors.$window_bg_color; + border: 1.3px solid colors.$accent_bg_color; + border-radius: 12px; + padding: 5px; +} + +dropdown popover.menu { + padding-top: 0; +} diff --git a/nixosModules/ags-v2/config/widgets/greeter/main.tsx b/nixosModules/ags-v2/config/widgets/greeter/main.tsx new file mode 100644 index 00000000..48d71574 --- /dev/null +++ b/nixosModules/ags-v2/config/widgets/greeter/main.tsx @@ -0,0 +1,118 @@ +import { idle, readFile } from 'astal'; +import { Astal, Gtk, Widget } from 'astal/gtk3'; + +import AstalGreet from 'gi://AstalGreet'; + + +const DEFAULT_NAME = 'matt'; +const PARSED_INDEX = { + name: 0, + uid: 2, + gid: 3, + desc: 4, + home: 5, + shell: 6, +}; + +const parsePasswd = (fileContent: string) => { + const splitUsers = fileContent.split('\n'); + const parsedUsers = splitUsers.map((u) => { + const user = u.split(':'); + + return { + name: user[PARSED_INDEX.name], + uid: Number(user[PARSED_INDEX.uid]), + gid: Number(user[PARSED_INDEX.gid]), + desc: user[PARSED_INDEX.desc], + home: user[PARSED_INDEX.home], + shell: user[PARSED_INDEX.shell], + }; + }); + + // Filter out system users, nixbld users and nobody + return parsedUsers.filter((u) => { + return u.uid >= 1000 && + !u.name.includes('nixbld') && + u.name !== 'nobody'; + }); +}; + +const users = parsePasswd(readFile('/etc/passwd')); + +const dropdown = new Gtk.ComboBoxText(); + +dropdown.show_all(); + +users.forEach((u) => { + dropdown.append(null, u.name); +}); + +const response =