fix(hypr): reliable gaming workspace focus across monitors

- Add game-focus-watcher: listens on hyprland socket, auto-focuses
  gaming workspace when a game opens, closing any special workspace
  on DP-1 first via --batch to avoid async dispatch races
- Add gaming-focus script: SUPER+G now handles special workspaces on
  DP-1 regardless of focused monitor, with toggle-back behavior
- Fix steam windowrule to send all class:steam windows to special:steam,
  not just title:Steam, preventing dialogs leaking to normal workspaces
- Fix monitor 0 -> monitor DP-1 in mkGameRules and steam_app rules
  so games always launch at correct resolution on the gaming monitor
- Extract gamingMonitor variable as single source of truth
This commit is contained in:
CLAUDE AI
2026-05-28 07:57:33 -05:00
committed by kenji
parent 4205ab5429
commit 40b7db2c00
3 changed files with 77 additions and 21 deletions
+1 -1
View File
@@ -74,7 +74,7 @@
];
wayland.windowManager.hyprland.settings.exec-once = [
"[workspace special:preload silent] uwsm app -- xdg-terminal-exec"
"[workspace 1] uwsm app -- ghostty -e bash -c 'fastfetch; exec $SHELL'" # TODO: must be xdg-terminal-exec, or default user terminal
"[workspace special:preload silent] uwsm app -- xdg-terminal-exec"
];
}
+15 -12
View File
@@ -3,20 +3,23 @@
#!/usr/bin/env bash
target_workspace="$1"
# Get current workspace info
current_info=$(${pkgs.hyprland}/bin/hyprctl activeworkspace -j)
current=$(echo "$current_info" | ${pkgs.jq}/bin/jq -r '.id')
# activeworkspace always returns the underlying workspace, even when a special
# workspace is open. Check the monitor's specialWorkspace field instead.
special=$(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .specialWorkspace.name')
# Check if we're in a special workspace (negative ID)
if [[ $current -lt 0 ]]; then
# We're in a special workspace, force switch to target workspace
${pkgs.hyprland}/bin/hyprctl dispatch focusworkspaceoncurrentmonitor "$target_workspace"
elif [[ $current -eq $target_workspace ]]; then
# We're already on the target workspace, toggle back to previous
${pkgs.hyprland}/bin/hyprctl dispatch workspace previous
if [[ -n "$special" ]]; then
${pkgs.hyprland}/bin/hyprctl dispatch togglespecialworkspace "''${special#special:}"
current=$(${pkgs.hyprland}/bin/hyprctl activeworkspace -j | ${pkgs.jq}/bin/jq -r '.id')
if [[ $current -ne $target_workspace ]]; then
${pkgs.hyprland}/bin/hyprctl dispatch focusworkspaceoncurrentmonitor "$target_workspace"
fi
else
# We're on a different normal workspace, switch to target using split:workspace
${pkgs.hyprland}/bin/hyprctl dispatch split:workspace "$target_workspace"
current=$(${pkgs.hyprland}/bin/hyprctl activeworkspace -j | ${pkgs.jq}/bin/jq -r '.id')
if [[ $current -eq $target_workspace ]]; then
${pkgs.hyprland}/bin/hyprctl dispatch workspace previous
else
${pkgs.hyprland}/bin/hyprctl dispatch split:workspace "$target_workspace"
fi
fi
'';
in {