Repository navigation
Open windows on the workspace they were launched from (Hyprland's token misses Chromium/Electron apps, hand-offs and the Apps launcher) #18513
Athesias
started this conversation in
Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The problem
If you start an app and switch workspaces before its window appears, the window opens on the workspace you're on now, not the one you launched it from. Slow starters make this happen all the time: Chrome on a cold start, Discord, Steam, any Electron app. It also happens with a new window of an app that's already running (Super+Shift+Return while Chrome is open). Related: #16122, which covers the same thing for apps started by a background agent.
Why turning on Hyprland's
initial_workspace_trackingisn't enoughOmarchy ships
misc.initial_workspace_tracking = 0. I turned it on (2, withinitial_workspace_token_timeout = 60), and it still misses most of the cases that matter:HL_INITIAL_WORKSPACE_TOKENin/proc/<pid>/environwhen the window maps. Chromium overwrites its own environment block when it sets its process title, so that file is all NUL bytes for Chrome, Discord and other Electron apps (checked withhead -c 300 /proc/<chrome-pid>/environ). Hyprland never finds the token, even though the process did inherit it.AppLibrary.qml→uwsm-app -- gtk-launch …), which has no token to pass on.1, a splash or updater window (Discord, Steam) uses up the one-shot token, and the real window then opens wherever you are.A working approach (tested on Omarchy 4.5.0-3, Hyprland 0.56.2)
Record the workspace at launch time, then place windows in Lua instead of relying on the environment token:
uwsm-appwrapper runshyprctl dispatch 'launch_workspace_mark($$)'and then execs the realuwsm-app.uwsm-appandsystemd-run --scopeexec straight through, so$$is the app's PID. When there's no token (the launcher case), the wrapper hands the command back to Hyprland's exec dispatcher so it goes through the same path.window.open:app-*.scopecgroup that uwsm creates, it's moved to the launch workspace withfollow = false. This applies to every window for 60 seconds, so splash screens don't use it up.I tested a cold Chrome start, a new Chrome window handed to the running browser, and a launcher-style launch with no token. In each, the window was launched on workspace 1 while I had already switched to workspace 9, and all three opened on workspace 1.
Inside Omarchy this could be cleaner than my local hack:
o.launchand the Apps launcher could record the launch directly in Lua or QML, with no wrapper arounduwsm-appand nohyprctlround trip. Separately, Hyprland could look for the token in ancestor processes or the cgroup instead of just/proc/<pid>/environ, which would fix problem 1 for everyone.Limits: apps that aren't launched through
uwsm-app(games started from Steam, D-Bus activation, links opened from inside another app) aren't covered. Hand-off detection is a heuristic: an unrelated running app that opens a window within 6 seconds of a launch that hasn't shown its own window yet could be moved by mistake.~/.config/hypr/launch-workspace.lua(required from hyprland.lua)/usr/local/bin/uwsm-appwrapperEdit: fixed the
window.destroyhandler. The window is already gone when that event fires, sowindow.addressis nil andplaced[nil] = nilthrew a "Runtime error in lua" popup on every window close.All reactions