jdholtz / i3-restore

A simple Bash and Python script to restore your i3 session
GNU General Public License v3.0
71 stars 1 forks source link

Firefox windows restored on invalid displays #17

Closed vitaly-zdanevich closed 1 month ago

vitaly-zdanevich commented 7 months ago

Description

After manual running:

$ i3-restore 
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
ERROR: No window matches given criteria
[{"success":false,"error":"No window matches given criteria"}]

To Reproduce

  1. i3-save
  2. reboot
  3. i3-restore

Expected Behavior

No response

Version

4.1

Additional context

No response

jdholtz commented 7 months ago

Could you paste the output when running the i3-restore script with -vv? It might be best to pipe it to a file and send the file here as there is a lot of debug output: ./i3-restore -vv > i3-restore-debug.txt.

vitaly-zdanevich commented 7 months ago

i3-restore-debug.txt

Not only Firefox - other programs also were restored on invalid layout.

jdholtz commented 7 months ago

i3-restore-debug.txt

This is the same output that you pasted in the issue. Make sure you run it with the -vv flag for a lot of verbosity in the output so I can debug this further.

Also, how are you running the save and restoring of the script? It is meant to be run automatically (see the Readme section here). Therefore, I recommend setting up the script to save and restore automatically and then report back if your sessions are not being restored correctly.

vitaly-zdanevich commented 7 months ago
$ head .config/i3/config 
# Autostart
exec i3-restore -vv > /tmp/i3-restore.log # Restore session
$ cat /tmp/i3-restore.log 
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true},{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":true}]
[{"success":false,"error":"No window matches given criteria"}]

Again Firefox windows are in the wrong displays.

I saved the session before powering off.

jdholtz commented 7 months ago

There should be a lot more output. Are you using the latest version of the script? You can get the version with ./i3-save --version

vitaly-zdanevich commented 7 months ago
$ i3-save --version
i3-restore v4.1
jdholtz commented 7 months ago

I forgot that I send all debug output to stderr to avoid it being returned in Bash. The command to pipe the output to the file is actually ./i3-restore -vv 2> output.txt. Sorry about that.

vitaly-zdanevich commented 7 months ago

i3-restore.log

jdholtz commented 7 months ago

Thanks! Are you using Firefox’s restore session feature? This won’t work without that enabled as the restoring won’t happen in the correct place. Also, do the windows get restored on the correct workspaces, just not the correct displays or are they not even restored on the correct workspaces?

vitaly-zdanevich commented 6 months ago

Are you using Firefox’s restore session feature?

Looks like yes image

are they not even restored on the correct workspaces?

Yes.

Also, for some reason, it creates 2 additional Firefox windows without tabs.

jdholtz commented 6 months ago

Also, for some reason, it creates 2 additional Firefox windows without tabs.

That's strange as that would be a Firefox issue that isn't restoring the session correctly. Do you have Firefox open before the restore? If so, this script won't properly restore as Firefox's restore session will not be triggered (I could document this as a limitation). Also, what other programs are not being restored correctly, as you said above?

You could try making the restore much slower, to see if it works at a much slower speed (and then adjust it from there until it is reliable). To do so, just adjust line 91 in i3-restore to sleep 1 (or a sleep time you see applicable).

vitaly-zdanevich commented 6 months ago

Do you have Firefox open before the restore?

No, I have this:

$ cat .xinitrc 
~/.screenlayout/four-displays.sh &
exec dbus-run-session i3
$ cat ~/.screenlayout/four-displays.sh
#!/bin/sh
xrandr --output HDMI-A-0 --primary --mode 3840x2160 --pos 1920x0 --rotate right --output DisplayPort-0 --off --output DisplayPort-1 --mode 1920x1200 --pos 0x2640 --rotate normal --output DisplayPort-2 --off --output DisplayPort-3 --mode 1920x1200 --pos 4080x1920 --rotate left --output DisplayPort-4 --mode 1920x1200 --pos 5280x1920 --rotate left

adjust line 91 in i3-restore to sleep 1

Done, still all 3 Firefox windows were restored on workspace 2 :(

jdholtz commented 6 months ago

Hm, not sure why they aren't being restored correctly. This script relies on i3 swallowing by matching the layout window to the window title. Perhaps one more thing to try is commenting out line 253 in i3-restore and seeing if the layouts are at least being restored on the correct displays.

To note, the script also works about ~90% reliably from my testing (it's not perfect). Usually, I have no issues running it (I use it everyday), but occasionally I will have to move a window back to the correct place. I can note this in the Limitations section of the Readme when I add that. This isn't to say that Firefox should never restore correctly though, that's still an issue you are seeing.

vitaly-zdanevich commented 5 months ago

I found something about this problem, I will try it... https://github.com/yurikhan/firefox-i3-workspaces

UPDATEL: yep, it works for me.

jdholtz commented 5 months ago

I found something about this problem, I will try it... https://github.com/yurikhan/firefox-i3-workspaces

Thanks for the reference. I've been getting less reliable restores with Firefox lately, so I will look more into this and try to make it as reliable as I can.

jdholtz commented 2 months ago

Hey @vitaly-zdanevich, there was an issue restoring all workspaces on the correct display, not just Firefox windows. This should be fixed with the latest changes I made. Can you test to make sure it works for you by doing git pull && git checkout develop and then running a save and restore?

glyiker commented 2 months ago

@jdholtz I experienced the same bug as @vitaly-zdanevich and using the fix in the develop branch did not resolve the issue. Was any other new config necessary? Performing a restore on my system opens a bunch of new windows, even on previously unoccupied workspaces. For example, trying to restore 1 firefox window from a save results in 4 firefox windows and 2 terminal windows, all arranged horizontally.

jdholtz commented 2 months ago

Was any other new config necessary?

No, there shouldn't be. Could you send your config file and the logs from the previous save and restore that failed? I did improve the logging in the latest commit on the develop branch, so it'd be great if the logs could come using the most updated changes.

For example, trying to restore 1 firefox window from a save results in 4 firefox windows and 2 terminal windows, all arranged horizontally.

The script should never restore terminal windows if the last save only contained 1 firefox window. Did you save your session with only 1 firefox window before you restored it?

jdholtz commented 2 months ago

Any follow-up to my previous comments @vitaly-zdanevich and @glyiker? If not, I'll close this issue as I am no longer seeing workspaces being restored on the incorrect displays.

jdholtz commented 1 month ago

Closing due to inactivity. I can reopen this if anyone is still running into issues and can provide some details about the issues they are seeing.