Comment 59 for bug 771896

Revision history for this message
Jogarem (jogi) wrote :

Unfortunately this (https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/1037616/comments/4) does not work for me.
I'm on Ubuntu Trusty with Gnome3 (gnome-session 3.9.90-0ubuntu12).

I started with the following workaround (manual method see bottom for a automated one):

1) download dex (https://github.com/jceb/dex) to e.g. ~/dex and make it executable (chmod +x ~/dex)
2) execute this in a terminal:
    $> dconf write /org/gnome/gnome-session/auto-save-session-one-shot true
    or if you like to save every session:
    $> dconf write /org/gnome/gnome-session/auto-save-session true
3) open the apps you want to have been restored on login
4) Logout from Gnome
5) open "Startup Programs" settings tool
6) add a new entry and type in the full path to "dex" with the following options:
(replace [YOUR-USER] with your username and correct path)
#####################
Name: Restore Gnome Session
Command: /home/[YOUR-USER]/dex.py -a -s /home/[YOUR-USER]/.config/gnome-session/saved-session/
Comment: This will restore the last saved Gnome session
#####################
7) now remove the gnome arguments from the session files:
find ~/.config/gnome-session/saved-session -type f -name "*.desktop" -exec sed -i 's/--sm-c.*//g' {} \;
This will remove for every desktop file the gnome start arguments. They are not needed cause we do not use Gnome for restoring them.
8) On next login depending on your choice in 2) either the last session or the last saved session is restored

Notes:
If you choosen the second option in step 2) which means saving on each logout you need to automate step 7, too.
This way it will be sure that before the restore happens that the replacements are made.

If you have choosen the "one-shot" in step 2) and you want to change some apps simply re-run the command in 2) then do your changes and do not forget to do step 7 again.

**********************************************************

I used that a while and I come up with this scripted one:

https://raw.githubusercontent.com/xdajog/misc/master/restore-session.sh
Maybe useful for others so..

# INSTALL:
# 0) Download above script and place it somewhere handy
# 1) Download DEX (https://github.com/jceb/dex) and change the DEX var in this script
# 2) Use "dconf write /org/gnome/gnome-session/auto-save-session-one-shot true"
# (or "auto-save-session true" if you want to save EVERY session)
# 3) Open the apps you like
# 4) Open startup programs settings tool of Gnome and add the full path to this script
# 5) logout and enjoy your next login