How to remember currently running applications in 12.04? [duplicate]

Solution 1:

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

  • Note: as described at the end, this official tweak does not appear to work -- you may want to skip directly to B. Hibernation with TuxOnIce
  • 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:

    • add GNOME_SESSION_SAVE environment variable for people wanting to
      use the save session still, knowing that it can break your system
      if used unwisely (LP: #771896)
  • You can enable this by setting the GNOME_SESSION_SAVE variable to a non-null value. Here's how:

    • Press Alt+F2, type gedit ~/.pam_environment, and press enter.
    • Add the line GNOME_SESSION_SAVE=1 at the end of the file as shown below:

    • enter image description here

    • Press Ctrl+S to save, and Ctrl+Q to quit the editor.

    • Now reboot (logout should also work, but just to be safe)
  • What the patch (source) does is disable the Options tab in Startup Applications, which used to contain the Remember running applications when logging out option. BUT it checks the 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"
    • if (g_getenv ("GNOME_SESSION_SAVE") != NULL)
                      maybe_load_saved_session_apps (manager);
    • Unfortunately, it doesn't seem to work, as confirmed by comment 32 in the bug tracker.
    • I even tried disabling the patch and rebuilding gnome-session from source. That makes the Options checkbox show up again, but it does nothing.
    • But hey, it may somehow work for you!! :)

