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.

Merge branch 'v082-video' (rebased onto 0.8.1) into v082-integration

Federico Pereiraae193054706a
diff --cc CHANGELOG.md
index 38dd8a9,7f6f0ba..3679892
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -12,27 -12,22 +12,43 @@@ of the matching [GitHub release](https:
### Added
+- **Monitor → Disks: each disk's temperature and health.** The Disks tab now shows every physical
+ disk's live temperature, read from the kernel without root: NVMe and M.2 drives through the nvme
+ driver's own sensor (also on a Raspberry Pi 5 with an M.2 HAT), SATA disks through the `drivetemp`
+ module, which the `lordos` package now loads at boot. Memory cards, virtual disks and adapters
+ without a sensor say "No sensor", never a made-up value. The chosen disk gets a 30-minute
+ temperature chart with the drive's own limits when it reports them, and an OK / Check / Failing
+ light from a cached SMART summary, with "Open in Disks". Spinning disks are only read while they
+ are in use, so a resting disk is never woken up
+ ([docs/MONITOR.md](docs/MONITOR.md#disk-temperature-and-health-082)).
+- **Disks: the full SMART report with smartmontools.** The first time, the health card offers to
+ install Debian's smartmontools through the Store's package engine (an administrator). Then it
+ shows the overall health and why in plain words, temperature and limits, SSD wear (% of its rated
+ life used), power-on hours and cycles, reallocated and pending sectors, every attribute with a plain
+ name, the NVMe health log, the error log, the disk's own temperature history, and short and long
+ self-tests with progress and results. USB disks behind adapters that pass SMART through work too.
+ `smartctl` runs only through four new closed, validated root helper actions (`smart-info`,
+ `smart-health`, `smart-test`, `smart-abort`) on real whole disks, at a fixed path, with JSON output
+ ([docs/SYSTEM.md](docs/SYSTEM.md#smart-with-smartmontools-082)).
+- **Notifications when a disk gets too hot or its health gets worse**, at most once per disk every
+ 30 minutes for heat, and only when the health is worse than last seen. On by default, with a switch
+ in Monitor → Disks.
+ - **Smooth video in the browser without hardware decoding.** Video sites that send VP9 or AV1
+ make the browser decode them on the processor when the graphics card can't (virtual machines,
+ older PCs, the Raspberry Pi 5), and the video stutters. LordOS now checks at every boot what the
+ hardware decodes (VA-API profiles through `lord-media`, V4L2 memory-to-memory decoders on ARM,
+ virtual graphics cards count as "no"; cached per boot) and, when VP9 or AV1 is missing, asks the
+ browsers for H.264 instead, which is far lighter to decode. Settings → Displays → Video in the
+ browser: "Optimize video for this computer" (Automatic by default, Always, Never) and "Lower
+ quality automatically when video stutters" (off by default). Nothing is sent anywhere
+ ([docs/VIDEO.md](docs/VIDEO.md)).
+ - **Our own small browser extension** (`/usr/share/chromium/extensions/lordos-video`, MIT), loaded
+ by Debian's Chromium: on YouTube it reports VP9/AV1 as unsupported so the site sends H.264, and
+ when a video keeps dropping frames it shows a small notice that offers a lower quality (or lowers
+ it by itself, if enabled). Its settings come from a managed policy written by the closed admin
+ action `video-optimize` (fixed text, no user text). Firefox ESR only loads signed extensions, so
+ for now it gets AV1 turned off through a default preference (it then uses VP9); the extension
+ for Firefox waits for signing.
## [Unreleased]
diff --cc docs/SETTINGS.md
index 4c1d8e4,012b30b..bdd92bf
--- a/docs/SETTINGS.md
+++ b/docs/SETTINGS.md
@@@ -44,7 -44,7 +44,8 @@@ the time fields keep `direction: 'ltr'`
│
▼ root work: closed admin actions (hw/hw_admin.c)
admin.c ─ display-brightness, power-profile, power-suspend, power-buttons, time-ntp, time-set,
- bt-unblock, rpi-case, hw-firmware-missing (the Store's suggestions, read-only)
- bt-unblock, rpi-case, video-optimize
++ bt-unblock, rpi-case, video-optimize, hw-firmware-missing (the Store's suggestions,
++ read-only)
Cooling: lord.fan (ui/js_fan.c) ── /run/lordos/fand.sock ── lord-fand (root service, src/fan)
```
@@@ -126,6 -131,6 +127,10 @@@ timer that sleeps until the next chang
for Computers algorithm (`night_sun_times`, within ±4 min of NOAA in the tests) at the
coordinates of the **chosen time zone** in `/usr/share/zoneinfo/zone1970.tab`. The location is
never looked up on the network.
++- **Video in the browser.** "Optimize video for this computer" (Automatic, Always, Never) and
++ "Lower quality automatically when video stutters": when the hardware can't decode VP9 or AV1,
++ the browsers are asked for H.264 (`Video.jsx`, `sdk/video.js`, the closed admin action
++ `video-optimize`). See [VIDEO.md](VIDEO.md).
- **Multiple displays** (`DISPLAYS.md`): extend or mirror, the arrangement edited by dragging the
displays (they snap next to each other), "Show menu bar on all displays", and what screenshots,
recording and the remote desktop see (main display or all). Each display has its own CRTC,
diff --cc sdk/index.js
index c450f0c,da17311..77ddb39
--- a/sdk/index.js
+++ b/sdk/index.js
@@@ -177,7 -174,7 +179,8 @@@ export function startShell(element)
startReminders(); // calendar and reminder alarms, with the apps closed
maybeStartTour(); // "Welcome to LordOS", the first time
startHardware(); // Night Light, idle timers, battery in the menu bar (hardware.jsx)
+ startDiskWatch(); // notices when a disk gets too hot or its health gets worse
+ startVideo(); // browser video without hardware decoding (video.js, docs/VIDEO.md)
}
// Changing the language remounts the whole interface (windows, tabs and
diff --cc server/Makefile
index 1c810cc,b172b48..02ed672
--- a/server/Makefile
+++ b/server/Makefile
@@@ -48,9 -48,9 +48,9 @@@ QJS_OBJ := $(patsubst %,build/qjs/%.o,q
# .lpk app isolation, permissions and signing (src/sec, see docs/PRIVACY.md and docs/SIGNING.md)
# Monitor: metrics, connections and the country of an IP (src/monitor, see docs/MONITOR.md)
-MON_SRC := src/monitor/mon.c src/monitor/conn.c src/monitor/procctl.c src/monitor/proc_admin.c src/monitor/mmdb.c src/monitor/map.c src/ui/js_monitor.c
+MON_SRC := src/monitor/mon.c src/monitor/disktemp.c src/monitor/conn.c src/monitor/procctl.c src/monitor/proc_admin.c src/monitor/mmdb.c src/monitor/map.c src/ui/js_monitor.c
# Media (src/media, docs/MEDIA.md): only the lord-server side. Only lord-media links FFmpeg.
- MEDIA_SRC := src/media/media.c src/media/mview.c src/media/capture.c src/media/annot.c src/media/maudio.c src/media/mpulse.c src/media/proto.c src/ui/js_media.c
+ MEDIA_SRC := src/media/media.c src/media/hwdec.c src/media/mview.c src/media/capture.c src/media/annot.c src/media/maudio.c src/media/mpulse.c src/media/proto.c src/ui/js_media.c
SEC_SRC := src/sec/json.c src/sec/sign.c src/sec/pkgstate.c src/sec/perms.c src/sec/cgroup.c src/sec/sandbox.c src/sec/brokersrv.c src/sec/brokercam.c src/sec/brokerkr.c src/sec/restrict.c src/sec/appid.c src/sec/pwguard.c
# App mode: lord-server --app <id> runs an .lpk app as an isolated Wayland client (src/app)
APP_SRC := src/app/appclient.c src/app/appspawn.c src/ui/js_broker.c src/ui/js_brokercam.c
diff --cc server/src/hw/hw_admin.c
index 2dfa5af,466a7f9..6bbbfd4
--- a/server/src/hw/hw_admin.c
+++ b/server/src/hw/hw_admin.c
@@@ -260,22 -259,72 +260,92 @@@ void hw_act_rpi_case(const AdminReq *r
admin_ok("hw.caseSet", "case", id, NULL);
}
+/* ---- missing firmware (the Store's suggestions, hwscan.c) ---- */
+
+/* Read-only: the session can't read the kernel log when kernel.dmesg_restrict=1. Takes no
+ * argument and returns only firmware file names that pass hwscan_fw_name_valid() and the driver
+ * name parsed from the same line (letters, digits, '_' and '-'), never other log text. */
+void hw_act_firmware_missing(const AdminReq *r, const char *arg, size_t len) {
+ (void)r; (void)arg;
+ if (len) { admin_err("admin.invalidArgument", NULL); return; }
+ size_t n;
+ int denied;
+ char *log = hwscan_read_kmsg("", &n, &denied);
+ if (!log) { admin_err("hw.noKernelLog", NULL); return; }
+ HwFwMiss m[HWSCAN_FW_MAX];
+ int k = hwscan_fw_missing("", log, n, m, HWSCAN_FW_MAX);
+ free(log);
+ for (int i = 0; i < k; i++)
+ admin_say("LOG", "fw %s %s", m[i].file, m[i].driver[0] ? m[i].driver : "-"); /* i18n-ok: protocol line parsed by sdk/suggestengine.js */
+ admin_ok("hw.firmwareChecked", NULL);
+}
++
+ /* ---- video in the browser (docs/VIDEO.md) ---- */
+
+ int hw_video_files(const char *arg, char *chromium, size_t cn, char *firefox, size_t fn) {
+ char a[64], mode[16], lower[8], vp9[8], av1[8], extra[2];
+ if (!arg || strlen(arg) >= sizeof a) return -1;
+ snprintf(a, sizeof a, "%s", arg);
+ a[strcspn(a, "\n")] = 0;
+ if (sscanf(a, "%15s %7s %7s %7s %1s", mode, lower, vp9, av1, extra) != 4) return -1;
+ if (strcmp(mode, "auto") && strcmp(mode, "always") && strcmp(mode, "never")) return -1;
+ if (strcmp(lower, "on") && strcmp(lower, "off")) return -1;
+ if ((strcmp(vp9, "yes") && strcmp(vp9, "no")) || (strcmp(av1, "yes") && strcmp(av1, "no"))) return -1;
+ int hw_vp9 = !strcmp(vp9, "yes"), hw_av1 = !strcmp(av1, "yes");
+ /* Chromium: the extension's managed storage ("3rdparty" policy); the extension decides */
+ snprintf(chromium, cn,
+ "{\n \"3rdparty\": {\n \"extensions\": {\n \"%s\": {\n"
+ " \"mode\": \"%s\",\n \"autoLower\": %s,\n \"hwVp9\": %s,\n \"hwAv1\": %s\n"
+ " }\n }\n }\n}\n",
+ HW_VIDEO_EXT_ID, mode, !strcmp(lower, "on") ? "true" : "false", hw_vp9 ? "true" : "false", hw_av1 ? "true" : "false");
+ /* Firefox ESR (no extension: it only loads signed ones): AV1 can be turned off on its own; VP9
+ * has no such switch without turning off all of WebM, so it stays */
+ int no_av1 = !strcmp(mode, "always") || (!strcmp(mode, "auto") && !hw_av1);
+ snprintf(firefox, fn,
+ "// Written by LordOS (Settings → Displays → Video in the browser). Changes here are overwritten.\n"
+ "// See docs/VIDEO.md.\n%s",
+ no_av1 ? "pref(\"media.av1.enabled\", false);\n" : "");
+ return 0;
+ }
+
+ /* Writes text to path through a temporary file and rename (nothing if it is already there). */
+ static int write_atomic(const char *path, const char *text) {
+ char cur[2048];
+ int fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
+ if (fd >= 0) {
+ ssize_t n = read(fd, cur, sizeof cur - 1);
+ close(fd);
+ if (n >= 0) { cur[n] = 0; if (!strcmp(cur, text)) return 0; }
+ }
+ char tmp[PATH_MAX];
+ snprintf(tmp, sizeof tmp, "%s.lordos-tmp", path);
+ fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0644);
+ if (fd < 0) return -1;
+ int ok = write(fd, text, strlen(text)) == (ssize_t)strlen(text);
+ ok = fsync(fd) == 0 && ok;
+ fchmod(fd, 0644);
+ close(fd);
+ if (!ok || rename(tmp, path)) { unlink(tmp); return -1; }
+ return 0;
+ }
+
+ void hw_act_video(const AdminReq *r, const char *arg, size_t len) {
+ (void)r;
+ char a[64], chromium[1024], firefox[512];
+ if (arg_copy(arg, len, a, sizeof a) || hw_video_files(a, chromium, sizeof chromium, firefox, sizeof firefox)) {
+ admin_err("admin.invalidArgument", NULL);
+ return;
+ }
+ const char *cp = "/etc/chromium/policies/managed/lordos-video.json";
+ mkdir("/etc/chromium", 0755);
+ mkdir("/etc/chromium/policies", 0755);
+ mkdir("/etc/chromium/policies/managed", 0755);
+ if (write_atomic(cp, chromium)) { admin_err("sys.writeFailed", "path", cp, NULL); return; }
+ struct stat st;
+ const char *fp = "/etc/firefox-esr/lordos-video.js";
+ if (stat("/etc/firefox-esr", &st) == 0 && S_ISDIR(st.st_mode) && write_atomic(fp, firefox)) {
+ admin_err("sys.writeFailed", "path", fp, NULL);
+ return;
+ }
+ admin_say("OK", "%s", a); /* i18n-ok */
+ }
diff --cc server/src/hw/hw_admin.h
index c9af648,4023906..75bbcfd
--- a/server/src/hw/hw_admin.h
+++ b/server/src/hw/hw_admin.h
@@@ -13,10 -13,11 +13,15 @@@
* rpi-case none|argon-one-v5 Raspberry Pi 5 only: writes /boot/firmware/lordos-case.txt
* (fixed text, included from config.txt; takes effect
* after a restart) admin
+ * hw-firmware-missing (no arguments) reads the kernel log (/dev/kmsg) and returns
+ * only the validated names of firmware files a driver asked
+ * for and that are still missing, as "LOG fw <file> <driver>"
+ * lines (the Store's suggestions, hwscan.c); read-only anyone
+ * video-optimize <mode> <lower> <vp9> <av1> auto|always|never, on|off, yes|no, yes|no (the
+ * last two: hardware VP9/AV1 decoding found this boot).
+ * Writes the browsers' video settings from fixed text:
+ * /etc/chromium/policies/managed/lordos-video.json and
+ * /etc/firefox-esr/lordos-video.js (docs/VIDEO.md) anyone
*/
#ifndef LORD_HW_ADMIN_H
#define LORD_HW_ADMIN_H
@@@ -31,8 -32,11 +36,12 @@@ void hw_act_ntp(const AdminReq *r, cons
void hw_act_time_set(const AdminReq *r, const char *arg, size_t len);
void hw_act_bt_unblock(const AdminReq *r, const char *arg, size_t len);
void hw_act_rpi_case(const AdminReq *r, const char *arg, size_t len);
+void hw_act_firmware_missing(const AdminReq *r, const char *arg, size_t len);
const char *hw_rpi_case_text(const char *id); /* fixed file text of a known case, NULL otherwise */
+ void hw_act_video(const AdminReq *r, const char *arg, size_t len);
+ /* The two files video-optimize writes, from its argument; 0 if the argument is valid. */
+ int hw_video_files(const char *arg, char *chromium, size_t cn, char *firefox, size_t fn);
+ #define HW_VIDEO_EXT_ID "kadhcpnkalbaminbojfmbmlgoheicmjo" /* assets/browser/video (manifest "key") */
/* Validators, exposed for tests. */
int hw_button_action_valid(const char *a, int lid);
@@@ -48,6 -52,6 +57,7 @@@ int hw_backlight_name_valid(const char
{ "time-set", hw_act_time_set, 0 }, \
{ "bt-unblock", hw_act_bt_unblock, A_ANYONE }, \
{ "rpi-case", hw_act_rpi_case, 0 }, \
- { "hw-firmware-missing", hw_act_firmware_missing, A_ANYONE },
++ { "hw-firmware-missing", hw_act_firmware_missing, A_ANYONE }, \
+ { "video-optimize", hw_act_video, A_ANYONE },
#endif
diff --cc tools/iso/mkdeb.sh
index 8c6be9e,0ffdf61..2368ac8
--- a/tools/iso/mkdeb.sh
+++ b/tools/iso/mkdeb.sh
@@@ -26,7 -24,10 +26,11 @@@
# /usr/share/keyrings/lordos-archive-keyring.gpg the key that signs that repository
# /usr/lib/lordos/migrate, migrations/ version-to-version system migrations, run by postinst
# /etc/kernel/postinst.d/zz-lordos-reboot-required "restart required" after a kernel update
+# /usr/lib/modules-load.d/lordos-drivetemp.conf SATA disk temperatures (drivetemp) at boot
+ # /usr/share/chromium/extensions/lordos-video/ LordOS's own browser extension for smooth video without
+ # hardware decoding (Debian's chromium loads every folder there;
+ # docs/VIDEO.md). Its settings are written at login by the
+ # admin action video-optimize, not shipped (postrm removes them)
set -eu
OUT=${1:?uso: mkdeb.sh salida.deb}
ROOT=$(pwd)