From 1221c4f64c72ed9e1a9fefb6b6861a156e04e4c4 Mon Sep 17 00:00:00 2001 From: NullBite Date: Fri, 10 May 2024 22:08:22 -0400 Subject: [PATCH] greetd: add autolock option This option can be referenced by window managers to determine if they should automatically lock. For example, this can add an extra layer of security on a system that automatically decrypts the boot drive, but still offers the advantages of auto-login, such as automatic starting of user programs. --- home/sessions/hyprland/default.nix | 16 +++++++++++++++- system/programs/greetd.nix | 9 +++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/home/sessions/hyprland/default.nix b/home/sessions/hyprland/default.nix index 54db4a9..8e18ad2 100644 --- a/home/sessions/hyprland/default.nix +++ b/home/sessions/hyprland/default.nix @@ -81,6 +81,20 @@ in example = true; description = "Whether to enable hyprland."; }; + + autolock = lib.mkOption { + description = '' + Whether to automatically lock Hyprland upon logging in. This is useful + on a system with auto-login enabled, so that user programs can start + automatically with the system, but there is still an added layer of + security. This can be configured system-wide via + nixfiles.greetd.settings.autolock. + ''; + type = lib.types.bool; + default = osConfig.nixfiles.greetd.settings.autolock or false; + defaultText = "osConfig.nixfiles.greetd.settings.autolock or false"; + example = true; + }; }; config = lib.mkIf cfg.enable { @@ -114,7 +128,7 @@ in # Execute your favorite apps at launch # exec-once = waybar & hyprpaper & firefox - exec-once = [ + exec-once = (lib.optional cfg.autolock lock-cmd) ++ [ wallpaper-cmd notifydaemon polkit-agent diff --git a/system/programs/greetd.nix b/system/programs/greetd.nix index ae258eb..da46de0 100644 --- a/system/programs/greetd.nix +++ b/system/programs/greetd.nix @@ -125,6 +125,15 @@ in default = null; example = "username"; }; + autolock = lib.mkOption { + description = '' + Whether to indicate to a window manager that it should immediately + lock. This needs to be implemented on a per window manager basis. + ''; + type = bool; + default = false; + example = true; + }; }; presets.tuigreet.enable = lib.mkOption { description = "tuigreet greetd configuration";