Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore session after startup #9

Closed
sojusnik opened this issue Dec 27, 2021 · 11 comments · Fixed by #67
Closed

Restore session after startup #9

sojusnik opened this issue Dec 27, 2021 · 11 comments · Fixed by #67
Labels
help wanted Extra attention is needed new feature New feature or request

Comments

@sojusnik
Copy link

Would be very handy, if this extension could save all windows before a system shutdown and restore them after startup, with the same window size and position (including workspaces).

@nlpsuge
Copy link
Owner

nlpsuge commented Dec 27, 2021

Duplicate issue: nlpsuge/xsession-manager#30

The current released version can restore windows to their associated workspace.

My priority is:

  • 1) Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.
  • 2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.
  • 3) Save all windows before a system shutdown / logout / reboot. But it should not work if someone press the physical power-off button.

@sojusnik
Copy link
Author

Duplicate issue: nlpsuge/xsession-manager#30

Only for X11, but your extension should work with both, X11 and Wayland.

Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.

An option to choose between a dialogue and automatically restoring (without asking) would be great to have.

Save all windows before a system shutdown / logout / reboot. But it should not work if someone press the physical power-off button.

You mean that after a proper shutdown it will work, but not after an “emergency” one, where one was pressing and holding the physical power button for some seconds?

@nlpsuge
Copy link
Owner

nlpsuge commented Dec 29, 2021

Only for X11, but your extension should work with both, X11 and Wayland.

Sure.

An option to choose between a dialogue and automatically restoring (without asking) would be great to have.

Great idea. It should be an option in the References.

You mean that after a proper shutdown it will work

Yes, by clicking those buttons:
image

, but not after an “emergency” one, where one was pressing and holding the physical power button for some seconds?

Yes. It should not work too if using non-GUI ways to quit Gnome, like using command shutdown or pkill -KILL -u a-user-name. I will just ignore these cases for now.

@Zefty
Copy link

Zefty commented Dec 31, 2021

Thanks for making this extension! The auto restore/save session would be a nice feature to have +1 from me for that as well.

@nlpsuge
Copy link
Owner

nlpsuge commented Jan 7, 2022

  1. Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.

Done. I have published a new release to support restoring window size and position :)

@nlpsuge nlpsuge pinned this issue Jan 7, 2022
@nlpsuge
Copy link
Owner

nlpsuge commented Jan 11, 2022

if this extension could save all windows before a system shutdown

There is a serious issue here for this target. What if there are one or more apps can't be closed, such as the below two cases, what should this extension do?

  1. Apps that are busy or its content has not been saved yet, like Gedit:
    image

This extension won't close an app in such a case, data is more important after all.

  1. If an app opens multiple windows, this extension won't close them by default.

What do you think? Any ideas?

For 2, I have a plan to add a whitelist in the Preferences, users put apps into this whitelist. And if an app is in the whitelist, this extension will close its windows one by one. The whitelist already exists in the code, gnome-terminal, Nautilus and SMplayer are in the whitelist. I think any apps that have no built-in session manager should be in the whitelist.

For 1, I'm still thinking ...

The above two cases will stop OS shutting down / rebooting / logging out after saving the session.

My goal is to close all apps safely.

What do you guys think?

@Zefty
Copy link

Zefty commented Jan 12, 2022

Hey im not too sure if this is a huge problem.

Just before shutdown/reboot/logout, the extension should just activate. Basically, the feature should automate us pressing the "save open windows" button.

Since those apps might prevent the shutdown/restart/logout, user can user to cancel or continue. If user cancels the shutdown/etc saves their work and then recommences shutdown/etc, then the extension should again automate the saving feature. This way whatever happens, the last state of apps should be saved.

Let me know if this helps 😄

@nlpsuge
Copy link
Owner

nlpsuge commented Apr 12, 2022

Hi everyone,

I would like to say that I have published the pre-release: 14-beta.0, you can download it from that page and install it for using the new feature.


To install it:

