18

Is there a way to save current session (the applications + the organization of windows in desktops) in Unity and load it when needed?

4

No - as you've described it is not currently possible on Ubuntu versions 11.04 and up.

You may read this bug report, comment 24 in particular

https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/771896

or here is a more complete explanation (too long to copy here)?

https://lists.ubuntu.com/archives/ubuntu-desktop/2011-January/002734.html

8

I have made a workaround that is a script that helps to configure your session.

Download it here.
Make it executable and run from terminal ./session.config

You can view the code of script ( https://www.dropbox.com/s/w1btmead93q6hze/session.config?dl=0 ), there are explanations in each part. It will create a startup script which will move to each viewport and open the specified application.

Also you can run it whenever you want just press Alt + F2 and paste ~/.sessionconf.

Removing

To remove any changes made by my script just delete this files:

  • ~/session.config
  • ~/sessionconf
  • ~/sessionconf.bak
  • ~/.config/autostart/sessionconf.desktop

Or run this at terminal:

rm ~/session.config ; rm ~/sessionconf ; rm ~/sessionconf.bak ; rm ~/.config/autostart/sessionconf.desktop  
  • The link is a 404 now. Can you paste the contents here? And update the link if possible? Thanks! – Tyler Collier Jul 31 '17 at 21:08
  • @TylerCollier the Dropbox download link still works for me (May 2018). If you are not logged into dropbox.com close the registration window that pops up then use the download link. Dropbox does not allow previewing files ending with the .config extension. – frederickjh May 15 '18 at 12:12
  • @frederickjh Not sure if the link was fixed or perhaps I was just wrong before, but it works now, thanks for letting me know! – Tyler Collier May 16 '18 at 22:34
5

You can do this: killall gnome-session. As we know that entering the command sudo gnome-session-save --logout will log out the system. This will save the current session on Unity. I have tried this.

Or may be you can read about how to make a program auto-start everytime you log in.

Or you can try this gconf-editor key:

/apps/gnome-session/options/auto_save_session = true
  • 1
    What is gnome-session-save? I get "command not found". And I can't find it in repository. "Unable to locate package gnome-session-save". – Sanjay Manohar Mar 27 '15 at 22:23
3

This script works great for me on Xubuntu. It's more or less desktop-agnostic and in theory should also support Unity. From the original blog post by Arnon Weinberg:

GNOME session save and restore

This script is used to save and restore a desktop session.

Why this script?

Some desktop managers do offer some session management features. Under GNOME it may be possible to run gnome-session-properties manually and turn on “Automatically remember running applications when logging out”. However, some GNOME implementations (notably Ubuntu’s) appear to be deemphasizing or deprecating this feature in favour of the Suspend or Hibernate feature.

Both the automated session save and suspend feature however are limited to saving/restoring sessions only on clean logout/login.

I use this script because sometimes I just need to reboot, and sometimes I like to restore my session to a previous state.

How to use:

Download the script, place it on your PATH, and be sure to give it executable permissions.

To save the current session:

session save

To restore the saved session:

session restore

Installation on Ubuntu

The installation instructions provided in the blog post are valid for Fedora. On Ubuntu you will have to install the following dependencies:

sudo apt-get install perl wmctrl xdotool x11-utils

Please make sure to check out the 'Details' section of the original blog post to find out more about the different session restore levels.


Update: another user reported that the script only worked with the first line being #!/usr/bin/perl instead of #!/bin/perl.

1
dconf write /org/gnome/gnome-session/auto-save-session true

Should enable this for you.

  • 3
    Not working on 14.04 :( – AlikElzin-kilaka Jan 29 '15 at 23:20
  • I also cannot get it to work on 14.04. The property is changed correctly, but nothing gets restored. Do you know where the session data is stored? That way I could find out if it's actually being saved. – Sanjay Manohar Mar 27 '15 at 22:22
1

I wrote a little library/command line tool which allow saving and restoring sessions and has support for different monitors setups as well as virtual desktops.

Installation

npm install -g linux-window-session-manager

Usage

Save the current session to ~/.lwsm/sessionData/DEFAULT.json

lwsm save

Save the current session to ~/.lwsm/sessionData/my-session.json

lwsm save my-session   

Restore the session from ~/.lwsm/sessionData/DEFAULT.json

lwsm restore

Restore the session from ~/.lwsm/sessionData/my-session.json

lwsm restore my-session   

Gracefully close all running apps before starting the session

lwsm restore --closeAllOpenWindows

Check it out: https://github.com/johannesjo/linux-window-session-manager

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.