Commit ab505a07a424

Vincent Demeester <vincent@sbr.pm>
2026-03-30 09:51:37
fix(swayidle): detect eDP output dynamically
Hardcoded eDP-1 didn't match okinawa's eDP-2 panel, so the screen never turned off on idle. Now greps niri output list for the actual eDP connector name.
1 parent fa4aa6d
Changed files (1)
home
common
desktop
home/common/desktop/sway/swayidle.nix
@@ -9,16 +9,24 @@ let
       "${niriPowerOffScript}"
     else
       ''${pkgs.sway}/bin/swaymsg "output * power off"'';
-  # For niri: only power off the laptop screen (eDP-1). External monitors
+  # For niri: only power off the laptop screen (eDP-*). External monitors
   # connected via Thunderbolt docks (e.g. LG Ultrawide) can get their firmware
   # stuck in deep power save when sent DPMS off — DDC communication dies and
   # the monitor won't wake up without a physical power cycle.
   # The lock screen wallpaper effectively blanks external monitors instead.
+  # Dynamically detect the eDP output name (eDP-1, eDP-2, etc.) since it
+  # varies across laptops.
   niriPowerOffScript = pkgs.writeShellScript "niri-power-off-monitors" ''
-    ${pkgs.niri}/bin/niri msg output eDP-1 off
+    edp=$(${pkgs.niri}/bin/niri msg outputs | ${pkgs.gnugrep}/bin/grep -oP 'eDP-\d+')
+    if [ -n "$edp" ]; then
+      ${pkgs.niri}/bin/niri msg output "$edp" off
+    fi
   '';
   niriPowerOnScript = pkgs.writeShellScript "niri-power-on-monitors" ''
-    ${pkgs.niri}/bin/niri msg output eDP-1 on
+    edp=$(${pkgs.niri}/bin/niri msg outputs | ${pkgs.gnugrep}/bin/grep -oP 'eDP-\d+')
+    if [ -n "$edp" ]; then
+      ${pkgs.niri}/bin/niri msg output "$edp" on
+    fi
   '';
   powerOnCmd =
     if desktop == "niri" then