Bug 60894

Summary: Periodic auto-saving of session state so state isn't lost if there's a crash or power loss
Product: [Plasma] plasmashell Reporter: ian
Component: Session ManagementAssignee: Plasma Bugs List <plasma-bugs>
Status: CONFIRMED ---    
Severity: wishlist CC: dinth, jeffbai, kde.org, kde, kde, kilrae, logixoul, maze, mcjason, med.medin.2014, missive, nate, noacco, o.freyermuth, plasma-bugs, subscriber, zmogas
Priority: VHI    
Version: 5.27.5   
Target Milestone: 1.0   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description ian 2003-07-07 21:49:22 UTC
Version:            (using KDE KDE 3.1)
Installed from:    SuSE RPMs
OS:          Linux

It would be nice to have an option where the current session's settings could be saved, similar to what is done at logout time, but without the need to log out.

In cases where KDE or X crashes and the current session is lost, such an option would save the pain of restoring from what was a much older session that was previously saved at a normal logout.

To extend this idea, it might be possible to produce a "restore crashed session" possibility.  KDE would regularly save the current state of the active session.  During the start up of a new session, the window manager could detect if the previously active session prematurely ended (crashed, power failure, or some other cause), and ask if that session should be restored to the state it was in just before the crash.

Relevant to this wish could be "Bug 59800" (the exact purpose of that wish is unclear to me).

Regards
Ian
PS: KDE is excellent!  Keep up the great work!
Comment 1 Stephan Binner 2003-07-11 00:05:16 UTC
There is an "Save Session" entry in the K menu if you choose the "Restore 
manually saved session" option in the "Session Manager" control center module. 
Comment 2 Oswald Buddenhagen 2003-11-20 03:44:09 UTC
retitling, as the first part which the old title refers to is already implemented.
Comment 3 Oswald Buddenhagen 2003-11-20 03:46:25 UTC
*** Bug 61254 has been marked as a duplicate of this bug. ***
Comment 4 Lubos Lunak 2005-02-28 11:45:28 UTC
*** Bug 100385 has been marked as a duplicate of this bug. ***
Comment 5 Lubos Lunak 2006-06-30 11:37:11 UTC
*** Bug 130050 has been marked as a duplicate of this bug. ***
Comment 6 William Entriken 2006-08-14 06:06:19 UTC
solved in work/soc_ksm, i'll close this when I merge it
Comment 7 ian 2006-08-14 08:28:50 UTC
OK, so what does "solved" actually mean?  I've noticed that there have been several wishes for the implementation of a recover crashed session feature, however until not this has not actually been done.  The only thing that was done in kde was to add a feature "Save Session" which was only available when the session manager was set to restoring a manually save session, which for me is not really satisfactory.  When I made this wish 3 years ago, I wanted a feature which would enable the recovery of a crashed session.  Is this now implemented?  That means, when I have a session open which is not manually saved, and then the session prematurely ends, do I get an option to restore that session at my next login?  Do I get options to select which crashed session I want to restore?  That is, if I had a crash today, one two weeks ago, and one three months ago, can I select which one of these I want to restore?It would also be nice to get an extra option in the KControl control centre to manage prematurely ended sessions (this is something I thought of right now as I was writing my question about what "solved" is).  The user would be able to see a list of sessions with start and approximate premature end times, and within each session entry they would see a list of windows that was open.  The user would then be able to choose if to maintain that session as a possibility to restore, or can choose to discard the records for that session.  The session list the user sees here would translate roughly into the list of possible sessions to restore at login which contains the list of prematurely ended sessions.And now I'm really thinking... The addition of a feature in KControl where a crashed session can be restored immediately in the current session.  Say for example the user logs in to an empty session and heads for the control centre to look at their list of prematurely ended sessions.  When they are looking at the details of each session, they get the option to immediately restore that session with the additional option of if the current session should be replaced or added to.  To replace a session means that all current windows and applications would be forcibly closed and the selected session restored.  To add to a session means that the prematurely ended session would have all its windows restored in addition to the currently open windows of the current session.Now I'm wondering if I should put my ideas about prematurely ended sessions management into a new wishlist item - should I do that?ThanksIan
Comment 8 Michael Zaugg 2008-05-11 14:28:07 UTC
AUTOSAVE SESSION HACK
Heres a hack to get sessions a way autosaved.

