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 =