diff --git a/hosts/pinwheel/modules/hyprland/default.nix b/hosts/pinwheel/modules/hyprland/default.nix index 4bbc025..62bc905 100644 --- a/hosts/pinwheel/modules/hyprland/default.nix +++ b/hosts/pinwheel/modules/hyprland/default.nix @@ -55,12 +55,22 @@ let esac } - # Bind workspaces on startup - bind_workspaces - + # Start the event listener first so monitoradded events emitted during + # session startup are not lost in the gap before we begin reading them. ${pkgs.socat}/bin/socat -U - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle_event "$line" - done + done & + LISTENER_PID=$! + + # Give socat a moment to actually connect before the initial bind. + sleep 0.2 + bind_workspaces + + # Re-bind once more after the DRM subsystem has had time to enumerate + # external connectors, in case they were not yet present at session start. + (sleep 3; bind_workspaces) & + + wait $LISTENER_PID ''; in {