Bug 436318 - Implement real session save/restore on Wayland
Summary: Implement real session save/restore on Wayland
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Session Management (show other bugs)
Version: 5.24.4
Platform: Fedora RPMs Linux
: HI task
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL: https://invent.kde.org/plasma/kwin/-/...
Keywords: wayland-only
: 442192 442283 453849 455105 455900 460567 471977 479886 481745 496674 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-04-28 16:11 UTC by Patrick O'Callaghan
Modified: 2025-03-14 21:10 UTC (History)
117 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
attachment-25640-0.html (1.16 KB, text/html)
2022-12-11 19:54 UTC, Ed Tomlinson
Details
attachment-30227-0.html (2.01 KB, text/html)
2022-12-11 20:19 UTC, ticonzero
Details
attachment-30617-0.html (2.46 KB, text/html)
2022-12-11 20:21 UTC, ticonzero
Details
attachment-13297-0.html (1.02 KB, text/html)
2022-12-12 03:33 UTC, ticonzero
Details
attachment-19101-0.html (2.03 KB, text/html)
2022-12-12 09:29 UTC, ticonzero
Details
attachment-23823-0.html (1.05 KB, text/html)
2022-12-12 10:02 UTC, ticonzero
Details
attachment-2084366-0.html (2.09 KB, text/html)
2023-12-19 10:46 UTC, ticonzero
Details
attachment-3317129-0.html (2.48 KB, text/html)
2024-06-06 12:24 UTC, ticonzero
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick O'Callaghan 2021-04-28 16:11:50 UTC
SUMMARY
After configuring session-restore on login, then saving the session, many items are missing after starting a new session.

STEPS TO REPRODUCE
1. Enable "Manually saved session"
2. Set up some apps including Firefox, Konsole, Dolphin
3. Save the session using the Leave button

OBSERVED RESULT
On logging in again, neither Dolphin nor Konsole windows are restored. Firefox is restored.

EXPECTED RESULT
All saved windows should be restored.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Fedora 34
(available in About System)
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2021-04-28 19:36:34 UTC
Already noted on https://community.kde.org/Plasma/Wayland_Showstoppers.

We can use this as the bug report to track it.
Comment 2 Nate Graham 2021-09-14 15:07:58 UTC
*** Bug 442192 has been marked as a duplicate of this bug. ***
Comment 3 Nate Graham 2021-09-16 17:51:46 UTC
*** Bug 442283 has been marked as a duplicate of this bug. ***
Comment 4 devsk 2022-04-18 06:53:30 UTC Comment hidden (spam)
Comment 5 Nate Graham 2022-04-18 14:29:15 UTC Comment hidden (spam)
Comment 6 Nate Graham 2022-05-16 18:46:11 UTC
*** Bug 453849 has been marked as a duplicate of this bug. ***
Comment 7 Etaash Mathamsetty 2022-06-10 02:21:17 UTC Comment hidden (spam)
Comment 8 David Redondo 2022-06-10 07:15:22 UTC
*** Bug 455105 has been marked as a duplicate of this bug. ***
Comment 9 David Edmundson 2022-06-27 11:10:43 UTC
*** Bug 455900 has been marked as a duplicate of this bug. ***
Comment 10 Shmerl 2022-06-29 04:50:24 UTC
So something like this will eventually be able to help it? https://www.youtube.com/watch?v=fRdnRwPBFBk
Comment 11 Francisco Cribari 2022-07-29 11:27:38 UTC Comment hidden (spam)
Comment 12 Nate Graham 2022-07-29 15:36:14 UTC Comment hidden (spam)
Comment 13 Armin 2022-08-30 06:46:51 UTC Comment hidden (spam)
Comment 14 Piotr Mierzwinski 2022-08-30 17:44:31 UTC Comment hidden (spam)
Comment 15 Nate Graham 2022-08-30 17:51:04 UTC Comment hidden (spam)
Comment 16 Piotr Mierzwinski 2022-08-30 20:13:15 UTC Comment hidden (spam)
Comment 17 Nate Graham 2022-08-30 20:15:58 UTC Comment hidden (spam)
Comment 18 Piotr Mierzwinski 2022-09-02 21:15:32 UTC Comment hidden (spam)
Comment 19 Nate Graham 2022-09-02 21:46:18 UTC Comment hidden (spam)
Comment 20 devsk 2022-09-30 18:15:36 UTC
(In reply to Nate Graham from comment #19)
> In general, Plasma has enough testers and QA people. What it lacks is enough
> developers to fix all the issues those people find.

Or the devs you already have are interested only in next shiny thing than to fix bugs in their code...:-) Sure, we can't force devs to stick around forever and fix bugs in their code but sometimes, its good to stop new development and just fix the bugs. You will have more adoption and participation, and that can potentially get you more devs.
Comment 21 Bernie Innocenti 2022-09-30 18:57:11 UTC
(In reply to devsk from comment #20)
> Or the devs you already have are interested only in next shiny thing than to
> fix bugs in their code...:-) Sure, we can't force devs to stick around
> forever and fix bugs in their code but sometimes, its good to stop new
> development and just fix the bugs. You will have more adoption and
> participation, and that can potentially get you more devs.

As a user, I also wish session restore to worked on Wayland, but inflammatory comments won't help expedite it.

I would like to know what's making this difficult. X11 had a session management protocol; does Wayland define something equivalent? If not, could Plasma do something limited to KDE apps?

