nlpsuge/gnome-shell-extension-another-window-session-manager

Restore session after startup

sojusnik opened this issue · 11 comments

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).

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.

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?

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 commented

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

  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 :)

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 commented

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 😄

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. :)

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.

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.

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.