cd /tmp
wget https://codeload.github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/tar.gz/refs/tags/14-beta.0 -O /tmp/14-beta.0.tar.gz
tar xzvf /tmp/14-beta.0.tar.gz -C /tmp/

Then you can trash or move all files in the folder ~/.local/share/gnome-shell/extensions/another-window-session-manager@gmail.com to another place.

And then copy them to ~/.local/share/gnome-shell/extensions/another-window-session-manager@gmail.com:

cp -rp /tmp/gnome-shell-extension-another-window-session-manager-14-beta.0/* ~/.local/share/gnome-shell/extensions/another-window-session-manager@gmail.com

Restart the Gnome shell.


I'll publish a final release and upload it to the https://extensions.gnome.org in the following days.

I added a new button () in the popup menu to active a session, and restore it at startup. It supports restore a session with or without asking users.
image

In the above menu, you can also click that filter button () to show only the auto-restore item.
image

And a new settings page was added to Preferences to modify the delay, timer, or how to restore a session.
image

Restore a session with asking users:
image

Cheers. :)

@nlpsuge
Copy link
Owner

nlpsuge commented Apr 12, 2022

Duplicate issue: nlpsuge/xsession-manager#30

The current released version can restore windows to their associated workspace.

My priority is:

* [ ]  1)  Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.

* [x]  2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.

* [ ]  3) Save all windows before a system shutdown / logout / reboot.  But it should not work if someone press the physical power-off button.

Tasks updated:

  • 1) Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.
  • 2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.
  • 3) Save all windows before a system shutdown / logout / reboot. But it should not work if someone press the physical power-off button.

@nlpsuge
Copy link
Owner

nlpsuge commented Apr 14, 2022

The feature of restore at startup has been released and approved in E.G.O. You should have received an update notification including this extension.

nlpsuge added a commit that referenced this issue Jun 27, 2022
…s-GtkListBox

Experimental feature: Close windows according to shortcuts using `ydotool`

It supports X11 and Wayland.

This PR is part of #9
@nlpsuge
Copy link
Owner

nlpsuge commented Feb 5, 2023

Duplicate issue: nlpsuge/xsession-manager#30
The current released version can restore windows to their associated workspace.
My priority is:

* [ ]  1)  Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.

* [x]  2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.

* [ ]  3) Save all windows before a system shutdown / logout / reboot.  But it should not work if someone press the physical power-off button.

Tasks updated:

* [x]  1)  Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.

* [x]  2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.

* [ ]  3) Save all windows before a system shutdown / logout / reboot.  But it should not work if someone press the physical power-off button.

Tasks updated:

  • 1) Restore saved windows after startup, should popup a dialog with a timeout (can be set in the Preferences?), user can click Yes to confirm or click Cancel to stop to restore in case no need to restore.
  • 2) Restore window size and position. I have written this code but not well-tested, may not work at all. BTW, most app can restore their size and geometry on Gnome. Looks Shell API does not support this, not sure, I need to do more test and read documents and code.
  • 3) Save all windows before a system shutdown / logout / reboot. But it should not work if someone press the physical power-off button.

The third task is done by PR #67 and this issue will be closed automatically when #67 is merged into the main branch. A new version will be pushed to https://extensions.gnome.org soon.

nlpsuge added a commit that referenced this issue Feb 5, 2023
…logout

Feature:  Auto restore the previous session at startup, etc. Includes:

1. Periodically, save windows when windows / apps states are changed. (fixes #60)
2. Auto close apps and windows  while `Log Out/Restart/Power Off` (fixes #9)
3. Auto restore the previous session at startup (fixes #9)
4. New configurations in Preferences and rename
5. `Stash and restore ` under `Restore sessions ` is renamed to `Restore windows states after Gnome Shell restarts` and it will be disabled on Wayland.
6. More support for apps that launched via the command line. Now those apps states can also be restored.
7. Fixes #59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed new feature New feature or request
Projects
None yet
3 participants