Repository navigation
Restore floating windows when the only monitor disconnects and comes back (TV standby) #18188
mmsmsy
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.
Problem
When the only display drops its connection and comes back, Hyprland moves every window to the
FALLBACKoutput. After the reconnect, floating windows stay at their old global coordinates, thousands of pixels off-screen. For the user, it looks as if every window closed.A TV makes this happen every day. My only display is a Samsung TV on HDMI. In standby, the TV drops the HDMI link, so Hyprland sees the monitor as unplugged. With a floating-window workflow (every window floats and is snapped to a screen quarter), each wake-up left all windows about 5760 px off-screen.
Related: #8010 (a float left off-screen after a second output is disabled, which omarchybot could not reproduce with two monitors) and #16351 (the bar breaks after the only monitor disconnects and reconnects). The case here is the single-monitor one, with
FALLBACKin between. #14291 describes the same output reset with a Thunderbolt dock. #10272 pulls an off-screen float back onto a monitor, but it does not put it back in its old place.Setup: Omarchy 4.5.0-3, Hyprland 0.56.2, kernel 7.2.15-1-omarchy, AMD RX 9070 XT, Samsung QBQ90 on HDMI-A-1.
What I use now
A small daemon that runs from
autostart.lua:FALLBACK, it saves a snapshot of each window every 3 s and on window events: workspace, floating state, position and size, plus each monitor's active workspace.monitorremovedit stops saving snapshots, so the broken layout does not overwrite the good one.monitoraddedit waits 2 s, then puts every window of a monitor that is back to its saved workspace, floating state, position and size. It gives each monitor its workspace back. It does this again after 2 s, because Hyprland sometimes moves windows again shortly after the reconnect.FALLBACKis still there, it never takes the place of a missing monitor.window-restore --restoreruns the restore by hand.Known limit: with more than one monitor, a screen that stays off for more than 15 s while another monitor is on counts as gone. When it comes back, its windows stay on the other monitor. (When all monitors sleep together, Hyprland shows
FALLBACKand the clock does not run, so a slow screen gets 15 s after the first one wakes.)It uses only
hyprctl,jqandsocat. It has worked on every TV wake-up in the two days since I added it (6 November). That is the single-monitor case. I have only one monitor, so I tested the rules for a replaced or removed monitor only with mockhyprctloutput.How to install
Omarchy's base packages already include
jqandsocat.~/.config/hypr/scripts/window-restoreand make it executable:chmod +x ~/.config/hypr/scripts/window-restore~/.config/hypr/autostart.lua(the user autostart file that every Omarchy install has):setsid -f ~/.config/hypr/scripts/window-restoreTo restore windows by hand at any time:
~/.config/hypr/scripts/window-restore --restoreScript (283 lines)
Suggestion
Ship something like this in Omarchy, or handle the case in the shell, so that a monitor reconnect never leaves windows off-screen. I can turn the script into a PR that follows
AGENTS.md, if that is a direction you want.All reactions