You need:
1. Startup script to change loginmode in ksmserverrc
2. Cronjob which save your current sessions
3. Logout script to change loginmode in ksmserverrc and show logoutwindow

Plan:
On startup we change loginmode from restorePreviousLogout to restoreSavedSession and autosave the current session via cron. If your computer crashes, kde loads your saved session on next login.

If you logout normally, we need to switch back to restorePreviousLogout to have the most actually session on next login (this can't be done with a shutdown script because it is executed at the end of the logout process). So we have to override the normal logout process or create a shortcut with a custom logout process.

Commands (change the paths according your installation)
1. STARTUP COMMAND to put in your ~/USER/.kde/Autostart/ folder

#!/bin/bash
sed -i 's/loginMode=restorePreviousLogout/loginMode=restoreSavedSession/g' '/home/michael/.kde/share/config/ksmserverrc'



2. AUTOSAVE SESSION to use it with cron

#!/bin/bash
DCOPSERVER=`cat /home/USER/.DCOPserver_YOURHOSTNAME_:0 | grep local`
export DCOPSERVER
/opt/kde3/bin/dcop ksmserver ksmserver saveCurrentSession



3. LOGOUT COMMAND make a menu entry which links to your script and give it a shortcut

#!/bin/bash
sed -i 's/loginMode=restoreSavedSession/loginMode=restorePreviousLogout/g' '/home/michael/.kde/share/config/ksmserverrc'
/opt/kde3/bin/dcop ksmserver ksmserver logout 1 -1 3



Maybe someone could pack this togheter and post it on kde-apps.org

Useful links
http://docs.kde.org/stable/de/kdemultimedia/kmix/dcop-examples.html
http://lists.kde.org/?l=kde-core-devel&m=102019069316875&w=2
http://www.spinics.net/lists/kde/msg00429.html
Comment 9 William Entriken 2010-08-26 21:19:25 UTC
Hello, I have technical notes about this bug listed at http://fulldecent.blogspot.com/2010/08/technical-notes-about-kde-ksmserver.html from my original attempt to fix it.
Comment 10 David Edmundson 2019-02-11 08:40:16 UTC
*** Bug 392003 has been marked as a duplicate of this bug. ***
Comment 11 Nate Graham 2020-01-31 21:59:15 UTC
*** Bug 251496 has been marked as a duplicate of this bug. ***
Comment 12 Nate Graham 2020-09-29 03:28:00 UTC
*** Bug 223285 has been marked as a duplicate of this bug. ***
Comment 13 Nate Graham 2020-09-29 03:28:24 UTC
*** Bug 311605 has been marked as a duplicate of this bug. ***
Comment 14 Nate Graham 2020-09-29 03:45:57 UTC
*** Bug 271586 has been marked as a duplicate of this bug. ***
Comment 15 Nate Graham 2020-09-29 03:51:40 UTC
*** Bug 186316 has been marked as a duplicate of this bug. ***
Comment 16 Nate Graham 2023-05-17 17:08:53 UTC
*** Bug 441905 has been marked as a duplicate of this bug. ***
Comment 17 Nate Graham 2023-05-17 17:09:40 UTC
*** Bug 122375 has been marked as a duplicate of this bug. ***
Comment 18 Eric S 2024-06-05 16:00:50 UTC
Woah thus bug is old! Is it really so hard to have a timer task run that does the equivalent of the manual save session button? 

Is there a command line way to trigger that function that I could add to a cron job? If not, could a command line way to activate it be added as a bit of a stopgap for this issue?