feat(greetd): use ags greetd example
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-02-05 12:00:25 -05:00
parent 47d1642e2e
commit fb9e26dc66
5 changed files with 55 additions and 64 deletions

View file

@ -1,13 +0,0 @@
diff --git a/src/gui/component.rs b/src/gui/component.rs
index 692309c..f2fb9c0 100644
--- a/src/gui/component.rs
+++ b/src/gui/component.rs
@@ -371,7 +371,7 @@ impl AsyncComponent for Greeter {
if let Some(monitor) = &model.updates.monitor {
// The window needs to be manually fullscreened, since the monitor is `None` at widget
// init.
- root.fullscreen_on_monitor(monitor);
+ // root.fullscreen_on_monitor(monitor);
} else {
// Couldn't choose a monitor, so let the compositor choose it for us.
root.fullscreen();

View file

@ -4,7 +4,7 @@
config, config,
... ...
}: let }: let
inherit (lib) getExe optionals readFile; inherit (lib) optionals readFile;
inherit (config.vars) mainUser greetdDupe mainMonitor; inherit (config.vars) mainUser greetdDupe mainMonitor;
# Nix stuff # Nix stuff
@ -20,9 +20,10 @@
.windowManager .windowManager
.hyprland .hyprland
.finalPackage; .finalPackage;
# Executables' paths
hyprBin = "${hyprland}/bin"; hyprBin = "${hyprland}/bin";
regreetBin = "${getExe config.programs.regreet.package}";
ags = config.home-manager.users.${mainUser}.programs.ags.package;
agsBin = "${ags}/bin";
# Show Regreet on all monitors # Show Regreet on all monitors
dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" '' dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" ''
@ -44,16 +45,13 @@
done done
''; '';
# Check if user wants Regreet only on main monitor # Check if user wants the greeter only on main monitor
setupMonitors = setupMonitors =
if (mainMonitor != "null" && !greetdDupe) if (mainMonitor != "null" && !greetdDupe)
then "${hyprBin}/hyprctl dispatch focusmonitor ${mainMonitor}" then "${hyprBin}/hyprctl dispatch focusmonitor ${mainMonitor}"
else "${dupeMonitors}/bin/dupeMonitors"; else "${dupeMonitors}/bin/dupeMonitors";
# Get css for regreet # Setup Hyprland as the greeter's compositor
style = pkgs.writeText "style.css" ''${readFile ./style.css}'';
# Setup Hyprland as regreet's compositor
hyprConf = hyprConf =
pkgs.writeText "greetd-hypr-config" pkgs.writeText "greetd-hypr-config"
(lib.strings.concatStrings ((optionals isNvidia [ (lib.strings.concatStrings ((optionals isNvidia [
@ -65,38 +63,32 @@
]) ])
++ [ ++ [
"exec-once = ${setupMonitors} &&" "exec-once = ${setupMonitors} &&"
" sleep 1; swww init --no-cache &&" " swww init --no-cache &&"
" swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n" " swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n"
"${readFile ./hyprland.conf}\n" "${readFile ./hyprland.conf}\n"
"exec-once = ${regreetBin} -s ${style};" "exec-once = ${agsBin}/ags --config ${./greetd.js};"
" ${hyprBin}/hyprctl dispatch exit" " ${hyprBin}/hyprctl dispatch exit"
])); ]));
in { in {
imports = [./regreet.nix]; # Add home folder for home-manager to work
users.users.greeter.home = "/var/lib/greetd";
users.users.greeter = { home-manager.users.greeter = {
packages = with pkgs; [ imports = [
dracula-theme ../../common/vars
flat-remix-icon-theme ../../home/theme.nix
];
home.packages = with pkgs; [
swww swww
gtk3 gtk3
glib glib
]; ];
};
# See overlay vars = config.vars;
programs.regreet = { home.stateVersion = "24.05";
enable = true;
settings = {
GTK = {
cursor_theme_name = "Dracula-cursors";
font_name = "Sans Serif";
icon_theme_name = "Flat-Remix-Violet-Dark";
theme_name = "Dracula";
};
};
}; };
services = { services = {

36
modules/greetd/greetd.js Normal file
View file

@ -0,0 +1,36 @@
const greetd = await Service.import('greetd');
const name = Widget.Entry({
placeholder_text: 'Username',
on_accept: () => password.grab_focus(),
})
const password = Widget.Entry({
placeholder_text: 'Password',
visibility: false,
on_accept: () => {
greetd.login(name.text || '', password.text || '', 'Hyprland')
.catch(err => response.label = JSON.stringify(err))
},
})
const response = Widget.Label()
const win = Widget.Window({
css: 'background-color: transparent;',
anchor: ['top', 'left', 'right', 'bottom'],
child: Widget.Box({
vertical: true,
hpack: 'center',
vpack: 'center',
hexpand: true,
vexpand: true,
children: [
name,
password,
response,
],
}),
});
export default { windows: [win] };

View file

@ -1,21 +0,0 @@
{pkgs, ...}: {
# TODO: try other greeters https://git.sr.ht/~kennylevinsen/gtkgreet
programs.regreet = {
package = pkgs.greetd.regreet.overrideAttrs (self: super: rec {
version = "0.1.1-patched";
src = pkgs.fetchFromGitHub {
owner = "rharish101";
repo = "ReGreet";
rev = "61d871a0ee5c74230dfef8100d0c9bc75b309203";
hash = "sha256-PkQTubSm/FN3FXs9vBB3FI4dXbQhv/7fS1rXkVsTAAs=";
};
cargoDeps = super.cargoDeps.overrideAttrs (_: {
inherit src;
outputHash = "sha256-dR6veXCGVMr5TbCvP0EqyQKTG2XM65VHF9U2nRWyzfA=";
});
# temp fix until https://github.com/rharish101/ReGreet/issues/32 is solved
patches = [./crash-fix.patch];
});
};
}

View file

@ -1,3 +0,0 @@
window {
background-color: rgba(0, 0, 0, 0);
}