Save session - How to run in a terminal, intention to add to crontab

Hello

I would like to find out if it’s possible to “save session” in a terminal and so in turn I’ll insert this in a script and add it to my crontab to schedule a save.

I am referring to the Desktop Session > Session Restore > Manually Saved. I would like this command to create this Manually saved session so that it is used when I logon again. Excuse me if my explanation here is perhaps overly descriptive, but I saw there were posts regarding Kate and Konsole session which isn’t what I am looking for.

My system version information is as follows:

image

Thank you
With kind regards
Andre

you know you can just use the settings to do that, right?

click on the desktop, type “session” and go to the setting page that comes up in the search result.

check the button that says “on last logout” and KDE will do that for you.

Thank you for your response and time skyfishgoo

My situation is that due to power failures, I don’t get to log out, that’s why I changed that setting you were referring to to manual instead of at log out. I must just remember to save the session every now and then (which I don’t always remember), hence my thought if I can do this on a schedule using crontab, but I can’t see what command to run to save the session.

1 Like

Really old post, but info still seems valid.

1 Like

ah, that makes more sense then.

altho, my experience with “unplanned restarts” is that it always seems to bring me back to where i was when it happened.

perhaps my clementine audio player will need to be restarted or any open libre office documents will need to go thru the “recovery” step, but i’ve not lost any work as far as i know.

but if you tried it and it’s not doing what you need, i hope you find a better solution.

What distro and KDE version are you using?

I may be remembering incorrectly but I had it set to session restore on last logout, but that irritated me a bit because it seemed to be doing as it says but my actual session had a different set of applications (hence this post), although it could be a bit complex and individual for each person depending on what applications used as well, considering that not all applications apply this X11 functionality as per the redirect explanation in that post @bedna quoted.

I’ll post my results now, however upon seeing your post I also did a quick test to include librecalc which didn’t reopen. All good though, I’ll accept as many applications being restored as I can, as long as it also excludes applications that I closed.

Like you say the choice of applications that do their own auto-recovery is great to prevent data loss which kate and libreoffice do so that’s great.

Hi

Below are my test results and methods used. I didn’t have success with dbus-send but perhaps it was something I missed in starting ksmserver


save session manually using menu:

open applications:

  • kate
  • firefox
  • thunderbird
  • dolphin

close all applications
reset pc

result: yes it worked


save session using qdbus:

qdbus-qt5 org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSession

open applications:

  • kate
  • firefox
  • thunderbird
  • konsole

close all
reset pc

result: seems to work, except for Konsole but dolphin was also closed so it seems to have not used the previously saved session


save session using dbus-send:

dbus-send --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSession
  • firefox
  • konsole

close all
reset pc

result: doesn’t work, strangely opened kate, firefox, thunderbird and even konsole