diff options
| -rw-r--r-- | games/README.md | 7 | ||||
| -rw-r--r-- | games/shell.qml | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/games/README.md b/games/README.md index 26e592e..b0b6f5b 100644 --- a/games/README.md +++ b/games/README.md @@ -29,6 +29,13 @@ they come from `~/.cache/keystone/games/owned.json`, which key is read with `pass show "$GAMES_PASS_ENTRY"`; the SteamID is derived from the userdata account directory. +Every game window lands on workspace 8, however it was started. Steam +sets `SteamGameId` in the environment of every game it runs, native, +Proton or a non-Steam shortcut, so the shell moves any newly opened +window whose process carries it. Class rules in the Hyprland config miss +games that name themselves: a GOG Ren'Py build added as a shortcut had no +`steam_app_` class and opened wherever focus was. + ## Running qs -p ./games diff --git a/games/shell.qml b/games/shell.qml index c667ec4..f6ca8b3 100644 --- a/games/shell.qml +++ b/games/shell.qml @@ -10,11 +10,29 @@ // GNU General Public License for more details. import Quickshell +import Quickshell.Hyprland import Quickshell.Io +import QtQuick ShellRoot { Games { id: games } + // Every game Steam starts, native, Proton or a non-Steam shortcut, + // inherits SteamGameId; class rules miss the ones naming themselves + // (a Ren'Py shortcut did), so route on the window's environment. + Connections { + target: Hyprland + function onRawEvent(event) { + if (event.name !== "openwindow") return; + const addr = "0x" + event.data.split(",")[0]; + Quickshell.execDetached(["sh", "-c", + 'pid=$(hyprctl clients -j | jq -r --arg a "$1" \'.[] | select(.address == $a) | .pid\') && ' + + 'grep -qz "^SteamGameId=" "/proc/$pid/environ" && ' + + 'hyprctl dispatch "hl.dsp.window.move({ workspace = \\"8\\", window = \\"address:$1\\" })"', + "sh", addr]); + } + } + // `qs -p <this dir> ipc call games toggle` IpcHandler { target: "games" |
