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

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

Merged
merged 21 commits into from
Feb 5, 2023

Conversation

nlpsuge
Copy link
Owner

@nlpsuge nlpsuge commented Jan 24, 2023

Includes:

  1. Periodically, save windows when windows / apps states are changed. (fixes Save session periodically #60)
  2. Auto close and save apps and windows while Log Out/Restart/Power Off (fixes Restore session after startup #9)
  3. Auto restore the previous session at startup (fixes Restore session after startup #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 Dragging windows becomes choppy when the extension is enabled #59

…oot. Part 2: Support drag and drop and other improvements.
…oot. Part 4: Add options and cleanup saved session files while windows/apps quit, etc
…oot. Part 5: 1. More support for apps that launched via command line. Now those apps states can also be restored. 2. Remove old session files after app is restored when restoring the previous session 3. When closing the current session via the Log Out/Restart/Power Off, always show closing dialog. 4. Fixes #59 Dragging windows becomes choppy when the extension is enabled. 5. Like 4, optimize the performance when restore the previous session on startup
…oot. Part 6: 1. Add an option under Preferences -> Restore sessions, Restore delay. 2. On wayland, disable Stash and restore. 3. Preferences UI stuff
…oot. Part 7: 1. Add TODOs 2. Tweak Preferences UI settings, 3. Install a .desktop file to `~/.config/autostart` while `Restore previous apps and windows at startup` is enabled 4. If there are no running apps, close current sesson immediately without user interaction
@nlpsuge
Copy link
Owner Author

nlpsuge commented Jan 24, 2023

  1. Auto close and save apps and windows while Log Out/Restart/Power Off (fixes Restore session after startup #9)

Enable this feature through Auto close session under Close windows:
image

After you click the Log Out/Restart/Power Off button:
image

If the second button on the above dialog has via AWSM, it means this feature is enabled.

After you click Log Out(via AWSM), all apps and windows will be closed automatically by AWSM. But some apps might be still opening, you have to close them yourself; then if there are no running apps, this extension logs out the current user immediately.
image

You can move it around in case it covers other windows.

Please note that currently if this option is enabled, it modifies the Gnome Shell endSessionDialog globally, which means running gnome-session-quit --logout will also popup the new modified dialog.

@nlpsuge
Copy link
Owner Author

nlpsuge commented Jan 24, 2023

  1. Auto restore the previous session at startup (fixes Restore session after startup #9)

Here is the overview of Restore sessions settings:
image

Activate Restore previous apps and windows at startup to enable this feature. This option and Restore selected session at startup are exclusive. And this option works for shutting down the system normally (via Log Out/Restart/Power Off buttons) and other ways (like pressing the physical power-off button).

Then while startup, AWSM will read the previous saved session configs to launch and restore apps and states.

The session configs are saved in the path ~/.config/another-window-session-manager/sessions/currentSession.

You can use the below command to test this feature.

gdbus call --session --dest org.gnome.Shell.Extensions.awsm --object-path /org/gnome/Shell/Extensions/awsm --method org.gnome.Shell.Extensions.awsm.Autostart.RestorePreviousSession "{'removeAfterRestore': <false>}"

…oot. Part 9. 1. Change currentSession location 2. 2. Add RestorePreviousSessionWithArgs 3. Meta.restart() only has one paramter on Gnome Shell versions less than 43. etc..
@nlpsuge nlpsuge force-pushed the feature-close-save-session-while-logout branch from aa1e0d0 to a50f1e0 Compare January 28, 2023 13:27
@nlpsuge nlpsuge force-pushed the feature-close-save-session-while-logout branch from c8ae8dc to 5a97eb7 Compare January 29, 2023 05:24
@EkanshdeepGupta
Copy link

Hey in which version is this update a part of? Is it pushed to extensions.gnome.org? I have the latest version from the GNOME store (how do I find out which version I have installed?) but I don't see the "Auto Close Session" option under the Close Windows tab of settings.

@nlpsuge
Copy link
Owner Author

nlpsuge commented Feb 2, 2023

Hey in which version is this update a part of? Is it pushed to extensions.gnome.org? I have the latest version from the GNOME store (how do I find out which version I have installed?) but I don't see the "Auto Close Session" option under the Close Windows tab of settings.

No, I've not pushed it to extensions.gnome.org. This PR is work-in-progress.

Two blocking issues remain:

  • Currently, after all apps are closed the system will log out (or restart, shutdown) immediately, but the processes related to apps may not exit yet. For example, Microsoft Edge may opens with a Microsoft Edge Closed Unexpectedly dialog next time:

image

  • Gnome Shell sometimes freezes after unlocking. But I can't sure it's caused by my extension...

…oot. Part 10.

1. Use `app.quit` to quit an app if it is available and the app has only one window.
2. Ignore the `null` folder under `currentSession` when restoring previous session
3. Check the process exit state after all windows are closed automatically. Currently, only `Microsoft Edge` has this check, because if the system is logged out immediately, it might be opened with a `Microsoft Edge Closed Unexpectedly` dialog.
@nlpsuge
Copy link
Owner Author

nlpsuge commented Feb 5, 2023

Hey in which version is this update a part of? Is it pushed to extensions.gnome.org? I have the latest version from the GNOME store (how do I find out which version I have installed?) but I don't see the "Auto Close Session" option under the Close Windows tab of settings.

No, I've not pushed it to extensions.gnome.org. This PR is work-in-progress.

Two blocking issues remain:

* Currently, after all apps are closed the system will log out (or restart, shutdown) immediately, but the processes related to apps may not exit yet. For example, Microsoft Edge may opens with a `Microsoft Edge Closed Unexpectedly` dialog next time:

image

* Gnome Shell sometimes freezes after unlocking. But I can't sure it's caused by my extension...

The first issue has been fixed. The second not, I can't reproduce it myself, but I don't think it only happens occasionally.

The possibly upstream issue: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1868

@nlpsuge nlpsuge merged commit ba2673b into main Feb 5, 2023
@nlpsuge nlpsuge deleted the feature-close-save-session-while-logout branch February 5, 2023 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants