From efaeab06be5962142042fab0a7001d787d65df03 Mon Sep 17 00:00:00 2001
From: NullBite <me@nullbite.com>
Date: Sun, 31 Mar 2024 02:46:20 -0400
Subject: [PATCH] hyprland: handle locked dpsm with swayidle

---
 home/programs/hypridle.nix         | 10 +++++-----
 home/sessions/hyprland/default.nix |  6 +++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/home/programs/hypridle.nix b/home/programs/hypridle.nix
index f500aae..d2ca42e 100644
--- a/home/programs/hypridle.nix
+++ b/home/programs/hypridle.nix
@@ -63,11 +63,11 @@ in
             onTimeout = cfg.commands.dpms-off;
             onResume = cfg.commands.dpms-on;
           }
-          {
-            timeout = cfg.timeouts.locked-dpms;
-            onTimeout = "${lock-dpms}";
-            onResume = cfg.commands.dpms-on;
-          }
+          # {
+          #   timeout = cfg.timeouts.locked-dpms;
+          #   onTimeout = "${lock-dpms}";
+          #   onResume = cfg.commands.dpms-on;
+          # }
           {
             timeout = cfg.timeouts.lock;
             onTimeout = "${lock}";
diff --git a/home/sessions/hyprland/default.nix b/home/sessions/hyprland/default.nix
index d1e0bcd..fd66e1a 100644
--- a/home/sessions/hyprland/default.nix
+++ b/home/sessions/hyprland/default.nix
@@ -33,7 +33,11 @@ let
   # idle-cmd = "${swayidle} -w timeout 315 '${lock-cmd}' timeout 300 '${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on' before-sleep '${lock-cmd}' lock '${lock-cmd}' unlock '${pkill} -USR1 -x swaylock'";
   # idle-cmd = "${swayidle} -w timeout 300 '${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'";
   # idle-cmd = "${hypridle}";
-  idle-cmd = "${pkgs.coreutils}/bin/true";
+  # idle-cmd = "${pkgs.coreutils}/bin/true";
+  idle-cmd = pkgs.writeShellScript "idle-dpms-lock" ''
+    ${swayidle} timeout 10 'pgrep -x swaylock > /dev/null && hyprctl dispatch dpms off' \
+      resume 'hyprctl dispatch dpms on'
+  '';
 
   hypr-dispatcher-package = pkgs.callPackage ./dispatcher { hyprland = hyprland-pkg; };
   hypr-dispatcher = "${hypr-dispatcher-package}/bin/hypr-dispatcher";