Where is the current session save/restore code? Any documentation we could link in this bug to support someone who wants to give a shot at it?
Comment 22 devsk 2022-09-30 19:15:29 UTC
(In reply to Bernie Innocenti from comment #21)
> (In reply to devsk from comment #20)
> > Or the devs you already have are interested only in next shiny thing than to
> > fix bugs in their code...:-) Sure, we can't force devs to stick around
> > forever and fix bugs in their code but sometimes, its good to stop new
> > development and just fix the bugs. You will have more adoption and
> > participation, and that can potentially get you more devs.
> 
> As a user, I also wish session restore to worked on Wayland, but
> inflammatory comments won't help expedite it.

I swear inflammation was not the intention. But truth can be hard sometimes and it lands wrongly in written communications. My apologies if it sounded like that.

It is true that devs like to move onto newer things. I see it everyday at work. And good teams and leaders have to bring them back to the table. We have burnt sprints doing just bug fixes solely because of this. And it works! The overall quality of the code improves and customers are happier and they spread the good word!
Comment 23 Ard van der Marel 2022-10-01 12:53:02 UTC Comment hidden (spam)
Comment 24 imaginator 2022-10-02 13:32:10 UTC Comment hidden (spam)
Comment 25 imaginator 2022-10-02 13:34:48 UTC Comment hidden (spam)
Comment 26 Nate Graham 2022-10-17 20:06:11 UTC
*** Bug 460567 has been marked as a duplicate of this bug. ***
Comment 27 Andreas Hartmann 2022-11-27 14:48:53 UTC Comment hidden (spam)
Comment 28 ticonzero 2022-12-09 09:14:13 UTC Comment hidden (spam)
Comment 29 imaginator 2022-12-09 11:43:07 UTC
(In reply to ticonzero from comment #28)
> Hi all, 
> 
> same problem here does anyone know if the bug has been fixed?
> 
If it had been fixed, the status would have changed. 
With the "Importance" downgraded to "normal", I don't expect it to be fixed before Plasma 6.
Comment 30 ticonzero 2022-12-09 16:43:15 UTC Comment hidden (spam)
Comment 31 imaginator 2022-12-09 17:41:44 UTC Comment hidden (spam)
Comment 32 Andreas Hartmann 2022-12-09 17:56:30 UTC Comment hidden (spam)
Comment 33 Ed Tomlinson 2022-12-11 19:54:02 UTC Comment hidden (spam)
Comment 34 Shmerl 2022-12-11 19:55:56 UTC Comment hidden (spam)
Comment 35 ticonzero 2022-12-11 20:19:51 UTC Comment hidden (spam)
Comment 36 ticonzero 2022-12-11 20:21:13 UTC Comment hidden (spam)
Comment 37 Francisco Cribari 2022-12-11 20:33:59 UTC
(In reply to ticonzero from comment #35)

> Well I do like it, in fact I'm sticking with it, but I do miss being able
> to restore the old session, for me it means not having to reopen dozen of
> pdfs in different okular instances on different desktops

Same here. This bug is the only reason why I am not running Wayland. I usually have about a dozen PDF (okular) and over twenty text (kate) files open. It is too much work to open each of these files again every time I restart the computer.
Comment 38 Mauro Molinari 2022-12-11 21:21:12 UTC Comment hidden (spam)
Comment 39 Francisco Cribari 2022-12-11 21:27:43 UTC Comment hidden (spam)
Comment 40 John E 2022-12-12 00:03:59 UTC
(In reply to Francisco Cribari from comment #37)
> (In reply to ticonzero from comment #35)
> 
> > Well I do like it, in fact I'm sticking with it, but I do miss being able
> > to restore the old session, for me it means not having to reopen dozen of
> > pdfs in different okular instances on different desktops
> 
> Same here. This bug is the only reason why I am not running Wayland. I
> usually have about a dozen PDF (okular) and over twenty text (kate) files
> open. It is too much work to open each of these files again every time I
> restart the computer.

If your windows don't change too much you can find a workaround on my dup: https://bugs.kde.org/show_bug.cgi?id=455900
Comment 41 ticonzero 2022-12-12 03:33:04 UTC Comment hidden (spam)
Comment 42 imaginator 2022-12-12 09:10:02 UTC Comment hidden (spam)
Comment 43 ticonzero 2022-12-12 09:29:14 UTC Comment hidden (spam)
Comment 44 imaginator 2022-12-12 09:41:35 UTC Comment hidden (spam)
Comment 45 ticonzero 2022-12-12 10:01:59 UTC Comment hidden (spam)
Comment 46 John E 2022-12-13 01:07:29 UTC Comment hidden (spam)
Comment 47 Andreas Hartmann 2023-01-22 17:44:26 UTC Comment hidden (spam)
Comment 48 Andreas Hartmann 2023-01-22 17:45:45 UTC Comment hidden (spam)
Comment 49 Bruno Friedmann 2023-03-05 14:40:39 UTC Comment hidden (spam)
Comment 50 imaginator 2023-03-05 15:02:11 UTC Comment hidden (spam)
Comment 51 postix 2023-03-05 18:47:55 UTC
(In reply to Bernie Innocenti from comment #21)
> I would like to know what's making this difficult. X11 had a session
> management protocol; does Wayland define something equivalent? 

Let me loosely quote the wiki [1]
> Session restoring does not include Wayland native windows (...). 
> Our sessions management recover engine is based on the X Session Management Protocol
> and there is apparently currently no generic concept to do it on Wayland.
> But on Qt it's plugin-able and GNOME has had their own implementation for some time. [2]

Regarding opened discussions, there's an issue in the kwin repo, see "Goal 2: Session restore" [3]

[1] https://community.kde.org/Plasma/Wayland_Showstoppers
[2] https://wiki.gnome.org/Projects/SessionManagement/GnomeSession
[3] https://invent.kde.org/plasma/kwin/-/issues/113#note_500909
Comment 52 postix 2023-03-05 18:55:34 UTC
See also the MR linked in the issue above: "Draft: wayland: Add support for xdg-session-v1" [1]

[1] https://invent.kde.org/plasma/kwin/-/merge_requests/3024
Comment 53 devsk 2023-06-24 16:13:55 UTC Comment hidden (spam)
Comment 54 Patrick O'Callaghan 2023-06-24 21:23:29 UTC Comment hidden (spam)
Comment 55 imaginator 2023-06-25 09:58:40 UTC Comment hidden (spam)
Comment 56 Eric 2023-07-25 18:11:32 UTC
Are there any reasonable workarounds? Say a script that reads all window positions, sizes, etc., and saves the information, and then another script that can read this info and open and arrange the windows?
Comment 57 Patrick O'Callaghan 2023-07-25 21:05:59 UTC
For a while I used a script based on:

https://github.com/zepalmer/script-vdr

but it's for Python-2 and X11 and I haven't tried to bring it up to date. It's based around wmctrl, which AFAIK is not supported on Wayland, but there might be something useful there. Note that it's designed to save/restore the windows belonging to one process, e.g. your browser, not the full user session.
Comment 58 wdmlist 2023-08-06 20:40:53 UTC Comment hidden (spam)
Comment 59 Eric 2023-10-05 20:05:01 UTC
According to the plasma/wayland showstoppers page, session restore is a priority:
https://community.kde.org/Plasma/Wayland_Showstoppers

However, on the plasma 6 development page there is no mention of session restore:
https://community.kde.org/Plasma/Plasma_6

Does anyone know if session restore is supposed to be in plasma 6?
Comment 60 postix 2023-10-05 21:11:49 UTC
> Does anyone know if session restore is supposed to be in plasma 6?
The plan is to solve all Wayland Showstoppers - including session restore - until Plasma 6.0 is released [1]

[1] https://pointieststick.com/2023/09/06/september-plasma-6-update/#comment-37811
Comment 61 ilovekiruna 2023-11-11 16:04:38 UTC
from my understanding the issue was downgraded to a non-showstopper anymore. At least this is shown now in the wiki page (https://community.kde.org/Plasma/Wayland_Showstoppers). I hope that Qt-pluginable option will still be provided on plasma 6. Is there  any update about when it will be integrated?
Comment 62 Nate Graham 2023-11-11 16:22:05 UTC
The plan right now is as follows:
- For Plasma 6.0, implement a sort of fake session restore that on login, simply re-opens apps that were open on last logout, and count on apps that have state worth saving doing the saving themselves (and many apps already do; for example Firefox, Discord, Dolphin, Kate, Kile, Elisa...).
- For a later Plasma 6 version, implement real session restore that's governed by a new Wayland protocol (one is in progress) and make KDE apps opt into it.
- After that, keep the fake session restore and use it for apps that don't opt into the real session restore.

This should ultimately produce a better UX than on X11, where many apps never opted into session restore and so it was semi-random as to which apps got launched on login.
Comment 63 Charles Dennett 2023-11-11 16:38:01 UTC Comment hidden (spam)
Comment 64 ticonzero 2023-11-11 17:01:06 UTC Comment hidden (spam)
Comment 65 Nate Graham 2023-11-11 17:08:11 UTC
For the fake session restore, I can't make any promises about that. I've talked to the fellow doing the work and he wants to take those into consideration, but it becomes more technically challenging, so the first version might not. But I do expect those to *eventually* work in the fake session restore.
Comment 66 Oleg Girko 2023-11-11 18:59:52 UTC Comment hidden (spam)
Comment 67 Armin 2023-11-25 11:52:18 UTC
(In reply to Nate Graham from comment #62)

> - For Plasma 6.0, implement a sort of fake session restore that on login,
> simply re-opens apps that were open on last logout, […]

Wow, that sounds great! I mean, real session restore would be a fantastic feature to have, but the “fake” option is already a great improvement to what we have at the moment (i.e. nothing).

I got already worried this was dropped entirely when I saw the change in the showstopper bug list. This is after all by far the biggest pain point I have with KDE Wayland.
Comment 68 Patrick O'Callaghan 2023-11-25 12:11:45 UTC
(In reply to Nate Graham from comment #62)
> The plan right now is as follows:
> - For Plasma 6.0, implement a sort of fake session restore that on login,
> simply re-opens apps that were open on last logout, and count on apps that
> have state worth saving doing the saving themselves (and many apps already
> do; for example Firefox, Discord, Dolphin, Kate, Kile, Elisa...).

Aside from the virtual desktop issue already mentioned by several people, it's worth noting that Dolphin does not currently restore its state correctly even under X11. Briefly, if you have more than one Dolphin window, some with the Terminal open and some not, the restored Dolphin will have all windows showing the Terminal in the same state, either open or closed, apparently at random.

I reported this over a year ago (see https://bugs.kde.org/show_bug.cgi?id=455324) but never saw a reply.
Comment 69 Mihai Sorin Dobrescu 2023-11-26 14:07:38 UTC
Indeed, Dolphin lost a lot of its session features, like restoring at the original position.

For me, being an Nvidia user (didn't know the drawbacks at the time and Plasma looked to work good enough with x11 and Nvidia), has become more and more unlikely I would move to the next Plasma at all. This combination that makes any input unusable, the mouse pointer or the keyboard signals being sent to Plasma after 30 secs or so, but also lacking session, are unacceptable. I understand some features are  ~ maybe ~ difficult to implement, but basic features like these are a must. I can't expect from a user to rather change a laptop just because he would use a DE, sorry.
Comment 70 nkwkelvin 2023-12-01 21:12:14 UTC
(In reply to Nate Graham from comment #62)
> The plan right now is as follows:
> - For Plasma 6.0, implement a sort of fake session restore that on login,
> simply re-opens apps that were open on last logout, and count on apps that
> have state worth saving doing the saving themselves (and many apps already
> do; for example Firefox, Discord, Dolphin, Kate, Kile, Elisa...).
> - For a later Plasma 6 version, implement real session restore that's
> governed by a new Wayland protocol (one is in progress) and make KDE apps
> opt into it.
> - After that, keep the fake session restore and use it for apps that don't
> opt into the real session restore.
> 
> This should ultimately produce a better UX than on X11, where many apps
> never opted into session restore and so it was semi-random as to which apps
> got launched on login.

Does Konsole save session (the windows and tabs and the current directory of each tab) by itself? My experience is that it does not, but given that things like Kate does, why can't Konsole, which is also a KDE app, do that? Am I missing something?
Comment 71 Bruno Friedmann 2023-12-02 08:36:44 UTC Comment hidden (spam)
Comment 72 ilovekiruna 2023-12-08 13:53:20 UTC
(In reply to Bruno Friedmann from comment #71)
> > Does Konsole save session (the windows and tabs and the current directory of each tab) by itself? My experience is that it does not, but given that things like Kate does, why can't Konsole, which is also a KDE app, do that?
> > Am I missing something?
> 
> Yes my experience proove it, I usually have 10 tabs opened in konsole, most
> of them are dedicated to a relative work, and as such the directory in which
> the last session was run, and is restored on the right desktop.
> That IS the most reason I don't use (yet) Wayland.

One workaround for Konsole exists on Stack-Exchange: https://unix.stackexchange.com/a/593779 It also works on Wayland. However, I believe this should be possible with built-in functionality.
Comment 73 ticonzero 2023-12-11 08:54:38 UTC Comment hidden (spam)
Comment 74 imaginator 2023-12-11 18:59:16 UTC Comment hidden (spam)
Comment 75 nkwkelvin 2023-12-11 19:21:41 UTC
I have made two scripts (heavily modified from scripts that I found somewhere else) to help session restore semi-automatically:

https://github.com/Kelvin-Ng/konsole-session-restore:
This script saves and reopens the Konsole windows with original tabs and directories.

https://github.com/Kelvin-Ng/kde-window-status-restore:
This script saves and restores the statuses of the windows, currently only activity and desktop. Note that it does not reopen the windows. The windows will have to be first reopened before running the restore script.

Hope these scripts are helpful.
Comment 76 imaginator 2023-12-19 09:07:47 UTC
(In reply to Nate Graham from comment #62)
> The plan right now is as follows:
> - For Plasma 6.0, implement a sort of fake session restore that on login,
> simply re-opens apps that were open on last logout, and count on apps that
> have state worth saving doing the saving themselves (and many apps already
> do; for example Firefox, Discord, Dolphin, Kate, Kile, Elisa...).
> - For a later Plasma 6 version, implement real session restore that's
> governed by a new Wayland protocol (one is in progress) and make KDE apps
> opt into it.
> - After that, keep the fake session restore and use it for apps that don't
> opt into the real session restore.
> 
> This should ultimately produce a better UX than on X11, where many apps
> never opted into session restore and so it was semi-random as to which apps
> got launched on login.

Alright, maybe my question was a bit too difficult to understand.  So I rephrase it a bit: will session restore in Plasma-6-X11 work _right from the start_ as it does in Plasma-5-X11 or not?  Some people don't give a damn about Wayland but do care about reliable and complete session restore.
Comment 77 ticonzero 2023-12-19 10:46:08 UTC Comment hidden (spam)
Comment 78 Nate Graham 2023-12-20 18:16:44 UTC
(In reply to imaginator from comment #76)
> Alright, maybe my question was a bit too difficult to understand.  So I
> rephrase it a bit: will session restore in Plasma-6-X11 work _right from the
> start_ as it does in Plasma-5-X11 or not?  Some people don't give a damn
> about Wayland but do care about reliable and complete session restore.

On X11? No changes have been made to session restore on X11 there so I would expect so. However I can't personally guarantee no regressions, as I'm not personally using X11 anymore and therefore not testing for regressions there. Someone else will need to step in for that.
Comment 79 imaginator 2023-12-20 21:17:12 UTC
(In reply to Nate Graham from comment #78)
> (In reply to imaginator from comment #76)
> > Alright, maybe my question was a bit too difficult to understand.  So I
> > rephrase it a bit: will session restore in Plasma-6-X11 work _right from the
> > start_ as it does in Plasma-5-X11 or not?  Some people don't give a damn
> > about Wayland but do care about reliable and complete session restore.
> 
> On X11? No changes have been made to session restore on X11 there so I would
> expect so. However I can't personally guarantee no regressions, as I'm not
> personally using X11 anymore and therefore not testing for regressions
> there. Someone else will need to step in for that.

Thanks for clarifying this.
Comment 80 Andrey 2024-01-12 16:12:32 UTC
*** Bug 476831 has been marked as a duplicate of this bug. ***
Comment 81 fanzhuyifan 2024-02-24 05:37:23 UTC
*** Bug 481745 has been marked as a duplicate of this bug. ***
Comment 82 Nate Graham 2024-03-04 19:26:29 UTC
Promoting this to be a 15-minute bug since it's Wayland-only and the Wayland-session is the default in Plasma 6 now.
Comment 83 Nate Graham 2024-03-06 15:40:33 UTC
*** Bug 479886 has been marked as a duplicate of this bug. ***
Comment 84 David Edmundson 2024-03-08 09:06:53 UTC
We've introduced a fallback. plasma-fallback-session-save which provides something.

It's not perfect. It just sees which apps were open and then reopens them. The application has no mechanism to save any state. 
There's definitely room for improvement, but that involves upstream and updating all  applications(!) which isn't worth us tracking in our bug tracker.
Comment 85 David Edmundson 2024-03-08 09:17:19 UTC
Git commit 804976c5ecec1fbf5f6e7e09970a8269bdf748d2 by David Edmundson.
Committed on 08/03/2024 at 09:17.
Pushed by davidedmundson into branch 'master'.

Migrate manual session saving to plasma-shutdown

This allows the wayland fallback session saving to run too and removes
more ksmserver logic from our library code.

session-restore is patched to also run when the configuration file is
set to restore the manually saved session.

M  +0    -3    libkworkspace/CMakeLists.txt
M  +2    -3    libkworkspace/sessionmanagement.cpp
M  +1    -0    startkde/plasma-shutdown/org.kde.Shutdown.xml
M  +24   -2    startkde/plasma-shutdown/shutdown.cpp
M  +1    -0    startkde/plasma-shutdown/shutdown.h
M  +1    -1    startkde/session-restore/restore.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/804976c5ecec1fbf5f6e7e09970a8269bdf748d2
Comment 86 Laurent Bonnaud 2024-03-08 09:27:33 UTC
> We've introduced a fallback. plasma-fallback-session-save which provides something.

Thanks!

> It's not perfect. It just sees which apps were open and then reopens them. The application has no mechanism to save any state. 

Let's take Konsole as an example.  Does this mean that Konsole will not save its current directory?
Comment 87 Nate Graham 2024-03-09 00:09:58 UTC
Correct. Because real session restore is not implemented on Wayland yet, at the moment this manual session restore hooks into the "real fake session restore" mechanism that will be used until we get real session restore.
Comment 88 Patrick O'Callaghan 2024-03-09 10:26:02 UTC
(In reply to Nate Graham from comment #87)
> Correct. Because real session restore is not implemented on Wayland yet, at
> the moment this manual session restore hooks into the "real fake session
> restore" mechanism that will be used until we get real session restore.

Any idea on when real session-restore might be coming?
Comment 89 Nate Graham 2024-03-10 03:18:43 UTC
Once the proposed Wayland protocol gets approved and merged, support in Plasma will likely arrive quickly. I don't know if it's helpful to speculate as to when the protocol might get approved. It could be tomorrow and it could be in two years. Obviously we all would prefer the former over the latter. :)
Comment 90 Laurent Bonnaud 2024-03-10 09:01:05 UTC Comment hidden (spam)
Comment 91 Piotr Mierzwinski 2024-03-15 00:19:20 UTC Comment hidden (spam)
Comment 92 Niklas Sombert 2024-03-15 22:00:11 UTC Comment hidden (spam)
Comment 93 David Edmundson 2024-03-15 22:55:48 UTC Comment hidden (spam)
Comment 94 Patrick O'Callaghan 2024-04-25 11:13:05 UTC
(In reply to Nate Graham from comment #62)
> The plan right now is as follows:
> - For Plasma 6.0, implement a sort of fake session restore that on login,
> simply re-opens apps that were open on last logout, and count on apps that
> have state worth saving doing the saving themselves (and many apps already
> do; for example Firefox, Discord, Dolphin, Kate, Kile, Elisa...).
> - For a later Plasma 6 version, implement real session restore that's
> governed by a new Wayland protocol (one is in progress) and make KDE apps
> opt into it.
> - After that, keep the fake session restore and use it for apps that don't
> opt into the real session restore.
> 
> This should ultimately produce a better UX than on X11, where many apps
> never opted into session restore and so it was semi-random as to which apps
> got launched on login.

I've just installed Fedora 40 with Plasma 6 on Wayland. I'm sorry to say the "fake session restore" simply doesn't work. The only app that re-opens on login is (ironically) Firefox, which isn't even a Plasma app. Both Konsole and Dolphin fail to appear and have to be started manually every time.

Needless to say, this is a considerable inconvenience.
Comment 95 postix 2024-04-25 11:15:54 UTC
As you just quoted "The plan right now is as follows:" this was the plan back in 2023. If you look at the "Version Fixed in" on the top right, it says 6.1. You have to wait til June or so. :)
Comment 96 Patrick O'Callaghan 2024-04-25 11:55:28 UTC
(In reply to postix from comment #95)
> As you just quoted "The plan right now is as follows:" this was the plan
> back in 2023. If you look at the "Version Fixed in" on the top right, it
> says 6.1. You have to wait til June or so. :)

In a post from January, Neil said he hoped to have this working for F40:

https://lists.fedoraproject.org/archives/list/kde@lists.fedoraproject.org/thread/PMAYGU3UJ6RXEOBGQJD6ZPKBLXEYLNJ2/

(you'll have to scroll down. The current list archive system doesn't seem to offer links to a specific message).
Comment 97 Bernd Steinhauser 2024-04-25 12:16:27 UTC
(In reply to Patrick O'Callaghan from comment #96)
> 
> (you'll have to scroll down. The current list archive system doesn't seem to
> offer links to a specific message).

Click on the link symbol in the upper right corner of the message.

https://lists.fedoraproject.org/archives/list/kde@lists.fedoraproject.org/message/HP26SLPOXK264324MAJMVC24MDEMOXQ7/
Comment 98 Patrick O'Callaghan 2024-04-25 12:36:01 UTC
(In reply to Bernd Steinhauser from comment #97)
> (In reply to Patrick O'Callaghan from comment #96)
> > 
> > (you'll have to scroll down. The current list archive system doesn't seem to
> > offer links to a specific message).
> 
> Click on the link symbol in the upper right corner of the message.
> 
> https://lists.fedoraproject.org/archives/list/kde@lists.fedoraproject.org/
> message/HP26SLPOXK264324MAJMVC24MDEMOXQ7/

Thanks. The reference is:

https://lists.fedoraproject.org/archives/list/kde@lists.fedoraproject.org/message/XSBZENY3VQCY57W3GXGCL7RMFZDANLTO/
Comment 99 devsk 2024-06-06 05:55:03 UTC Comment hidden (spam)
Comment 100 Eugene Shalygin 2024-06-06 06:32:49 UTC Comment hidden (spam)
Comment 101 David Edmundson 2024-06-06 06:35:03 UTC
The hack is definitely there. 
It follows the systemsettings -> desktop session -> session restore settings
Comment 102 Eugene Shalygin 2024-06-06 06:54:44 UTC
It is set to "On last logout" here, but nothing gets launched on the next log in.
Comment 103 Cruz Enrique 2024-06-06 07:14:06 UTC
Same here using Gentoo.
Comment 104 Eugene Shalygin 2024-06-06 09:04:01 UTC
Oh, I'm on Gentoo as well. Maybe it is our packaging that disables this feature? 

David, could you, please, point out the implementation location so I can try to figure out why it does not work?
Comment 105 Cruz Enrique 2024-06-06 09:26:33 UTC Comment hidden (spam)
Comment 106 Patrick O'Callaghan 2024-06-06 10:34:16 UTC Comment hidden (spam)
Comment 107 Patrick O'Callaghan 2024-06-06 10:38:28 UTC Comment hidden (spam)
Comment 108 Armin 2024-06-06 10:40:13 UTC
The fake session restore is part of plasma 6.1 and not available in 6.0 as far as I can tell. However, as stated in the link in Comment 98, Fedora has backported the session restore to their plasma packages (version 6.0) for Fedora 40.

Hope this clears up that confusion.
Comment 109 Armin 2024-06-06 10:43:50 UTC
Here the link to the commit for the Fedora 40 package: https://src.fedoraproject.org/rpms/plasma-workspace/c/d03958da910f3ba08c531e7569ff40c19ca2f045?branch=f40
Comment 110 Patrick O'Callaghan 2024-06-06 10:46:00 UTC
(In reply to Armin from comment #109)
> Here the link to the commit for the Fedora 40 package:
> https://src.fedoraproject.org/rpms/plasma-workspace/c/
> d03958da910f3ba08c531e7569ff40c19ca2f045?branch=f40

Note that this is not yet available in the Fedora repos, so probably better to wait.
Comment 111 Armin 2024-06-06 10:54:54 UTC
Regarding the actual session restore functionality, I have just switched to Fedora 40 and tested this a bit. So far, the fake session restore was not useful at all since it only launches the applications, but those apparently are not capable of remembering their previous state.

For instance, I rebooted my machine with 1 Kate, 2 Okular and 2 Konsole instances open, and while Kate, 2 Okular and 2 Konsole windows opened after the restart, none of those opened the previously open document or changed to the directory they previously were at. Back in X11, the session restore would not only reopen the applications, but also restore the actual documents (e.g. reopen the PDF file in Okular, change to the directory in Konsole, or restore a session in Kate).

As such, the current session restore doesn't add any value, since I need to manually open the documents/session anyway myself.
Comment 112 Armin 2024-06-06 11:04:32 UTC
(In reply to Patrick O'Callaghan from comment #110)
> (In reply to Armin from comment #109)
> > Here the link to the commit for the Fedora 40 package:
> > https://src.fedoraproject.org/rpms/plasma-workspace/c/
> > d03958da910f3ba08c531e7569ff40c19ca2f045?branch=f40
> 
> Note that this is not yet available in the Fedora repos, so probably better
> to wait.

Ok, what makes you think it is not? As far as I can tell, the F40 spec file contains the patch: https://src.fedoraproject.org/rpms/plasma-workspace/blob/f40/f/plasma-workspace.spec#_33
Comment 113 ticonzero 2024-06-06 12:24:01 UTC Comment hidden (spam)
Comment 114 Patrick O'Callaghan 2024-06-06 12:31:32 UTC
(In reply to Armin from comment #112)
> (In reply to Patrick O'Callaghan from comment #110)
> > (In reply to Armin from comment #109)
> > > Here the link to the commit for the Fedora 40 package:
> > > https://src.fedoraproject.org/rpms/plasma-workspace/c/
> > > d03958da910f3ba08c531e7569ff40c19ca2f045?branch=f40
> > 
> > Note that this is not yet available in the Fedora repos, so probably better
> > to wait.
> 
> Ok, what makes you think it is not? As far as I can tell, the F40 spec file
> contains the patch:
> https://src.fedoraproject.org/rpms/plasma-workspace/blob/f40/f/plasma-
> workspace.spec#_33

Because of:

https://lists.fedoraproject.org/archives/list/kde@lists.fedoraproject.org/message/HP26SLPOXK264324MAJMVC24MDEMOXQ7/

which mentions 6.1 "due out in June". I know we're in June now, but 6.1 is not out yet, at least in stable Fedora repos.
Comment 115 imaginator 2024-06-06 13:27:39 UTC Comment hidden (spam)
Comment 116 imaginator 2024-06-06 13:36:33 UTC Comment hidden (spam)
Comment 117 Niklas Sombert 2024-06-06 14:29:16 UTC Comment hidden (spam)
Comment 118 ticonzero 2024-06-06 14:31:02 UTC Comment hidden (spam)
Comment 119 devsk 2024-06-09 07:19:32 UTC Comment hidden (spam)
Comment 120 Patrick O'Callaghan 2024-06-20 10:06:09 UTC Comment hidden (spam)
Comment 121 undoIT 2024-06-21 04:50:13 UTC
Updated Arch with Plasma 6.1, rebooted, didn't work. Then, switched setting to: "When session was manually saved" and rebooted. Don't remember seeing a button to "Save Session" but it worked same as setting: "On last logout". Switched back to "On last logout" and it is still working. Very pleased! Thanks to everyone who put in the hard work to make this happen for Plasma 6.
Comment 122 devsk 2024-06-21 06:50:06 UTC Comment hidden (spam)
Comment 123 ticonzero 2024-06-21 07:23:16 UTC Comment hidden (spam)
Comment 124 Patrick O'Callaghan 2024-06-21 09:34:46 UTC
(In reply to Patrick O'Callaghan from comment #120)
> Just a heads-up to note that Plasma 6.1 is now available. I have installed
> it on Fedora 40 (via the normal dnf upgrade system) and look forward to
> testing it.

Here's my experience after brief testing:

* Apps are restored, including non-KDE ones such as Firefox and Evolution, but Yakuake does not restore.

* They all appear on the first desktop and have to be manually repositioned. Window sizes are correct but window positioning within the desktop is arbitrary.

* AFAIK each app is responsible for its own internal state. Konsole does not preserve tabs. Dolphin does not preserve terminal open/closed state independently for each window (though all windows are present) and instead of 3 windows in different directories they are all copies of each other (probably a Dolphin problem).

* Shortcut for normal interactive logout doesn't work consistently, not does the Logout menu selection. The shortcut for immediate logout (Shift-Ctrl-Alt-Del) does work.

Login/logout is very fast compared to 6.0 on Wayland.
Comment 125 imaginator 2024-06-21 11:10:48 UTC Comment hidden (spam)
Comment 126 Patrick O'Callaghan 2024-06-21 11:28:08 UTC Comment hidden (spam)
Comment 127 imaginator 2024-06-21 11:57:43 UTC Comment hidden (spam)
Comment 128 Mustafa Kamran 2024-06-21 16:35:45 UTC
(In reply to undoIT from comment #121)
> Updated Arch with Plasma 6.1, rebooted, didn't work. Then, switched setting
> to: "When session was manually saved" and rebooted. Don't remember seeing a
> button to "Save Session" but it worked same as setting: "On last logout".
> Switched back to "On last logout" and it is still working. Very pleased!
> Thanks to everyone who put in the hard work to make this happen for Plasma 6.

I am on Fedora 40 and I pretty much had to go through the same steps to actually enable this feature. Also the manual option didn't make the "save session" button show up even after reboot.

System Info:
Operating System: Fedora Linux 40
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1
Kernel Version: 6.9.4-200.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-10510U CPU @ 1.80GHz
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: LENOVO
Product Name: 20RD002RUS
System Version: ThinkPad E15
Comment 129 Reinier 2024-06-22 23:17:12 UTC Comment hidden (spam)
Comment 130 devsk 2024-06-24 08:36:39 UTC Comment hidden (spam)
Comment 131 Armin 2024-06-24 09:03:44 UTC Comment hidden (spam)
Comment 132 Patrick O'Callaghan 2024-06-24 09:38:01 UTC
(In reply to Armin from comment #131)
> (In reply to imaginator from comment #115)
> > So why don't you just dump Plasma-Wayland and use Plasma-X11 until this
> > essential (but nowadays rather trivial) feature is _fully_ implemented?
> 
> Well, with modern laptops featuring extremely high resolution displays, and
> a multiscreen setup, X11 simply cannot handle such setups any more.
> 
> With Wayland, a bunch of X11-features that have been "sort of working" like
> X-forwarding, screen sharing (in Teams/Zoom), and session management stopped
> working, but a whole lot of pain points that I had to work through over the
> past two decades went away, such as the resolution issue mentioned above.
> Ever since I adopted Wayland, screen sharing has been fixed and X-forwarding
> can be replaced by alternatives like VNC, which leaves session management as
> the last big ticket item.
> 
> Regarding the fake session report, Fedora 40 has backported the patches to
> Plasma 6.0 a few months ago, so there was not really any change with the
> update to Plasma 6.1. I otherwise came to realise that the fake session
> restore is working exactly as advertised (cf.
> https://bugs.kde.org/show_bug.cgi?id=436318#c84 or the commit message at
> https://invent.kde.org/plasma/plasma-workspace/-/commit/
> 660988b0e30ee8ccac98c0cf164b142d70709675).
> 
> So, got to wait until somebody with the necessary knowledge and skills
> implements true session management in KDE Plasma.

I generally agree, though I had hoped that the 6.1 version would be a little better and it really isn´t. What worries me is that apparently proper session restore is a missing feature in Wayland itself (Gnome has a non-standard workaround) so I don't know how long we are going to have to wait. This is not a good situation.

I would be much happier if we could at least have windows restored to their proper desktops and positions, but I don't know enough to guess how hard that is to do. Is there no way for the 'session save' action to interrogate the window manager (or Wayland server) and save this information?
Comment 133 Mustafa Kamran 2024-06-24 10:43:46 UTC Comment hidden (spam)
Comment 134 Patrick O'Callaghan 2024-06-24 10:57:05 UTC Comment hidden (spam)
Comment 135 imaginator 2024-06-24 11:50:26 UTC Comment hidden (spam)
Comment 136 Armin 2024-06-24 14:55:14 UTC
(In reply to imaginator from comment #135)
> Now it seems that Plasma-6-users are at the mercy of the Wayland-devs
> (comment 89).

Well, not really. There is nothing stopping KDE devs to go ahead and implement the Wayland session management draft protocol. In fact, it would not be a bad thing at all to have an implementation of the protocol in order to identify any issues early on.

The Gnome devs did exactly that, and implemented the draft protocol in Mutter and GTK:
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7370

Maybe this helps KDE devs to move things along for Plasma as well...
Comment 137 imaginator 2024-06-24 16:52:49 UTC Comment hidden (spam)
Comment 138 Lassi Väätämöinen 2024-06-28 18:18:30 UTC
(In reply to Nate Graham from comment #87)
> Correct. Because real session restore is not implemented on Wayland yet, at
> the moment this manual session restore hooks into the "real fake session
> restore" mechanism that will be used until we get real session restore.

It's a bit bad UX that this is not at least communicated to the user in the settings where this is selected. Quite frankly I cannot see why it was not hooked to the real session save which it at least attempts to do...
Comment 139 gimmemahlulz 2024-07-06 13:52:47 UTC Comment hidden (spam)
Comment 140 Brian Kaye 2024-09-06 02:27:47 UTC Comment hidden (spam)
Comment 141 devsk 2024-09-06 02:47:28 UTC Comment hidden (spam)
Comment 142 Brian Kaye 2024-09-06 13:45:06 UTC Comment hidden (spam)
Comment 143 Roke Julian Lockhart Beedell 2024-09-06 13:50:51 UTC Comment hidden (spam)
Comment 144 equeim 2024-09-06 13:57:48 UTC Comment hidden (spam)
Comment 145 Roke Julian Lockhart Beedell 2024-09-06 13:59:12 UTC Comment hidden (spam)
Comment 146 Patrick O'Callaghan 2024-09-06 14:01:04 UTC Comment hidden (spam)
Comment 147 Mihai Sorin Dobrescu 2024-09-06 15:58:45 UTC Comment hidden (spam)
Comment 148 Patrick O'Callaghan 2024-09-06 16:29:36 UTC Comment hidden (spam)
Comment 149 imaginator 2024-09-06 16:47:42 UTC Comment hidden (spam)
Comment 150 Mihai Sorin Dobrescu 2024-09-06 17:41:32 UTC Comment hidden (spam)
Comment 151 Charles Dennett 2024-09-06 17:47:58 UTC
I've been following this bug because I used session restore back when it worked.  I have found a workaround that works for me but I have not seen it mentioned here yet.  Here's what I do.  I have two monitors and use 4 virtual desktops.  I'm able to have a console window with multiple tabs open on the left monitor in virtual desktop 1 by using the konsole option --tabs-from-file.  One of the tabs starts with top running.   Chrome starts on the left monitor in virtual desktop 2.  Thunderbird starts on the right monitor in all virtual desktops.  I am able to do this by using the autostart section of the system setting app to specify what apps start at login.  Then in the Window Rules section (in Apps & Windows -> Window Management) I am able to specify where each app appears.  Like I said, this works for me.  Of course it does not save the current session so that it comes back on the next login.
Comment 152 Patrick O'Callaghan 2024-09-06 21:29:54 UTC Comment hidden (spam)
Comment 153 imaginator 2024-09-07 11:33:05 UTC Comment hidden (spam)
Comment 154 Patrick O'Callaghan 2024-09-07 12:21:59 UTC Comment hidden (spam)
Comment 155 imaginator 2024-09-07 12:40:14 UTC Comment hidden (spam)
Comment 156 Patrick O'Callaghan 2024-09-08 09:12:53 UTC Comment hidden (spam)
Comment 157 Fushan Wen 2024-09-14 13:22:08 UTC
Git commit 4dff1973116597210cf9fb1c102e5c9433d13b1d by Fushan Wen, on behalf of David Edmundson.
Committed on 14/09/2024 at 13:22.
Pushed by fusionfuture into branch 'master'.

startkde: Fix wayland session restore saving

When we added manual saving support to plasma-shutdown a guard was
changed in the normal shutdown path. This guard was wrong, we want to
check we're in the restorePreviousLogout path here.

This amends 804976c5ecec1fbf5f6e7e09970a8269bdf748d2

M  +1    -1    startkde/plasma-shutdown/shutdown.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/4dff1973116597210cf9fb1c102e5c9433d13b1d
Comment 158 Mihai Sorin Dobrescu 2024-09-15 07:53:43 UTC Comment hidden (spam)
Comment 159 Fushan Wen 2024-09-17 08:15:36 UTC
Git commit fae71841ff018e34bbb02aa1098b53f63c1743d2 by Fushan Wen.
Committed on 17/09/2024 at 07:53.
Pushed by fusionfuture into branch 'Plasma/6.2'.

startkde: Fix wayland session restore saving

When we added manual saving support to plasma-shutdown a guard was
changed in the normal shutdown path. This guard was wrong, we want to
check we're in the restorePreviousLogout path here.

This amends 804976c5ecec1fbf5f6e7e09970a8269bdf748d2


(cherry picked from commit 4dff1973116597210cf9fb1c102e5c9433d13b1d)

89ee67ad startkde: Fix wayland session restore saving

Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>

M  +1    -1    startkde/plasma-shutdown/shutdown.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/fae71841ff018e34bbb02aa1098b53f63c1743d2
Comment 160 ticonzero 2024-09-18 11:57:34 UTC Comment hidden (spam)
Comment 161 Nate Graham 2024-09-18 12:06:17 UTC Comment hidden (spam)
Comment 162 ticonzero 2024-09-18 12:21:14 UTC Comment hidden (spam)
Comment 163 Nate Graham 2024-09-18 12:22:35 UTC Comment hidden (spam)
Comment 164 Anthony Fieroni 2024-09-21 05:55:45 UTC
I wonder why there is extra button for save session since this is the button for leave session when configuration is restore previous session?
Comment 165 Kishore Gopalakrishnan 2024-09-22 09:58:30 UTC
Am I correct in assuming that the commit marked as fixing this issue only enables the 'fake session restore' (that opens all the applications that were previously opened without restoring their state)?

From my experiments, it still looks like *saving* the session information (which is what this bug title references) is not fixed by that commit. That would probably require progress on https://invent.kde.org/plasma/kwin/-/issues/113
Comment 166 imaginator 2024-09-23 08:59:40 UTC
(In reply to Kishore Gopalakrishnan from comment #165)
> Am I correct in assuming that the commit marked as fixing this issue only
> enables the 'fake session restore' (that opens all the applications that
> were previously opened without restoring their state)?
> 
> From my experiments, it still looks like *saving* the session information
> (which is what this bug title references) is not fixed by that commit. That
> would probably require progress on
> https://invent.kde.org/plasma/kwin/-/issues/113

From [1]: "Fixed a bug that caused real-fake-session-restore to not work properly on Wayland (David Edmundson, Plasma 6.2.0. Link)"

I'm not sure what a "real-fake-session-restore" is but I guess it's the surrogate session-restore that's been delivered to Plasma-6-wayland-users lately.

Now, if only that crutch is fixed, it's indeed hard to see how that would qualify to mark *this* bug (again) as "resolved".  Perhaps after three years the pain became just too much to bear.
--

[1] https://pointieststick.com/2024/09/20/this-week-in-plasma-polishing-like-mad/
Comment 167 Patrick O'Callaghan 2024-09-23 09:10:28 UTC Comment hidden (spam)
Comment 168 imaginator 2024-09-23 11:26:18 UTC Comment hidden (spam)
Comment 169 Patrick O'Callaghan 2024-09-23 11:34:25 UTC Comment hidden (spam)
Comment 170 Brian Kaye 2024-10-12 20:23:21 UTC Comment hidden (spam)
Comment 171 Brian Kaye 2024-11-09 18:19:51 UTC Comment hidden (spam)
Comment 172 Nate Graham 2024-11-12 15:16:14 UTC Comment hidden (spam)
Comment 173 Brian Kaye 2024-11-12 16:49:16 UTC Comment hidden (spam)
Comment 174 Brian Kaye 2024-11-12 16:54:40 UTC Comment hidden (spam)
Comment 175 Nate Graham 2024-11-12 17:36:38 UTC
Folks, please try to keep down the chatter in here. I know it's very frustrating that this feature hasn't been implemented on Wayland yet (it is for me too, believe me), but more comments in here about how Wayland sucks or KDE developers are like Microsoft devs or workarounds using other software are off-topic, and I have hidden them to improve the signal-to-noise ratio in here. Let's please try to keep comments technical and steered in the direction of getting the feature implemented. Thanks!
Comment 176 Eugene Shalygin 2024-11-12 17:44:46 UTC
(In reply to Nate Graham from comment #175)
Thanks, Nate, for confirming that KDE developers are  working on this. I guess users would be less confused if you also clean the "Version fixed in" filed, because it is clearly not fixed and most of the recent comments say just that.
Comment 177 Nate Graham 2024-11-12 18:08:14 UTC
Good call, I forgot to do that. Thanks.
Comment 178 Nate Graham 2024-11-25 20:20:59 UTC
*** Bug 496674 has been marked as a duplicate of this bug. ***
Comment 179 Nate Graham 2024-12-19 18:04:22 UTC
*** Bug 471977 has been marked as a duplicate of this bug. ***
Comment 180 Peter Huatan 2025-01-10 19:03:00 UTC
I'd like to add to this bug report.  I can reliably (100% of the time) reproduce this bug as submitted on 

Fedora 41
KDE Frameworks Version:  6.9.0
Qt Version:  6.8.1
Graphics Platform:  Wayland 

Additionally, once I select "Application Launcher" -> Leave -> "Save Session"  CTRL-ALT-DEL becomes 'inactive.'  That is, hitting CTRL-ALT-DEL has no response by the system whatsoever.  To restart or shutdown I have to use the bash command line.  I can also reproduce this behavior 100% of the time.
Comment 181 Patrick O'Callaghan 2025-01-22 13:05:21 UTC
I currently have a set of apps in Autostart, but it's still annoying to have to manually move windows onto the right desktops after logging in. As a partial workaround, I wrote a couple of scripts using kdotool (see your local KDE repo). They can occasionally give strange error messages, and don't do anything for window positions within a desktop because that doesn't seem to be possible, but I thought I'd post them here in case anyone finds them useful. Note that I invoke them manually. There may be a way to automate this, but I haven't found it. (Simple login/logout scripts are not the answer).:

Save:
--------
#!/bin/bash
# Save desktop state of selected windows
# pocallaghan@gmail.com - 22/11/2024

# FIXME: assumes all the window names are distinct
# and restored on restarting

SAVE_FILE=$HOME/.save_desktops

true > "$SAVE_FILE"     # Zero the file

apps=(dolphin firefox evolution konsole)

for app in "${apps[@]}"
do
        for d in $(kdotool search "$app")
        do
#               cn=$(kdotool getwindowclassname $d)
#               [ "$cn" = plasmashell ] && continue     # Plasma has no desktop
                dt=$(kdotool get_desktop_for_window "$d")
                wn=$(kdotool getwindowname "$d")
                echo "$dt $wn" >> "$SAVE_FILE"
        done
done
---------
Restore:
---------
#!/bin/bash
# Restore the virtual desktops of saved windows
# pocallaghan@gmail.com - 23/11/2024

SAVE_FILE=$HOME/.save_desktops

cat "$SAVE_FILE"|while read dt wn ; do
        window=$(kdotool search "$wn")
        [ "$window"x = x ] && continue
        kdotool set_desktop_for_window "$window" "$dt"
done
------
Comment 182 Roke Julian Lockhart Beedell 2025-01-22 14:15:03 UTC
(In reply to Patrick O'Callaghan from comment #181)  
If you uploaded the script to even something as simple as a GitHub Gist or GitLab Snippet, and then linked that here, I think it'd be more useful, since questions and suggestions can't be posted here without notifying 118 people. Thanks for it, though.
Comment 183 Patrick O'Callaghan 2025-01-22 15:00:19 UTC
(In reply to Roke Julian Lockhart Beedell from comment #182)
> (In reply to Patrick O'Callaghan from comment #181)  
> If you uploaded the script to even something as simple as a GitHub Gist or
> GitLab Snippet, and then linked that here, I think it'd be more useful,
> since questions and suggestions can't be posted here without notifying 118
> people. Thanks for it, though.

Good idea. I've put it on:

https://gist.github.com/pjoc/a5059b93321ee67d42f4af8d45b7276f

Thanks
Comment 184 devsk 2025-01-28 08:35:34 UTC
While hunting for any recent updates, I found this. Looks like gnome-48 will contain some form of session restore:

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7682
https://www.phoronix.com/news/Mutter-XDG-Session-Management

I can't really find any recent updates for KDE for similar effort. Is this ever going to be worked on by KDE?
Comment 185 Peter Huatan 2025-01-28 17:19:21 UTC
(In reply to devsk from comment #184)
> While hunting for any recent updates, I found this. Looks like gnome-48 will
> contain some form of session restore:
> 
> https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825
> https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7682
> https://www.phoronix.com/news/Mutter-XDG-Session-Management
> 
> I can't really find any recent updates for KDE for similar effort. Is this
> ever going to be worked on by KDE?

I surely hope so.  I'm sure I'm not the only one who finds it extremely annoying to have to reposition my windows each time I log in or reboot my system.  In fact, I update my system only once a month (dnf upgrade) because I'm tired of having to resize and reposition my windows each time.  

SunOS OpenLook did this beautifully, accurately, and reliably way back in 1990.  I've tried 4 Linux distros, and this does not work on any of the ones I've tried.  Why is it that Linux has so much trouble with basic things like this?  Who does the prioritization of work on Linux platforms?  Do they get the feedback from users?
Comment 186 devsk 2025-01-28 20:02:41 UTC
> Is this ever going to be worked on by KDE?

In my mind, there are two answers to this question, and both are correct answers:

1. We have no plan to get this working on KDE anytime soon
2. We have a plan and here is the schedule (gnome guys took this approach)

I haven't seen 2) for KDE anywhere on the interwebs. Can we at least create a plan? Its fine if its done in 6 months from now or 1 year. But let's have a plan and work toward it.

1) is also fine but then, let's state that clearly so that we can stop coming back to this bug (its almost 4 years old now) every few months.

To me, it almost feels like, because this bug is open, someone is working on it in the background when, in reality, no one is, and there is no way of knowing if someone is or not.

PS: I found the following for kwin but its 2 years old and open: https://invent.kde.org/plasma/kwin/-/merge_requests/3024
Comment 187 Peter Humphrey 2025-01-29 11:21:58 UTC
(In reply to Peter Huatan from comment #185)

> > Is this ever going to be worked on by KDE?
> 
> I surely hope so.  I'm sure I'm not the only one who finds it extremely
> annoying to have to reposition my windows each time I log in or reboot my
> system.  In fact, I update my system only once a month (dnf upgrade) because
> I'm tired of having to resize and reposition my windows each time.  

There is a work-round if you use sddm: select X11 on the login screen, rather than Wayland, and you'll have the proper restoration of desktops and their windows. It works for me, anyway.
Comment 188 imaginator 2025-01-29 12:36:09 UTC
(In reply to Peter Humphrey from comment #187)
> (In reply to Peter Huatan from comment #185)
> 
> > > Is this ever going to be worked on by KDE?
> > 
> > I surely hope so.  I'm sure I'm not the only one who finds it extremely
> > annoying to have to reposition my windows each time I log in or reboot my
> > system.  In fact, I update my system only once a month (dnf upgrade) because
> > I'm tired of having to resize and reposition my windows each time.  
> 
> There is a work-round if you use sddm: select X11 on the login screen,
> rather than Wayland, and you'll have the proper restoration of desktops and
> their windows. It works for me, anyway.

Regarding session-restore, Plasma-X11 works for anybody. ;)  
The question is whether your distribution offers it, as Plasma-wayland unfortunately is the default now.

To me the central problem in this affair seems to be the obviously still missing wayland-protocol (see Comment 89).
Comment 189 Peter Humphrey 2025-01-29 14:37:52 UTC
(In reply to imaginator from comment #188)
> (In reply to Peter Humphrey from comment #187)
> > (In reply to Peter Huatan from comment #185)
> > 
> > > > Is this ever going to be worked on by KDE?
> > > 
> > > I surely hope so.  I'm sure I'm not the only one who finds it extremely
> > > annoying to have to reposition my windows each time I log in or reboot my
> > > system.  In fact, I update my system only once a month (dnf upgrade) because
> > > I'm tired of having to resize and reposition my windows each time.  
> > 
> > There is a work-round if you use sddm: select X11 on the login screen,
> > rather than Wayland, and you'll have the proper restoration of desktops and
> > their windows. It works for me, anyway.
> 
> Regarding session-restore, Plasma-X11 works for anybody. ;)  
> The question is whether your distribution offers it, as Plasma-wayland
> unfortunately is the default now.
> 
> To me the central problem in this affair seems to be the obviously still
> missing wayland-protocol (see Comment 89).

I said: "if you use sddm."
Comment 190 imaginator 2025-01-29 16:49:07 UTC
(In reply to Peter Humphrey from comment #189)
> (In reply to imaginator from comment #188)
> > (In reply to Peter Humphrey from comment #187)
> > > (In reply to Peter Huatan from comment #185)
> > > 
> > > > > Is this ever going to be worked on by KDE?
> > > > 
> > > > I surely hope so.  I'm sure I'm not the only one who finds it extremely
> > > > annoying to have to reposition my windows each time I log in or reboot my
> > > > system.  In fact, I update my system only once a month (dnf upgrade) because
> > > > I'm tired of having to resize and reposition my windows each time.  
> > > 
> > > There is a work-round if you use sddm: select X11 on the login screen,
> > > rather than Wayland, and you'll have the proper restoration of desktops and
> > > their windows. It works for me, anyway.
> > 
> > Regarding session-restore, Plasma-X11 works for anybody. ;)  
> > The question is whether your distribution offers it, as Plasma-wayland
> > unfortunately is the default now.
> > 
> > To me the central problem in this affair seems to be the obviously still
> > missing wayland-protocol (see Comment 89).
> 
> I said: "if you use sddm."

It doesn't matter whether your display manager is sddm, lightdm, gdm or whatever.  If the distribution supports Plasma-X11 in addition to Plasma-Wayland, you can choose between them when logging in.
Comment 191 imaginator 2025-01-29 16:54:11 UTC
(In reply to Peter Huatan from comment #185)
> (In reply to devsk from comment #184)
> > While hunting for any recent updates, I found this. Looks like gnome-48 will
> > contain some form of session restore:
> > 
> > https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825
> > https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7682
> > https://www.phoronix.com/news/Mutter-XDG-Session-Management
> > 
> > I can't really find any recent updates for KDE for similar effort. Is this
> > ever going to be worked on by KDE?
> 
> I surely hope so.  I'm sure I'm not the only one who finds it extremely
> annoying to have to reposition my windows each time I log in or reboot my
> system.  In fact, I update my system only once a month (dnf upgrade) because
> I'm tired of having to resize and reposition my windows each time.  
> 
> SunOS OpenLook did this beautifully, accurately, and reliably way back in
> 1990.  I've tried 4 Linux distros, and this does not work on any of the ones
> I've tried.  Why is it that Linux has so much trouble with basic things like
> this?  Who does the prioritization of work on Linux platforms?  Do they get
> the feedback from users?

A Linux-system is a huge mosaic of several hundreds or more pieces of software provided by probably as many individual projects (communities of developers).  There is no central authority that can set/enforce priorities or order certain devs to get out of slo-mo mode and finally provide what others urgently need.  

By making Wayland the default for Plasma-6 instead of sticking with X11 (and publicly explaining why), KDE unfortunately gave away the only leverage they had in this affair.
Comment 192 Andreas Hartmann 2025-01-29 17:08:14 UTC
(In reply to imaginator from comment #191)
> By making Wayland the default for Plasma-6 instead of sticking with X11 (and
> publicly explaining why), KDE unfortunately gave away the only leverage they
> had in this affair.

openSUSE Leap 16.x still uses X11 / KDE 5 as default as far as I know or better as I'm using it.
Comment 193 imaginator 2025-01-29 18:26:02 UTC
(In reply to Andreas Hartmann from comment #192)
> (In reply to imaginator from comment #191)
> > By making Wayland the default for Plasma-6 instead of sticking with X11 (and
> > publicly explaining why), KDE unfortunately gave away the only leverage they
> > had in this affair.
> 
> openSUSE Leap 16.x still uses X11 / KDE 5 as default as far as I know or
> better as I'm using it.

You probably mean 15.x?  AFAIK they do not even offer Wayland for those versions.  But anyway, we're talking about Plasma-6 here, not Plasma-5.  
KDE chose Wayland as default for Plasma-6.  So if a distribution only offers the default Plasma-6, then  the user has no choice - and no session-restore.
Comment 194 Patrick O'Callaghan 2025-02-01 13:31:51 UTC
(In reply to Patrick O'Callaghan from comment #183)
> (In reply to Roke Julian Lockhart Beedell from comment #182)
> > (In reply to Patrick O'Callaghan from comment #181)  
> > If you uploaded the script to even something as simple as a GitHub Gist or
> > GitLab Snippet, and then linked that here, I think it'd be more useful,
> > since questions and suggestions can't be posted here without notifying 118
> > people. Thanks for it, though.
> 
> Good idea. I've put it on:
> 
> https://gist.github.com/pjoc/a5059b93321ee67d42f4af8d45b7276f
> 
> Thanks

Updated the Restore script to handle window titles with special characters.
Comment 195 imaginator 2025-02-08 16:14:03 UTC
(In reply to Patrick O'Callaghan from comment #181)
> I currently have a set of apps in Autostart, but it's still annoying to have
> to manually move windows onto the right desktops after logging in. As a
> partial workaround, I wrote a couple of scripts using kdotool (see your
> local KDE repo). They can occasionally give strange error messages, and
> don't do anything for window positions within a desktop because that doesn't
> seem to be possible, but I thought I'd post them here in case anyone finds
> them useful. Note that I invoke them manually. There may be a way to
> automate this, but I haven't found it. (Simple login/logout scripts are not
> the answer).:

Have you ever put the script that restores the windows into "Autostart" as well?  I don't know whether one has any influence on the sequence in which the programs are started but _if_ they are started in alphabetical order you could name it something like z_script.

More on topic: the funny and real mean thing with session-save/-restore in Plasma-wayland (-5.27.11.1) is that _restoring_ a previous session does work fine (perhaps apart from minor differences in window-positions).  I can tell because when I log out of a Plasma-X11 session and then log in to a Plasma-wayland session, the previous (Plasma-X11) session is restored almost perfectly, incl. kate, dolphin, whatever.  And that's reproducible.  However, if one then logs out of the Plasma-wayland session and in to a Plasma-X11 session (or Plasma-wayland session), the previous session is gone, except for non-KDE-apps like Firefox or Thunderbird.

So, from what I see here with Plasma-wayland, the real problem is not _restoring_ a session but _saving_ it correctly.  And what makes matters worse (somehow) is that the state of non-KDE-apps like Firefox/Thunderbird _is_ saved correctly in ksmserverrc [1].  What's not saved is the state of KDE-apps.  But perhaps you know all this already. ;)

--

[1]
[LegacySession: saved at previous logout]
count=0

[LegacySession: saved by user]
count=0

[Session: saved at previous logout]
clientId1=104c55580000173762586300000023360009
clientId2=104c55580000173870527300000023170111
clientId3=104c55580000173902919800000078330002
count=3
program1=thunderbird
program2=firefox
program3=pulseaudio
restartCommand1=/opt/thunderbird/thunderbird,--sm-client-id,104c55580000173762586300000023360009
restartCommand2=/opt/firefox/firefox,--sm-client-id,104c55580000173870527300000023170111
restartCommand3=
[...]
Comment 196 Patrick O'Callaghan 2025-02-09 10:39:28 UTC
(In reply to imaginator from comment #195)
> (In reply to Patrick O'Callaghan from comment #181)
> > I currently have a set of apps in Autostart, but it's still annoying to have
> > to manually move windows onto the right desktops after logging in. As a
> > partial workaround, I wrote a couple of scripts using kdotool (see your
> > local KDE repo). They can occasionally give strange error messages, and
> > don't do anything for window positions within a desktop because that doesn't
> > seem to be possible, but I thought I'd post them here in case anyone finds
> > them useful. Note that I invoke them manually. There may be a way to
> > automate this, but I haven't found it. (Simple login/logout scripts are not
> > the answer).:
> 
> Have you ever put the script that restores the windows into "Autostart" as
> well?  I don't know whether one has any influence on the sequence in which
> the programs are started but _if_ they are started in alphabetical order you
> could name it something like z_script.

It doesn't work (I tried it). AFAIK Plasma fires all the Autostart scripts concurrently and I don't see a way to make the Restore script wait until everything else is up, or at least has mapped its window(s). Maybe there's some systemd magic that would do it.
 
> More on topic: the funny and real mean thing with session-save/-restore in
> Plasma-wayland (-5.27.11.1) is that _restoring_ a previous session does work
> fine (perhaps apart from minor differences in window-positions).  I can tell
> because when I log out of a Plasma-X11 session and then log in to a
> Plasma-wayland session, the previous (Plasma-X11) session is restored almost
> perfectly, incl. kate, dolphin, whatever.  And that's reproducible. 
> However, if one then logs out of the Plasma-wayland session and in to a
> Plasma-X11 session (or Plasma-wayland session), the previous session is
> gone, except for non-KDE-apps like Firefox or Thunderbird.
> 
> So, from what I see here with Plasma-wayland, the real problem is not
> _restoring_ a session but _saving_ it correctly.  And what makes matters
> worse (somehow) is that the state of non-KDE-apps like Firefox/Thunderbird
> _is_ saved correctly in ksmserverrc [1].  What's not saved is the state of
> KDE-apps.  But perhaps you know all this already. ;)

That is interesting.
Comment 197 imaginator 2025-02-09 12:11:01 UTC
(In reply to Patrick O'Callaghan from comment #196)
> (In reply to imaginator from comment #195)
> > (In reply to Patrick O'Callaghan from comment #181)
> > > I currently have a set of apps in Autostart, but it's still annoying to have
> > > to manually move windows onto the right desktops after logging in. As a
> > > partial workaround, I wrote a couple of scripts using kdotool (see your
> > > local KDE repo). They can occasionally give strange error messages, and
> > > don't do anything for window positions within a desktop because that doesn't
> > > seem to be possible, but I thought I'd post them here in case anyone finds
> > > them useful. Note that I invoke them manually. There may be a way to
> > > automate this, but I haven't found it. (Simple login/logout scripts are not
> > > the answer).:
> > 
> > Have you ever put the script that restores the windows into "Autostart" as
> > well?  I don't know whether one has any influence on the sequence in which
> > the programs are started but _if_ they are started in alphabetical order you
> > could name it something like z_script.
> 
> It doesn't work (I tried it). AFAIK Plasma fires all the Autostart scripts
> concurrently and I don't see a way to make the Restore script wait until
> everything else is up, or at least has mapped its window(s). Maybe there's
> some systemd magic that would do it.

You could use "sleep" (-> sleep --help) to delay the execution of the relevant parts of your script until other scripts have run or the desktop is fired up.  Example:

#!/bin/bash

# Test "sleep".
sleep 10
echo "This was a test."


HTH.
Comment 198 Roke Julian Lockhart Beedell 2025-02-09 13:52:47 UTC
(In reply to imaginator from comment #197)  
On older systems, this wouldn't really work, since there's always something that randomly takes ages to launch. Is there a way to wait for a specific process to be invoked? If so, perhaps wait for `plasmashell` to be running, then run the script, since it's usually one of the last things to run. https://stackoverflow.com/a/9118509/9731176 might be of use.
Comment 199 Patrick O'Callaghan 2025-02-09 15:10:39 UTC
(In reply to imaginator from comment #197)
> (In reply to Patrick O'Callaghan from comment #196)
> > (In reply to imaginator from comment #195)
> > > (In reply to Patrick O'Callaghan from comment #181)
> > > > I currently have a set of apps in Autostart, but it's still annoying to have
> > > > to manually move windows onto the right desktops after logging in. As a
> > > > partial workaround, I wrote a couple of scripts using kdotool (see your
> > > > local KDE repo). They can occasionally give strange error messages, and
> > > > don't do anything for window positions within a desktop because that doesn't
> > > > seem to be possible, but I thought I'd post them here in case anyone finds
> > > > them useful. Note that I invoke them manually. There may be a way to
> > > > automate this, but I haven't found it. (Simple login/logout scripts are not
> > > > the answer).:
> > > 
> > > Have you ever put the script that restores the windows into "Autostart" as
> > > well?  I don't know whether one has any influence on the sequence in which
> > > the programs are started but _if_ they are started in alphabetical order you
> > > could name it something like z_script.
> > 
> > It doesn't work (I tried it). AFAIK Plasma fires all the Autostart scripts
> > concurrently and I don't see a way to make the Restore script wait until
> > everything else is up, or at least has mapped its window(s). Maybe there's
> > some systemd magic that would do it.
> 
> You could use "sleep" (-> sleep --help) to delay the execution of the
> relevant parts of your script until other scripts have run or the desktop is
> fired up.  Example:
> 
> #!/bin/bash
> 
> # Test "sleep".
> sleep 10
> echo "This was a test."
> 
> 
> HTH.

I generally think timer-based solutions are inferior to triggers, but you can do that if want. It strikes me as even more kludgey than what I already have, and given that the user has to manually save the session anyway it wouldn't even have the advantage of transparency.
Comment 200 Brian Kaye 2025-02-19 16:45:14 UTC
Behaviour may have changed. Not sure of when this happened but I just noticed that the session restore does not resume windows to the first virtual desktop. It restores the windows to the last virtual desktop that was used in the previous session. I little window is flashed that says the name of the virtual desktop and then proceeds to restore the windows in that desktop.
Comment 201 devsk 2025-03-05 00:53:15 UTC
I finally moved to wayland with 6.3. I had to jump through some hoops though. Here is the code in case someone wants to try the save/restore scripts (make sure to read the comments on the gist before using this code):

https://gist.github.com/devsk/9eff2d08d6cd5772afd2b178930b66ae
Comment 202 devsk 2025-03-05 03:26:25 UTC
(In reply to Roke Julian Lockhart Beedell from comment #198)
> (In reply to imaginator from comment #197)  
> On older systems, this wouldn't really work, since there's always something
> that randomly takes ages to launch. Is there a way to wait for a specific
> process to be invoked? If so, perhaps wait for `plasmashell` to be running,
> then run the script, since it's usually one of the last things to run.
> https://stackoverflow.com/a/9118509/9731176 might be of use.

I simply went with the option of starting all the applications from the saved session and then giving user a dialog box to OK the moving of the windows to their respective desktops, positioning them at the saved location and resizing them as per the saved info.

The user just waits for all the application windows to start in the current desktop and then, pressing OK does the work. There are tricks to center the dialog box, keep it above all windows and activating it. kdotool works really well to do the rest.

Checkout the gist I posted. Most of code can be used as is. Only binary names need adjusting/addition/deletion.
Comment 203 Patrick O'Callaghan 2025-03-05 12:23:26 UTC
(In reply to devsk from comment #202)
> (In reply to Roke Julian Lockhart Beedell from comment #198)
> > (In reply to imaginator from comment #197)  
> > On older systems, this wouldn't really work, since there's always something
> > that randomly takes ages to launch. Is there a way to wait for a specific
> > process to be invoked? If so, perhaps wait for `plasmashell` to be running,
> > then run the script, since it's usually one of the last things to run.
> > https://stackoverflow.com/a/9118509/9731176 might be of use.
> 
> I simply went with the option of starting all the applications from the
> saved session and then giving user a dialog box to OK the moving of the
> windows to their respective desktops, positioning them at the saved location
> and resizing them as per the saved info.
> 
> The user just waits for all the application windows to start in the current
> desktop and then, pressing OK does the work. There are tricks to center the
> dialog box, keep it above all windows and activating it. kdotool works
> really well to do the rest.
> 
> Checkout the gist I posted. Most of code can be used as is. Only binary
> names need adjusting/addition/deletion.

What does kwin-fix_crazy_gesture.patch do? Seems to be a patch to the kwin source code.
Comment 204 devsk 2025-03-05 17:02:17 UTC
(In reply to Patrick O'Callaghan from comment #203)
> (In reply to devsk from comment #202)
> > (In reply to Roke Julian Lockhart Beedell from comment #198)
> > > (In reply to imaginator from comment #197)  
> > > On older systems, this wouldn't really work, since there's always something
> > > that randomly takes ages to launch. Is there a way to wait for a specific
> > > process to be invoked? If so, perhaps wait for `plasmashell` to be running,
> > > then run the script, since it's usually one of the last things to run.
> > > https://stackoverflow.com/a/9118509/9731176 might be of use.
> > 
> > I simply went with the option of starting all the applications from the
> > saved session and then giving user a dialog box to OK the moving of the
> > windows to their respective desktops, positioning them at the saved location
> > and resizing them as per the saved info.
> > 
> > The user just waits for all the application windows to start in the current
> > desktop and then, pressing OK does the work. There are tricks to center the
> > dialog box, keep it above all windows and activating it. kdotool works
> > really well to do the rest.
> > 
> > Checkout the gist I posted. Most of code can be used as is. Only binary
> > names need adjusting/addition/deletion.
> 
> What does kwin-fix_crazy_gesture.patch do? Seems to be a patch to the kwin
> source code.

On all platforms where I have used the swipe gesture, it takes to the right desktop when you swipe left. With X11, it was like that (imagine years of motor tuning). With wayland, it drove me crazy because every time I wanted to go a desktop, it took me to the wrong desktop.

This behavior would be typically changeable but everything I tried using touchegg, confused the desktop navigation more: touchegg would move it to next but kwin would move it back, meaning that it did not change the desktop. After some real desperation, I took the drastic step of finding and toggling the gesture in code.
Comment 205 Patrick O'Callaghan 2025-03-05 17:57:47 UTC
(In reply to devsk from comment #204)
> (In reply to Patrick O'Callaghan from comment #203)
> > (In reply to devsk from comment #202)
> > > (In reply to Roke Julian Lockhart Beedell from comment #198)
> > > > (In reply to imaginator from comment #197)  
> > > > On older systems, this wouldn't really work, since there's always something
> > > > that randomly takes ages to launch. Is there a way to wait for a specific
> > > > process to be invoked? If so, perhaps wait for `plasmashell` to be running,
> > > > then run the script, since it's usually one of the last things to run.
> > > > https://stackoverflow.com/a/9118509/9731176 might be of use.
> > > 
> > > I simply went with the option of starting all the applications from the
> > > saved session and then giving user a dialog box to OK the moving of the
> > > windows to their respective desktops, positioning them at the saved location
> > > and resizing them as per the saved info.
> > > 
> > > The user just waits for all the application windows to start in the current
> > > desktop and then, pressing OK does the work. There are tricks to center the
> > > dialog box, keep it above all windows and activating it. kdotool works
> > > really well to do the rest.
> > > 
> > > Checkout the gist I posted. Most of code can be used as is. Only binary
> > > names need adjusting/addition/deletion.
> > 
> > What does kwin-fix_crazy_gesture.patch do? Seems to be a patch to the kwin
> > source code.
> 
> On all platforms where I have used the swipe gesture, it takes to the right
> desktop when you swipe left. With X11, it was like that (imagine years of
> motor tuning). With wayland, it drove me crazy because every time I wanted
> to go a desktop, it took me to the wrong desktop.
> 
> This behavior would be typically changeable but everything I tried using
> touchegg, confused the desktop navigation more: touchegg would move it to
> next but kwin would move it back, meaning that it did not change the
> desktop. After some real desperation, I took the drastic step of finding and
> toggling the gesture in code.

So this patch has actually nothing to do with session restore. I'd suggest posting it somewhere else to avoid confusion.

I've had a quick look at your scripts but haven't tried them. They seem quite complicated, but maybe they do more than mine. I've taken note of how you use 'kdotool windowmove' and have added this to my own scripts (don't know why I hadn't noticed this before :-). I'll upload them shortly (still not very familiar with Gist to be honest).
Comment 206 Patrick O'Callaghan 2025-03-05 18:13:55 UTC
(In reply to Patrick O'Callaghan from comment #194)
> (In reply to Patrick O'Callaghan from comment #183)
> > (In reply to Roke Julian Lockhart Beedell from comment #182)
> > > (In reply to Patrick O'Callaghan from comment #181)  
> > > If you uploaded the script to even something as simple as a GitHub Gist or
> > > GitLab Snippet, and then linked that here, I think it'd be more useful,
> > > since questions and suggestions can't be posted here without notifying 118
> > > people. Thanks for it, though.
> > 
> > Good idea. I've put it on:
> > 
> > https://gist.github.com/pjoc/a5059b93321ee67d42f4af8d45b7276f
> > 
> > Thanks
> 
> Updated the Restore script to handle window titles with special characters.

Updated again to save/restore window positions.
Comment 207 devsk 2025-03-06 04:12:50 UTC
(In reply to Patrick O'Callaghan from comment #205)
> 
> So this patch has actually nothing to do with session restore. I'd suggest
> posting it somewhere else to avoid confusion.

Yes. I don't think anybody cares about flipping the gestures behavior. I will keep this patch around.

> I've had a quick look at your scripts but haven't tried them. They seem
> quite complicated, but maybe they do more than mine. I've taken note of how
> you use 'kdotool windowmove' and have added this to my own scripts (don't
> know why I hadn't noticed this before :-). I'll upload them shortly (still
> not very familiar with Gist to be honest).

Yes. My script does do way more..:-) It saves a lot more information in a format which is easily read in bash. Then, it starts all the apps and waits for the user to ack the restoration process which restores their desktop, position and size.

I had to add a lot of code for robustness e.g. some random processes make their way into 'kdotool search' when they don't have a real window associated with them e.g. plasmashell. 

For example, restoring from X11 to wayland, the window class changes from konsole to org.kde.konsole.

For example, the size and location on wayland are floating point numbers sometimes, which was not apparent until wayland locked up on creating a window with 0 size with infinite memory allocation loop and got killed by OOM.

For example, if you saved session from a crontab periodically, kdotool just doesn't find any windows because crontab does not have access to the user environment to access the DBUS.

Lots of accounting for quirks.
Comment 208 Patrick O'Callaghan 2025-03-06 11:31:29 UTC
(In reply to devsk from comment #207)
> (In reply to Patrick O'Callaghan from comment #205)
> > 
> > So this patch has actually nothing to do with session restore. I'd suggest
> > posting it somewhere else to avoid confusion.
> 
> Yes. I don't think anybody cares about flipping the gestures behavior. I
> will keep this patch around.

I'd suggest keeping it separate from the rest. It's confusing to have it lumped in with the save/restore stuff.

> > I've had a quick look at your scripts but haven't tried them. They seem
> > quite complicated, but maybe they do more than mine. I've taken note of how
> > you use 'kdotool windowmove' and have added this to my own scripts (don't
> > know why I hadn't noticed this before :-). I'll upload them shortly (still
> > not very familiar with Gist to be honest).
> 
> Yes. My script does do way more..:-) It saves a lot more information in a
> format which is easily read in bash. Then, it starts all the apps and waits
> for the user to ack the restoration process which restores their desktop,
> position and size.

All the apps I've used already remember their sizes on restarting, so I don't bother with that.

I'll consider using Zenity or similar, but given that it only helps with restoring and not saving, I wouldn't place a high priority on it. If there were a reliable way to save state on logging out, that would change. Unfortunately the Auto-start logout scripts only seem to trigger once all windows have been destroyed.

> I had to add a lot of code for robustness e.g. some random processes make
> their way into 'kdotool search' when they don't have a real window
> associated with them e.g. plasmashell. 

I already skip plasmashell, and if anything else has this behaviour it would be trivial to add.

> For example, restoring from X11 to wayland, the window class changes from
> konsole to org.kde.konsole.

I don't care about X11. I wrote this specifically for Wayland.

> For example, the size and location on wayland are floating point numbers
> sometimes, which was not apparent until wayland locked up on creating a
> window with 0 size with infinite memory allocation loop and got killed by
> OOM.
>

kdotool can return floating-point values for position, but doesn't accept them when trying to set it. This to me is a bug. However I'm not worried about fractions of a pixel, so I just truncate these to integers.

> For example, if you saved session from a crontab periodically, kdotool just
> doesn't find any windows because crontab does not have access to the user
> environment to access the DBUS.

Not something I do. I only save the state explicitly.
Comment 209 devsk 2025-03-06 23:19:04 UTC
> All the apps I've used already remember their sizes on restarting, so I don't bother with that.

konsole doesn't do that for me. It opens a single window of a dimension from the profile.

My script opens as many konsole windows as you had open before, moves to the right location in the right desktop and sizes them.
Comment 210 Patrick O'Callaghan 2025-03-07 11:24:35 UTC
(In reply to devsk from comment #209)
> > All the apps I've used already remember their sizes on restarting, so I don't bother with that.
> 
> konsole doesn't do that for me. It opens a single window of a dimension from
> the profile.
> 
> My script opens as many konsole windows as you had open before, moves to the
> right location in the right desktop and sizes them.

Thanks for pointing that out I almost never have more than one Konsole terminal open so hadn't noticed. It does however remember the size of the single one it opens.
Comment 211 Kevin Gilbert 2025-03-10 23:28:42 UTC Comment hidden (spam)
Comment 212 Eugene Savitsky 2025-03-11 00:13:52 UTC Comment hidden (spam)
Comment 213 Eugene Savitsky 2025-03-11 00:21:53 UTC
Some coverage: https://www.youtube.com/watch?v=UAMAlqqVijY
Comment 214 imaginator 2025-03-11 09:31:41 UTC Comment hidden (spam)
Comment 215 devsk 2025-03-14 06:08:42 UTC Comment hidden (spam)
Comment 216 David Edmundson 2025-03-14 09:14:54 UTC
This is a bug tracker, not a forum. If you're not adding something, don't post things.

People are working on this. 

There's the window management stuff in kwin that's linked somewhere, rebased very recently and there's also Qt work here: https://codereview.qt-project.org/c/qt/qtwayland/+/603992

But that's not the important part of session restore. You need to actually restart the apps. 

We cannot blindly copy XSMP because that's a huge security hole for Flatpak'd apps. *including on X11*

 It is going to need something that that allows apps in flatpaks to request a restart command and have something outside that rewrite that command with the security prefixing. 
This is the part that's in progress in xdg-desktop-portals and why the Wayland part is seemingly stuck.
Comment 217 devsk 2025-03-14 21:10:57 UTC
(In reply to David Edmundson from comment #216)
> This is a bug tracker, not a forum. If you're not adding something, don't
> post things.

I posted something that gets me 95% of the way there. If KDE had gotten me there 1/2/3/4 years ago, I would have moved to wayland much earlier and never complained.

> People are working on this. 

Why so secret about it if people are working on it? We rarely see any updates here or anywhere else I could find with google search. What I could find showed that the development stopped more than 2 years ago.

> This is the part that's in progress in xdg-desktop-portals and why the
> Wayland part is seemingly stuck.

Can you please point to the discussion thread for this? I need read-only access and have no (or had any) intention of spamming anyone. The last thing I want to do is to annoy the people who are working voluntarily on this feature.