KDE logging out remotely

Hello. I have tried to look for a solution to this issue but nothing I find is working.

I am using KDE plasma on Debian Bookworm I connect locally sometimes, and remotely with ThinLinc over SSH more frequently. If I forget to logout locally I am unable to view the desktop remotely.

I am looking for a solution to do either of the below preferably both.

  1. Logout cleanly of a local session remotely using SSH (qdbus doesn’t work over SSH)

  2. I would like the system to automatically logout rather than just lock after a period of inactivity.

Both these things I feel should be easy to do, but I can’t find the info on how to do them in KDE so any help please.

I think I managed to work around it by logging in through xRDP and then running the below command from terminal.

qdbus org.kde.Shutdown /Shutdown org.kde.Shutdown.logout

I was then able to connect using ThinLinc.

Still hoping someone knows how to set an automatic logout?