2 Commits

Author SHA1 Message Date
CLAUDE AI f7ab887ed0 revert(hypr): remove game-focus-watcher, restore steam rules
Keep only DP-1 forcing changes: gamingMonitor variable, monitor rules
for steam_app/mkGameRules, gaming-focus script, and SUPER+G binding.

Remove game-focus-watcher (caused game freeze on workspace switch).
Revert steam workspace rule back to title:Steam only.
Revert ghostty exec-once order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 08:18:42 -05:00
CLAUDE AI fe0d006f2e fix(hypr): reliable gaming workspace focus across monitors
- Add gaming-focus script: closes special workspace on DP-1 via
  --batch dispatch (fixes async race), then focuses gaming workspace;
  replaces raw workspace binding for SUPER+G
- Add game-focus-watcher: listens on Hyprland socket, auto-focuses
  gaming workspace when a game launches regardless of current monitor
- Fix monitor 0 → DP-1 in mkGameRules and steam_app windowrules
- Fix steam dialogs leaking to normal workspaces (broaden workspace
  rule from title:Steam to all class:steam)
- Extract gamingMonitor variable as single source of truth
- Drop redundant workspace dispatch after togglespecialworkspace to
  prevent game freeze on special→gaming transition

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 08:13:47 -05:00
2 changed files with 4 additions and 34 deletions
+1 -1
View File
@@ -74,7 +74,7 @@
]; ];
wayland.windowManager.hyprland.settings.exec-once = [ wayland.windowManager.hyprland.settings.exec-once = [
"[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" "[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
]; ];
} }
+3 -33
View File
@@ -18,39 +18,13 @@
# Close special workspace on gaming monitor if open # Close special workspace on gaming monitor if open
special=$(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[] | select(.name == "${gamingMonitor}") | .specialWorkspace.name') special=$(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[] | select(.name == "${gamingMonitor}") | .specialWorkspace.name')
if [[ -n "$special" ]]; then if [[ -n "$special" ]]; then
${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch togglespecialworkspace ''${special#special:};dispatch focusmonitor ${gamingMonitor};dispatch workspace name:gaming" # Gaming workspace is already underneath just close the special overlay
${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch togglespecialworkspace ''${special#special:}"
else else
${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch workspace name:gaming" ${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch workspace name:gaming"
fi fi
''; '';
game-focus-watcher = pkgs.writeShellScriptBin "game-focus-watcher" ''
handle() {
case $1 in
openwindow*)
data="''${1#openwindow>>}"
class=$(echo "$data" | cut -d',' -f3)
if [[ "$class" =~ ^steam_app_[0-9]+ ]] || \
[[ "$class" == "gamescope" ]] || \
[[ "$class" =~ ^wine- ]] || \
[[ "$class" == "lutris" ]] || \
[[ "$class" == "heroic" ]]; then
special=$(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[] | select(.name == "${gamingMonitor}") | .specialWorkspace.name')
if [[ -n "$special" ]]; then
${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch togglespecialworkspace ''${special#special:};dispatch focusmonitor ${gamingMonitor};dispatch workspace name:gaming"
else
${pkgs.hyprland}/bin/hyprctl --batch "dispatch focusmonitor ${gamingMonitor};dispatch workspace name:gaming"
fi
fi
;;
esac
}
${pkgs.socat}/bin/socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do
handle "$line"
done
'';
# Games that should have `stayfocused` applied (to avoid multi-monitor focus issues) # Games that should have `stayfocused` applied (to avoid multi-monitor focus issues)
stayFocusedGames = [ stayFocusedGames = [
# "Deadlock" # "Deadlock"
@@ -78,7 +52,6 @@ in {
protontricks protontricks
mangohud mangohud
gaming-focus gaming-focus
game-focus-watcher
# via # via
]; ];
@@ -101,7 +74,6 @@ in {
exec-once = [ exec-once = [
"[workspace special:steam silent] uwsm app -- steam" "[workspace special:steam silent] uwsm app -- steam"
"game-focus-watcher"
]; ];
bindd = [ bindd = [
@@ -126,9 +98,7 @@ in {
# --- STEAM CLIENT OVERRIDE --- # --- STEAM CLIENT OVERRIDE ---
# Override the float for the main Steam client, tile it, and move it to the special workspace. # Override the float for the main Steam client, tile it, and move it to the special workspace.
"tile, class:^(steam)$, title:^(Steam)$" "tile, class:^(steam)$, title:^(Steam)$"
# All steam class windows go to special:steam (dialogs, store, friends, etc.) "workspace special:steam, class:^(steam)$, title:^(Steam)$"
# Game overrides below take precedence for actual games.
"workspace special:steam, class:^(steam)$"
# --- STEAM GAME OVERRIDES --- # --- STEAM GAME OVERRIDES ---
# Override the float for actual games and move them to the gaming workspace. # Override the float for actual games and move them to the gaming workspace.