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.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Login screen only while shown: lord-sessiond stops it 10 s after a session takes the monitor and starts it on demand; on lock/switch the monitor is taken from the session first (screen dark, input revoked) so an unlocked desktop never shows while it starts; no duplicate hand-over on lock; set_mode no longer copies onto itself; greeter socket polled every 20 ms; timings logged. Boot splash timer (s.ms, bottom right) and the time to the first frame from the kernel's start in the log
Federico Pereira17e3e072aa25
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 744cd12..d98fbb8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,10 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Added+- **A boot timer.** The boot splash shows the time since it started, in seconds and milliseconds, in+ the bottom right corner, and the log records when the desktop's first frame reached the screen,+ counted from the kernel's start (`first frame on the monitor 7.267 s after the kernel started`), for+ comparing versions and machines.- **`lordos-fetch`.** Type it in a terminal to see the LordOS crown beside a summary of yourcomputer: system, kernel, CPU, GPU, display, memory, disk, packages and how apps are isolated.`lordos-fetch --share` leaves out your user and computer names, for a screenshot you'll post.@@ -80,6 +84,13 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Fixed+- **The login screen no longer stays running behind your session.** It was a whole display server+ kept in memory after sign-in (about 53 MB of its own, 78 MB counting shared pages, measured in a+ VMware VM). It now closes 10 seconds after a session takes the screen and starts again in a few+ milliseconds when you lock, switch user or log out; the whole system went from 603 to 548 MB in use.+ When you lock, the screen goes dark first and only then is the login screen started, so the unlocked+ desktop is never left visible meanwhile. Also fixed: asking for the login screen twice on a lock (the+ monitor handed over a second time), and its mode coming out empty when a request was retried.- **On virtual cards that don't wait for the screen's refresh, the desktop drew hundreds of frames asecond.** The VMware graphics driver (`vmwgfx`) completes each page flip at once, so the compositor andevery app followed it at 500–580 frames a second on a 60 Hz display, using CPU for frames nobody sees.diff --git a/docs/SESSIONS.md b/docs/SESSIONS.mdindex 5002621..7841447 100644--- a/docs/SESSIONS.md+++ b/docs/SESSIONS.md@@ -185,6 +185,18 @@ after that the wait is 1, 2, 4… seconds, up to 5 minutes.### Lock, switch user and log out+**The login screen runs only when it is shown (0.8.5).** It used to stay running behind the session+after sign-in, a whole `lord-server` (about 53 MB of its own memory, 78 MB of PSS, measured in a VMware+VM). Now `lord-sessiond` stops it 10 s after a session takes the monitor (`GREETER_LINGER_S`), and+`sd_greeter_get` starts it again for a lock, a user switch or a log out; its socket is up in 8–22 ms+and it reaches the monitor about 20 ms after it's asked for. On a lock or a switch the monitor is taken+from the session **first** (`leave_for_greeter`: input revoked, its framebuffers removed, the screen+dark), and only then is the login screen asked for, so an unlocked desktop never stays on the screen+while it starts. Taking the monitor away is the slow part on some drivers: 1.18 s on VMware's+`vmwgfx` (removing the framebuffer on the screen turns the output off), the same as before this change.+The log says both: `monitor: taken from <user> in N ms` and `monitor: the login screen (lock), N ms+after the screen went dark`.+- **Lock screen:** ❖L, ❖Ctrl+Q, or the logo menu → «Lock Screen».1. The session sends `RP_SESSION {"a":"lock"}` to all its viewers.2. The monitor shows the login screen with that user.diff --git a/server/src/remote/sess.c b/server/src/remote/sess.cindex ecdbef8..09418ab 100644--- a/server/src/remote/sess.c+++ b/server/src/remote/sess.c@@ -338,10 +338,10 @@ static void spawn(const struct passwd *pw, const char *rt, const char *lang, int}static int wait_socket(const char *path, uid_t uid, int greeter) {- for (int i = 0; i < 200; i++) { /* up to 20 s while the theme loads */+ for (int i = 0; i < 1000; i++) { /* up to 20 s while the theme loads, every 20 ms */int fd = greeter ? connect_path(path) : sd_session_connect(uid);if (fd >= 0) return fd;- usleep(100000);+ usleep(20000);}return -1;}diff --git a/server/src/remote/sessiond.c b/server/src/remote/sessiond.cindex 3dfa79b..56a4fba 100644--- a/server/src/remote/sessiond.c+++ b/server/src/remote/sessiond.c@@ -404,6 +404,13 @@ static void file_value(const char *path, const char *key, char *out, size_t n) {}static char greeter_mode[8] = "login", greeter_user[33];+/* The login screen costs a lord-server (about 50 MB of its own memory, measured in a VM) and isn't+ * needed while a session is on the monitor: it is stopped this long after a session takes the monitor,+ * and started again for a lock, a user switch or a log out (sd_greeter_get starts it on demand). */+#define GREETER_LINGER_S 10+static double greeter_stop_at;+static double greeter_asked_at;+static int left_on_purpose; /* the monitor was just taken from the session for a lock or a switch */ /* when the login screen was asked for (lock, switch), to log the wait *//* The last user whose session was shown on the monitor: the login screen preselects it. Kept in* SD_LAST_USER (root's, 0644) so it survives a reboot; only a valid user name is read back. */@@ -488,8 +495,13 @@ static WorkKind pending;static char pending_user[33];static void set_mode(const char *mode, const char *user) {- snprintf(greeter_mode, sizeof greeter_mode, "%s", mode);- snprintf(greeter_user, sizeof greeter_user, "%s", user ? user : "");+ /* through copies: callers may pass greeter_mode and greeter_user themselves (a retry), and an+ * snprintf onto its own source is undefined (it left the mode empty) */+ char m[sizeof greeter_mode], u[sizeof greeter_user];+ snprintf(m, sizeof m, "%s", mode ? mode : "login");+ snprintf(u, sizeof u, "%s", user ? user : "");+ memcpy(greeter_mode, m, sizeof m);+ memcpy(greeter_user, u, sizeof u);}/* In a child: the login screen (creates it if needed) to the monitor. */@@ -584,7 +596,7 @@ static int start_worker(WorkKind kind, const char *user, char *pass) {static void show_greeter(const char *mode, const char *user) {set_mode(mode, user);- if (start_worker(W_GREETER, NULL, NULL)) pending = W_GREETER;+ if (start_worker(W_GREETER, NULL, NULL)) { pending = W_GREETER; sd_log("login screen (%s) queued behind a running worker", greeter_mode); }}static void power(const char *what, const char *who) {@@ -648,7 +660,11 @@ static void first_frame(void) {int f = open(SD_FIRST_FRAME, O_WRONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW, 0644);if (f < 0) { sd_log("warning: %s: %s", SD_FIRST_FRAME, strerror(errno)); return; }close(f);- sd_log("first frame on the monitor: the boot splash can go");+ /* the boot time to the desktop, from the kernel's start (CLOCK_BOOTTIME), for the logs and the+ * results (docs/RESULTS.md) */+ struct timespec bt;+ clock_gettime(CLOCK_BOOTTIME, &bt);+ sd_log("first frame on the monitor %.3f s after the kernel started: the boot splash can go", bt.tv_sec + bt.tv_nsec / 1e9);}/* No card with KMS (0.8.1): before this, the boot ended on a silent black screen. The message goes@@ -697,6 +713,9 @@ static void from_worker(void) {if (n <= 0) { if (fd >= 0) close(fd); return; }char user[40];if (!strcmp(buf, "show g") && fd >= 0) {+ greeter_stop_at = 0;+ if (greeter_asked_at) sd_log("monitor: the login screen (%s), %.0f ms after the screen went dark", greeter_mode, (rd_now() - greeter_asked_at) * 1000);+ greeter_asked_at = 0;set_shown('g', NULL);if (sd_mon_show(fd, "-", keep_lend())) { sd_mon_lost(); set_shown('-', NULL); }return;@@ -705,7 +724,7 @@ static void from_worker(void) {sd_log("monitor: %s's session", user);set_shown('u', user);if (sd_mon_show(fd, user, keep_lend())) { sd_mon_lost(); set_shown('-', NULL); show_greeter("login", NULL); }- else save_last_user(user);+ else { save_last_user(user); greeter_stop_at = rd_now() + GREETER_LINGER_S; }return;}if (fd >= 0) close(fd);@@ -747,6 +766,24 @@ static void session_power(const char *j) {power(what, who);}+/* Lock and switch user: the login screen isn't kept running behind a session (it is stopped a few+ * seconds after a session takes the monitor, greeter_stop_at), and starting it takes a moment. So the+ * monitor is taken from the session first: input revoked, its framebuffers removed (the screen goes+ * dark), and only then is the login screen asked for. An unlocked desktop is never left on the screen+ * while it starts. */+static void leave_for_greeter(const char *mode) {+ char user[40];+ snprintf(user, sizeof user, "%s", shown_user);+ greeter_stop_at = 0;+ greeter_asked_at = rd_now();+ left_on_purpose = 1; /* the closed connection isn't the session ending (monitor_event) */+ double t0 = rd_now();+ sd_mon_lost();+ sd_log("monitor: taken from %s in %.0f ms", user, (rd_now() - t0) * 1000);+ set_shown('-', NULL);+ show_greeter(mode, user);+}+/* Requests from the session being shown: lock, switch user, restart or shut down; from the login screen:* log in, restart or shut down. */static void from_shown(int type, const char *j) {@@ -759,9 +796,9 @@ static void from_shown(int type, const char *j) {sd_log("%s locked the screen", shown_user);struct passwd *lp = sd_valid_username(shown_user) ? getpwnam(shown_user) : NULL;if (lp) rd_tokens_drop_uid(lp->pw_uid); /* locking also signs that user's browsers out */- show_greeter("lock", shown_user);+ leave_for_greeter("lock");}- else if (strstr(j, "\"switch\"")) { sd_log("%s is switching user", shown_user); show_greeter("switch", shown_user); }+ else if (strstr(j, "\"switch\"")) { sd_log("%s is switching user", shown_user); leave_for_greeter("switch"); }return;}if (type != RP_GREETER || shown != 'g') return;@@ -782,7 +819,8 @@ static void from_shown(int type, const char *j) {}static void monitor_event(void) {- if (sd_mon_read(from_shown) == 0) return;+ left_on_purpose = 0;+ if (sd_mon_read(from_shown) == 0 || left_on_purpose) { left_on_purpose = 0; return; }/* the session being shown ended: it logged out, or the login screen crashed */char was = shown;sd_mon_lost();@@ -1281,6 +1319,10 @@ int main(int argc, char **argv) {if (r > 0 && lfd >= 0 && (p[1].revents & POLLIN)) accept_remote();if (r > 0 && p[2].fd >= 0 && p[2].fd == sd_mon_fd() && p[2].revents) monitor_event();if (r > 0 && p[3].fd >= 0 && (p[3].revents & POLLIN)) sd_mon_hotplug(); /* hotplug */+ if (greeter_stop_at && rd_now() >= greeter_stop_at) {+ greeter_stop_at = 0;+ if (shown == 'u' && worker_pid < 0 && pending == W_NONE) stop_greeters("a session is on the monitor");+ }if (rd_shared->lockout_dirty) save_lockout();deliver_notices();if (rd_shared->version != seen) { seen = rd_shared->version; write_status(); }diff --git a/tools/boot/plymouth/lordos/lordos.script b/tools/boot/plymouth/lordos/lordos.scriptindex 37bf2fa..3aebf29 100644--- a/tools/boot/plymouth/lordos/lordos.script+++ b/tools/boot/plymouth/lordos/lordos.script@@ -1,7 +1,9 @@# lordos.script: the LordOS boot splash (Plymouth "script" module).## The crown on a navy gradient with a soft violet glow, and a rounded progress bar that follows-# Plymouth's boot progress, smoothed so it never jumps or goes back. No text messages: Esc shows+# Plymouth's boot progress, smoothed so it never jumps or goes back. In the bottom right corner, the+# time since the splash started, in seconds and milliseconds (lord-sessiond logs the time from the+# kernel's start to the desktop's first frame; docs/RESULTS.md). No text messages: Esc shows# the text console as usual. The password field appears only when a disk asks for one (LUKS).# The images come from tools/boot/gen-boot-assets.py (1x, and @2x on 4K screens).# See docs/brand/README.md, "Boot splash".@@ -91,7 +93,36 @@ fun draw_bar() {}}+# ---- the boot timer, bottom right ----+timer = Sprite();+timer.SetOpacity(0);+boot_s = 0; # Plymouth's last duration (seconds since the splash started)+since_s = 0; # time since then, from the refresh calls (about 50 a second)+timer_shown = -1;++fun pad3(n) {+ if (n < 10) return "00" + n;+ if (n < 100) return "0" + n;+ return "" + n;+}++fun draw_timer() {+ if (!global.bar_visible) { timer.SetOpacity(0); return; }+ t = global.boot_s + global.since_s;+ ms = Math.Int(t * 1000);+ if (ms <= global.timer_shown) return; # never backwards when Plymouth's duration catches up+ global.timer_shown = ms;+ sec = Math.Int(ms / 1000);+ text = sec + "." + pad3(ms - sec * 1000) + " s";+ img_t = Image.Text(text, 0.80, 0.78, 0.95, 0.55, global.font_timer);+ timer.SetImage(img_t);+ timer.SetPosition(Window.GetX() + Window.GetWidth() - img_t.GetWidth() - 24 * global.scale,+ Window.GetY() + Window.GetHeight() - img_t.GetHeight() - 20 * global.scale, 20);+ timer.SetOpacity(1);+}+fun boot_progress(duration, progress) {+ if (duration > global.boot_s) { global.boot_s = duration; global.since_s = 0; }# Plymouth's progress is based on the previous boot's length; on a first boot (the live ISO, a# fresh card) it barely moves, so a time curve keeps the bar going: half at 8 s, two thirds at# 16 s, never past 95 % until Plymouth says so@@ -107,6 +138,8 @@ fun refresh() {if (global.shown > global.target) global.shown = global.target;}draw_bar();+ global.since_s = global.since_s + 0.02;+ draw_timer();}fun quit() {@@ -144,7 +177,8 @@ for (i = 0; i < max_bullets; i = i + 1) {# font names as literals (no number formatting in the script)font_small = "Sans 11";font_large = "Sans 12";-if (scale == 2) { font_small = "Sans 22"; font_large = "Sans 24"; }+font_timer = "Sans 10";+if (scale == 2) { font_small = "Sans 22"; font_large = "Sans 24"; font_timer = "Sans 20"; }fun set_prompt(text) {if (text == "") { prompt.SetOpacity(0); return; }