Bug 480280

Summary: Power management actions shown even when they don't fit the use case of remote login
Product: [Plasma] plasmashell Reporter: Sebastian Mogl <sebastian.mogl>
Component: Session ManagementAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: natalie_clarius, nate, sebastian.mogl
Priority: NOR Keywords: usability
Version First Reported In: 5.27.5   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Sebastian Mogl 2024-01-24 17:04:53 UTC
Currently, all the Menus that allow one to leave KDE (logout, lock screen, poweroff, …) always assume a local session, even when running as a remote session under x2go, xrdp, etc.

However, when running remote the actions available don't fit the use case and should be in most cases limited to logging out and suspending the session. (Most are useless when regular users don't even have the permissions for things like power controls)

The lock screen could be argued over, I'm in favor of suspending the session and completely closing the connection in order to lock it.

The Mate Desktop solved this problem by using librda to detect how the desktop was started, which actions are available and calling the appropriate handlers.

librda: https://github.com/ArcticaProject/librda
Corresponding blog post: https://sunweavers.net/blog/node/82

Context: Librda detects remote sessions based on Environment variables and the logout/suspend functions call the appropriate commands.

This is a resubmitted version of Bug 479403 addressing its root cause.
Comment 1 Sebastian Mogl 2024-08-28 11:11:14 UTC
So after doing some research, this is probably best implemented as a session-management-backend in plasma-worspace in libkworkspace/sessionmanagementbackend.cpp¹.

* New Class that implements and only allows logout.
    * logout by running the command: `x2goterminate-session`
    * Session status would be always Ready
* Hook in initializer that uses the X2go-Backend if the `X2GO_SESSION` envoirnment variable is set before checking for logind after checking for the test session variable.

¹: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/libkworkspace/sessionmanagementbackend.cpp

Locking could be handled by running `x2gosuspendsession`, but that isn't handled by the backends yet.