When I log in Ubuntu, I would like all windows opened at previous session (terminal and Firefox mainly) to be re-opened automatically at the same size and position.
How to proceed?
display-managergnomestartupwindow-manager
When I log in Ubuntu, I would like all windows opened at previous session (terminal and Firefox mainly) to be re-opened automatically at the same size and position.
How to proceed?
Best Answer
For 12.04 (and 11.10)
The short answer is: hibernation is the best option because the gnome-session-save functionality was removed after 11.04 since it was buggy, and the official tweak to manually re-enable this functionality does not appear to work. Part B of this answer describes how to use an alternative hibernation method, TuxOnIce, which is more compatible and reliable right now than the built-in hibernation.
A. Trying to enable the old Gnome session saving functionality
This Launchpad bug discusses restoring the "save session" functionality. It is currently marked "fixed", because a patch was introduced in the
gnome-session
package in April 2012, allowing users to manually re-enable this functionality. The patch describes itself as:You can enable this by setting the
GNOME_SESSION_SAVE
variable to a non-null value. Here's how:Alt+F2
, typegedit ~/.pam_environment
, and press enter.Add the line
GNOME_SESSION_SAVE=1
at the end of the file as shown below:Press
Ctrl+S
to save, andCtrl+Q
to quit the editor.GNOME_SESSION_SAVE
variable, and if set (non-null), it should enable session-saving just as if the Remember... box existed and was checked. That's why the bug is labeled as "fixed"gnome-session
from source. That makes the Options checkbox show up again, but it does nothing.B. What works for now: Enhanced Hibernation with TuxOnIce
Hibernation support is available in Ubuntu/Linux but was disabled in 12.04 because it wasn't working properly on a number of systems. See this question and this bugreport if you want more information.
A more compatible alternative: TuxOnIce
TuxOnIce (wiki|homepage) is an alternative to the kernel's built-in hibernation technology, and is supposed to be more compatible, more reliable and more flexible.
It does require installing TuxOnIce's custom kernel, but the instructions that follow should make it easy. If you've never opened the terminal before, you may want to now :-)
0. Requirements
The only requirement for TuxOnIce is that your swap partition be at least as large as the amount of memory (RAM) you have. You can check this by:
Start the terminal with Ctrl+Alt+T
Type
free -m
, and you should see something like this:The number after
Swap:
(e.g. 1536) should be more than the number afterMem:
(e.g. 1024)If this is not the case, and your swap is smaller than your memory, you must either resize and increase the size of your swap partition, or configure TuxOnIce to use a special swap file. That is beyond the scope of this answer, but if you ask another question and mention it in the comments, I will answer and explain how.
1. Installing the TuxOnIce kernel
Start the terminal with Ctrl+Alt+T
Ubuntu should now start up with the TuxOnIce kernel. If there are any problems, keep the Shift pressed at startup and you will get the Grub menu. Use the arrow keys to go to
Previous Linux Versions
, press enter, and press enter again to go back to the working kernel.2. Testing hibernation functionality.
Open some of the applications you normally use, e.g. Firefox, Thunderbird, LibreOffice, etc.
sudo pm-hibernate
, press enter, enter your password.You should see the lock screen for a second, and then the TuxOnIce hibernation progress screen, like the one below:
If all this worked, go to Step 3, which lets you enable Hibernate from the dashboard.
3. Enabling hibernation from the dashboard
Press Alt+F2, type the below and then press enter:
Paste the below, press Ctrl+S to save and Ctrl+Q to exit the editor:
Restart, and you should see the Hibernate option as shown below:
4. Removing TuxOnIce
If TuxOnIce doesn't work for you, or you simply wish to remove it, start the terminal and enter:
and remember to disable the Hibernate option in the menu with:
Then restart.