How could Unity2D save sessions?

Solution 1:

Info
The feature to save session has been removed in Ubuntu 12.04 because of a bug.

First
I have made a workaround that is a script that helps to configure your session. Just paste the command below at terminal and press Enter.

This if you are using Metacity (Unity-2d):

cd ~/ && wget -c http://dl.dropbox.com/u/4098082/session.meta.config && chmod +x ~/session.meta.config && ~/session.meta.config

.

Or this if you are using Compiz (Unity-3d):

cd ~/ && wget -c http://dl.dropbox.com/u/4098082/session.config && chmod +x ~/session.config && ~/session.config

You can view the code of script (1, 2). There are explanations in each part. It will create a startup script which will move to each viewport (or desktop) and open the specified application.

Removing

To remove any changes made by my script just delete this files (if they exists):

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

Or run this at terminal:

rm ~/session.config ; rm ~/session.meta.config ; rm ~/sessionconf ; rm ~/sessionconf.bak ; rm ~/.config/autostart/sessionconf.desktop  

Second
There are others workarounds like TuxOnIce:

"TuxOnIce is most easily described as the Linux equivalent of Windows' hibernate functionality, but better. It saves the contents of memory to disk and powers down. When the computer is started up again, it reloads the contents and the user can continue from where they left off. No documents need to be reloaded or applications reopened and the process is much faster than a normal shutdown and start up."

See it working here.

You can install it through "tuxonice/ppa":
1) Add the ppa: sudo apt-add-repository ppa:tuxonice/ppa
2) Update: sudo apt-get update
3) Install sudo apt-get install tuxonice-userui linux-generic-tuxonice linux-headers-generic-tuxonice


Third
A third idea is to set Compiz to launch windows in selected viewports:

1) Install CompizConfig-Settings-Manager,

2) Open Alt + F2 and type ccsm and hit Enter,

3) Go to "Place Windows"

enter image description here

4) Select "Fixed Window Placement" > "Window with fixed viewport" > "New"

enter image description here

5) Select the window by class, id, title, name, type or role and set the viewport it should be placed:

enter image description here

enter image description here

6) Now add your apps to "Startup Applications" (press Super and type Startup Applications)