{
  programs.hyprlock.enable = true;
}
home-manager
{
  programs.hyprlock = {
    enable = true;
 
    settings = {
      general = {
        disable_loading_bar = true;
        immediate_render = true;
        hide_cursor = true;
        grace = 2;
      };
      animations = {
        enabled = true;
        animation = "fade, 1, 20, default";
      };
      background = {
        blur_passes = 3;
        blur_size = 12;
        noise = "0.1";
        contrast = "1.3";
        brightness = "0.2";
        vibrancy = "0.5";
        vibrancy_darkness = "0.3";
      };
 
      input-field = {
        size = "300, 50";
        valign = "bottom";
        position = "0%, 20%";
 
        outline_thickness = 1;
 
        fade_on_empty = false;
        placeholder_text = "$PAMPROMPT";
 
        dots_spacing = 0.2;
        dots_center = true;
 
        shadow_size = 7;
        shadow_passes = 2;
      };
 
      label = [
        {
          text = ''
            cmd[update:1000] echo "<span font-weight='ultralight'>$TIME</span>"
          '';
          font_size = 180;
 
          valign = "center";
          halign = "center";
          position = "0%, 10%";
 
          shadow_size = 20;
          shadow_passes = 2;
        }
        {
          text = "<span font-weight='ultralight'>$LAYOUT</span>";
          font_size = 12;
 
          valign = "bottom";
          halign = "center";
          position = "0%, 15%";
 
          shadow_passes = 2;
          shadow_size = 7;
        }
      ];
    };
  };
}
home-manager
{
  pkgs,
  lib,
  config,
  ...
}:
 
let
  lock = "${pkgs.systemd}/bin/loginctl lock-session";
  dpms = act: "${lib.getExe config.programs.niri.package} msg action power-${act}-monitors";
  notify = "${pkgs.libnotify}/bin/notify-send -u critical -t 10000 -i system-lock-screen 'Screen will be locked in 10 seconds...'";
  brillo = lib.getExe pkgs.brillo;
 
  # timeout after which DPMS kicks in
  timeout = 300;
in {
  # screen idle
  services.hypridle = {
    enable = true;
 
    settings = {
      general = {
        lock_cmd = lib.getExe config.programs.hyprlock.package;
        before_sleep_command = lock;
        after_sleep_command = dpms "on";
      };
 
      listener = [
        {
          timeout = timeout - 5;
          # save the current brightness and dim the screen over a period of
          # 1 s
          on-timeout = "${brillo} -O; ${brillo} -u 1000000 -S 10";
          # brighten the screen over a period of 250ms to the saved value
          on-resume = "${brillo} -I -u 250000";
        }
        {
          timeout = timeout - 10;
          on-timeout = notify;
        }
        {
          inherit timeout;
          on-timeout = lock;
        }
        {
          timeout = timeout + 10;
          on-timeout = dpms "off";
        }
      ];
    };
  };
 
  systemd.user.services.hypridle.Unit.After = lib.mkForce "graphical-session.target";
}
home-manager