Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Session: offer Restart and Shut Down only in the session on the monitor (lord.session.onMonitor), since lord-sessiond reads requests from that one alone; a remote-desktop-only session showed the countdown and then nothing

Federico Pereira9f9eed11ca23
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3909c81..e829a2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,9 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
### Fixed
+- **Restart… and Shut Down… in a session seen only through the remote desktop** showed the
+ countdown and then did nothing: only the session on the monitor can ask for them. They are now
+ offered only there.
- **The Store now follows apt's priorities** (`/etc/apt/preferences.d`), choosing the same versions
as `apt`. On the Raspberry Pi image, "Update all" could take Raspberry Pi's builds of Chromium,
BlueZ and other Debian packages instead of Debian's; it no longer does, and Raspberry Pi's kernel
diff --git a/docs/SESSIONS.md b/docs/SESSIONS.md
index f1fd031..eea9a35 100644
--- a/docs/SESSIONS.md
+++ b/docs/SESSIONS.md
@@ -246,6 +246,10 @@ card lent to a session has not been tested on real hardware yet.
screen's channel (`RP_GREETER_IN`) and the sheet shows the refusal.
- then the same closed path as the login screen: `systemctl reboot` or `poweroff`, fixed path,
fixed environment, logged as `reboot requested by <user> (<n> other session(s) open)`.
+- **Only on the monitor's session** (0.8.5): the items appear only while the session holds
+ lord-sessiond's seat connection (`lord.session.onMonitor()`, which `session.canPower()` checks). A
+ session seen only through the remote desktop isn't offered them; before 0.8.5 it showed the
+ sheet and nothing happened at the end of the countdown.
- **Tested on VM 122:** the menu items, the sheet in light and dark, the countdown, Cancel and
Escape (no restart after the minute), the Classic Power button, a real Shut Down (`qm start` back
to the login screen) and a real Restart (back to the login screen). The refusal with other users
diff --git a/sdk/power.jsx b/sdk/power.jsx
index 84ef45d..8370913 100644
--- a/sdk/power.jsx
+++ b/sdk/power.jsx
@@ -23,7 +23,10 @@ export const POWER_SECONDS = 60;
// null, or { action: 'reboot'|'poweroff', until (ms), state: 'ask'|'sent'|'denied'|'unavailable' }
export const powerAsk = createStore(null);
-export const canPower = () => typeof lord.session !== 'undefined' && typeof lord.session.power === 'function' && lord.session.managed();
+// Only in the session on the monitor: lord-sessiond reads requests from that one alone, so a session
+// seen only through the remote desktop isn't offered Restart or Shut Down.
+export const canPower = () => typeof lord.session !== 'undefined' && typeof lord.session.power === 'function' && lord.session.managed()
+ && (typeof lord.session.onMonitor !== 'function' || lord.session.onMonitor());
export function askPower(action) {
if (action !== 'reboot' && action !== 'poweroff') return;
diff --git a/server/src/ui/js_sys.c b/server/src/ui/js_sys.c
index db85777..51e8bf2 100644
--- a/server/src/ui/js_sys.c
+++ b/server/src/ui/js_sys.c
@@ -1918,8 +1918,17 @@ static JSValue f_session_power(JSContext *c, JSValueConst this_val, int argc, JS
return JS_TRUE;
}
+/* lord.session.onMonitor(): is this session the one lord-sessiond shows on the monitor (it holds the
+ * seat connection)? Only that session's requests reach lord-sessiond, so Restart and Shut Down are
+ * offered only there; a session seen only through the remote desktop doesn't have it. */
+static JSValue f_session_on_monitor(JSContext *c, JSValueConst this_val, int argc, JSValueConst *argv) {
+ (void)this_val; (void)argc; (void)argv;
+ return JS_NewBool(c, !greeter_mode && mirror_has_seat());
+}
+
static const JSCFunctionListEntry session_funcs[] = {
JS_CFUNC_DEF("managed", 0, f_session_managed),
+ JS_CFUNC_DEF("onMonitor", 0, f_session_on_monitor),
JS_CFUNC_DEF("power", 1, f_session_power),
JS_CFUNC_DEF("lock", 0, f_session_lock),
JS_CFUNC_DEF("switchUser", 0, f_session_switch),