B. What works for now: Enhanced Hibernation with TuxOnIce

  • Hibernation saves your current system state (including your session, applications open, etc.) to the hard disk, and shuts the computer down. When you start it again, it reads the saved state and restores it, just as if you had never turned the computer off. This technology is mostly used by laptop users to save on battery power, but there's no reason it can't be used on desktops as well.
  • 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 is easily installed, and if it doesn't work for you, as easily removed.
  • 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:

                 total       used       free     shared    buffers     cached
    Mem:          1024        731        260          0          0        190
    -/+ buffers/cache:        540        451
    Swap:         1536          6       1530
    
  • The number after Swap: (e.g. 1536) should be more than the number after Mem: (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

  • Copy and paste the following into the terminal. This adds the TuxOnIce PPA and installs the custom kernel and headers.
    • sudo apt-add-repository ppa:tuxonice/ppa -y
      and once the ppa is added:
    • sudo apt-get update
      sudo apt-get install tuxonice-userui linux-generic-tuxonice -y 
      sudo apt-get install linux-headers-generic-tuxonice -y
  • Now reboot.
  • 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.

  • Open the terminal again, with Ctrl+Alt+T.
  • Type 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:

    enter image description here

    • If TuxOnIce works, your computer will shutdown.
    • Start it again, and wait. TuxOnIce should resume from the point you hibernated, including all the windows you opened at the position you opened.
  • 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:

    gksudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
  • Paste the below, press Ctrl+S to save and Ctrl+Q to exit the editor:

    [Re-enable hibernate by default]
    Identity=unix-user:*
    Action=org.freedesktop.upower.hibernate
    ResultActive=yes

    enter image description here

  • Restart, and you should see the Hibernate option as shown below:

    enter image description here

    4. Removing TuxOnIce

    • If TuxOnIce doesn't work for you, or you simply wish to remove it, start the terminal and enter:

       sudo apt-get remove tuxonice-userui linux-generic-tuxonice linux-headers-generic-tuxonice -y
    • and remember to disable the Hibernate option in the menu with:

      sudo rm /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
    • Then restart.

Solution 2:

For 11.04 and earlier

Try this

System > Start up Applications > Options and check Automatically remember running applications when logging off and click remember current applications.

Solution 3:

It doesn't seem to be possible to have all applications remember their last window position and size. This behaviour seems to have been removed a long long time ago. My understanding is that it is the application's responsability to remember its own position and size. And here in lies the rub.

A search through the bug tracker yields many reports that in some way relevant to this issue.

So what applications remember position & size and what versions of Ubuntu do the applications have this functionaility?

Note : Please edit and fill the applications and versions of Ubuntu you have tested for this functionaility. i.e. the application remembers window position and/or size.

Sepecify the version of Ubuntu you have tested and if one or both window postition and size is remembered.

13.04

window postion | size

  • Y, Y - Nautilus
  • N, Y - Firefox erratic mutiple monitor placements
  • N, N - Terminal The terminal has custom settings to remember a specific size everytime, but it will not remember the last position
  • N, Y - Chromium
  • Y, Y - Banshee
  • N, - - Calculator Is not resizable*
  • N, Y - Gedit

Bug Reports Examples

Here are some random bug reports from some simple search in the bug tracker e.g. "remember window position".

2013
  • thunderbird does not remember position of window 1208647
2012
  • debconf gtk+ dialog boxes do not remember window sizes on ubuntu. 1097089
  • update-manager doesn't remember its position on screen 928434
  • system (GIMP) window does not remember its size 998030
2011
  • Firefox not remembering Window size and position between close and restart 876862
  • Window management - When a app is launched the windows should re-open in their exact previous location 767232
2009
  • Firefox doesn't remember the size and position of the windows 349740
  • Thunderbird does not remember window position in GNOME. 330779
2008
  • Window position is not remembered between starts 204480
  • When using Compiz; Firefox always starts in top-left corner 198328

  • Positioning of gnome-do window is sometimes erratic 204372

2007
  • Remember+restore window position of applications with WM_WINDOW_ROLE or window title set 124315
    • ubuntu does not remember window position 1100924
    • Audacious window position forgotten on display toggle via plugins, and on restart 409539
    • Application windows do not restore to last known position 391533
    • Gtk applications always appear in upper right corner of the screen at start 387700
    • metacity doesn't remember window positions on session restore 354674
  • the window of the weather applet should remember it's screen position 108952

Solution 4:

How to save a session on Ubuntu 11.04 or above:

  1. Download and install DConf-Editor.

  2. Type dconf on the dash and run it.

DASH-IMG

Open the next labels in order: org --> gnome

Then select gnome-session

Now you should see the auto-save-session option as the following image, activate it.

APP-IMG

DONE!

Now when you turn off your computer, the current session will save automatically. The next time you turn it will be exactly as you left.

Solution 5:

The current believe is that the proper session saving/restoring feature is to use either suspend or hibernate. I agree though that hibernate and suspend can be a pain to get working if they did not out of the box ...

But have a look at ...

CryoPID

CryoPID allows you to capture the state of a running process in Linux and save it to a file. This file can then be used to resume the process later on, either after a reboot or even on another machine.

CryoPID was spawned out of a discussion on the Software suspend mailing list about the complexities of suspending and resuming individual processes.

CryoPID consists of a program called freeze that captures the state of a running process and writes it into a file. The file is self-executing and self-extracting, so to resume a process, you simply run that file. See the table below for more details on what is supported.

Features

  • Can run as an ordinary user! (no root privileges needed)
  • Works on both 2.4 and 2.6.
  • Works on x86 and AMD64.
  • Can start & stop a process multiple times
  • Can migrate processes between machines and between kernel versions (tested between 2.4 to 2.6 and 2.6 to 2.4).

It is not very well documented though and the last DEB released was for Heron and the website was last updated in 2005 so it might be useless. Here are the tarballs:

  • i386 tarball
  • x86_64 tarball

And also have a look at 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.

ppa:tuxonice/ppa 

The PPA has precompiled Ubuntu kernels with TuxOnIce already compiled in, the userui binary and the hibernate script. So it might not be for the fainthearted.


There is one workaround that might be worth looking in to:

  • Create a script that has all the programs you tend to open. Or create 2,3,4,5,6 of those scripts and bind a key to this script. Like control + alt + 1|2|3|4|5|6 or if that is in use something else. Hit the key and let the script open all the programs from that script.

  • And you can use something like this how to shift applications from workspace 1 to 2 using command to toss them onto another workspaces if you want them grouped.

Not what you asked for but it seems we are deemed to look for workarounds :)