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
Automatic default apps: with no user choice, launchWith('') opens a file with the system's default (mimeapps.list/defaults.list, then Added Associations) or the first installed app that declares its type (mimeinfo.cache order, then desktop id), only .desktop files the launcher lists in its two folders with an Exec that takes a file; apps_default_for in apps.c, lord.mime.resolve/unset, Settings -> Default Apps shows "Automatic (<app>)" and can go back to it, Files' default uses the same order; defaults-test over a fake XDG tree; SETTINGS, PAPER-VALIDATION, CHANGELOG, paper (en/es/pt)
Federico Pereira251b71da212f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 798a0bc..d3b2880 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -275,6 +275,36 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),371. With the build's defaults then (the pipeline while frames are heavy, GPU drag on): under load render13.85/19.07, GPU 15.63/23.38, `heldMs` 18.27/31.60, 148 on time, 1 CPU-late, 285 GPU-late of 436. So under load theframe is late on the GPU's side: its time per frame goes from about 1.5 ms alone to 14–16 ms.+- **Automatic default apps** (in development for 0.8.6; `docs/SETTINGS.md`, "Default Apps"): when you never chose+ an app for a file type, a file of that type still opens. Before, `lord.apps.launchWith('', path)` only read the+ `[Default Applications]` lines of the mimeapps.list files and, on a fresh account with none, nothing opened (Files+ opened an `.html` in the Text Editor, and anything that asks for "the default app" got nothing). Now+ `apps_default_for()` (`server/src/apps.c`) follows the freedesktop MIME Applications order: the user's own+ `[Default Applications]` (an explicit choice), then what the system marks as default (`/etc/xdg/mimeapps.list`,+ `/usr/local/share/applications/mimeapps.list`, `/usr/share/applications/mimeapps.list`, `defaults.list`), skipping+ entries that aren't installed, then `[Added Associations]`, then the first installed app whose `MimeType` declares+ the type, in `mimeinfo.cache` order and then by desktop id (deterministic); `[Removed Associations]` are honoured,+ MIME subclasses and aliases are not followed. Only apps the launcher itself runs count: a `.desktop` in+ `/usr/share/applications` or `~/.local/share/applications` that it lists (not Hidden, NoDisplay or Terminal,+ TryExec found, OnlyShowIn/NotShowIn) with a `MimeType` and an `Exec` that takes a file (`%f %F %u %U`) and names a+ program that exists. No path, argument or way to write `.desktop` files was added; the file still goes through+ `launchWith`'s checks (a real path in the home or the user's mounts, one argument, no shell).+ `lord.mime.resolve(mime)` returns `{ id, explicit, source }` and `lord.mime.unset(mime)` goes back to automatic+ (removes the user's line from `[Default Applications]` and `[Added Associations]` of `~/.config/mimeapps.list`,+ every other line kept, as GLib's reset does). **Settings → Default Apps** shows a category you never chose as+ "Automatic (<app>)" ("Automática (…)", "Automático (…)"): the system's default, else LordOS's own app for it, else+ the first installed app that declares the type; an explicit choice can go back with "Automatic". Files' default+ (`defaultOpenerId`) uses the same order, so on a fresh account an `.html` file opens in the installed browser.+ Tests: `build/defaults-test` (38 checks, in `make -C server test`) over a fake XDG tree: the user's choice wins+ (also `lordos-<app>.desktop`, left to the theme), the system's lists in order with uninstalled entries skipped,+ the first declaring app by id and by `mimeinfo.cache` (the user's first), Hidden/NoDisplay/Terminal/OnlyShowIn/a+ missing TryExec/an Exec without a file code or with a missing program skipped, ids outside the launcher's folders+ ignored, `[Removed]` and `[Added Associations]`, going back to automatic, no app → nothing, and that+ `launchWith('')` really starts the chosen app with the file. Checked on VM 116 in an isolated headless session+ with a fresh home and no mimeapps.list (2026-10-29): Settings → Default Apps showed "Automatic (Chromium Web+ Browser)" for the web browser and "Automatic (Mail/Player/Photos/PDF Viewer/Text Editor)" for the rest;+ choosing Chromium wrote the four browser types, "Automatic" removed them again; double-clicking `page.html` in+ Files opened it in Chromium (the only installed app that declares `text/html` there).### Changeddiff --git a/apps/settings/DefaultApps.jsx b/apps/settings/DefaultApps.jsxindex ace0b89..96b0d2d 100644--- a/apps/settings/DefaultApps.jsx+++ b/apps/settings/DefaultApps.jsx@@ -2,10 +2,19 @@// LordOS's own apps and the installed Linux apps (.desktop with MimeType). Saved in// ~/.config/mimeapps.list (and ~/.config/xdg-terminals.list), so Files' "Open With", double// clicks, lord.apps.launchWith and Linux apps (xdg-open) agree. See docs/SETTINGS.md.-import { View, Text, useTheme, useLocale, useLauncherApps, DEFAULT_CATEGORIES, defaultFor, setDefaultFor, candidatesFor } from '@lordos/sdk';+import { View, Text, useTheme, useLocale, useLauncherApps, DEFAULT_CATEGORIES, defaultInfo, setDefaultFor, resetDefaultFor, candidatesFor } from '@lordos/sdk';import { useState } from 'react';import { GroupBox, SettingRow, PopUp, Note, Stack, Badge } from './ui.jsx';+// The name of a default app's desktop id: from the category's candidates, else the installed Linux+// apps, else the id itself.+function nameOf(desktopId, list, apps) {+ const c = list.find((a) => a.id === desktopId);+ if (c) return c.name;+ const a = apps.find((x) => x.kind === 'linux' && `${x.desktopId}.desktop` === desktopId);+ return a ? a.name : desktopId.replace(/\.desktop$/, '');+}+const LOOK = {browser: ['◎', '#0a84ff'], mail: ['✉', '#30a0ff'], music: ['♪', '#ff375f'], video: ['▶', '#bf5af2'], images: ['▣', '#ff9f0a'],pdf: ['⎙', '#ff453a'], text: ['✎', '#8e8e93'], terminal: ['>_', '#2c2c2e'],@@ -21,15 +30,26 @@ export function DefaultAppsSettings() {<GroupBox footer={tr('prefs.defaults.footer')}>{DEFAULT_CATEGORIES.map((c) => {const list = candidatesFor(c.id, apps);- const cur = defaultFor(c.id);+ const info = defaultInfo(c.id);const opts = list.map((a) => [a.id, a.name, a.Icon]);+ // the user chose nothing: the app that opens these files now, as "Automatic (name)"; an+ // explicit choice can go back to it (the user's lines leave mimeapps.list)+ const cur = info && !info.auto ? info.id : '';if (cur && !opts.some(([id]) => id === cur)) opts.push([cur, tr('prefs.defaults.other', { id: cur.replace(/\.desktop$/, '') })]);+ let first = ['', tr('prefs.defaults.choose')];+ if (info && info.auto) first = ['', tr('prefs.defaults.automatic', { name: nameOf(info.id, list, apps) })];+ else if (cur && !c.terminal) first = ['', tr('prefs.defaults.automaticPlain')];+ const options = cur && c.terminal ? opts : [first, ...opts];const [glyph, color] = LOOK[c.id];return (<SettingRow key={`${c.id}${rev}`} icon={<Badge glyph={glyph} color={color} />} label={tr(`prefs.defaults.cat.${c.id}`)}- hint={list.length ? '' : tr('prefs.defaults.none')}>- {opts.length ? <PopUp width={230} value={cur || ''} options={cur ? opts : [['', tr('prefs.defaults.choose')], ...opts]}- onChange={(id) => { if (id && !setDefaultFor(c.id, id)) setErr(tr('prefs.defaults.failed')); else setErr(''); setRev((r) => r + 1); }} /> : null}+ hint={list.length || info ? '' : tr('prefs.defaults.none')}>+ {opts.length || info ? <PopUp width={230} value={cur} options={options}+ onChange={(id) => {+ const ok = id ? setDefaultFor(c.id, id) : !cur || resetDefaultFor(c.id);+ setErr(ok ? '' : tr('prefs.defaults.failed'));+ setRev((r) => r + 1);+ }} /> : null}</SettingRow>);})}diff --git a/assets/locales/en/prefs.json b/assets/locales/en/prefs.jsonindex ceee1a5..b238096 100644--- a/assets/locales/en/prefs.json+++ b/assets/locales/en/prefs.json@@ -54,6 +54,8 @@"bt.unblock": "Turn On","bt.visibleAs": "Now discoverable as “{name}”.","bt.working": "Connecting…",+ "defaults.automatic": "Automatic ({name})",+ "defaults.automaticPlain": "Automatic","defaults.cat.browser": "Web browser","defaults.cat.images": "Images","defaults.cat.mail": "Email",diff --git a/assets/locales/es/prefs.json b/assets/locales/es/prefs.jsonindex 9f86173..eb5e293 100644--- a/assets/locales/es/prefs.json+++ b/assets/locales/es/prefs.json@@ -54,6 +54,8 @@"bt.unblock": "Activar","bt.visibleAs": "Visible como «{name}».","bt.working": "Conectando…",+ "defaults.automatic": "Automática ({name})",+ "defaults.automaticPlain": "Automática","defaults.cat.browser": "Navegador web","defaults.cat.images": "Imágenes","defaults.cat.mail": "Correo",diff --git a/assets/locales/pt/prefs.json b/assets/locales/pt/prefs.jsonindex 81f5cd1..3953a8f 100644--- a/assets/locales/pt/prefs.json+++ b/assets/locales/pt/prefs.json@@ -54,6 +54,8 @@"bt.unblock": "Ativar","bt.visibleAs": "Visível como “{name}”.","bt.working": "Conectando…",+ "defaults.automatic": "Automático ({name})",+ "defaults.automaticPlain": "Automático","defaults.cat.browser": "Navegador","defaults.cat.images": "Imagens","defaults.cat.mail": "E-mail",diff --git a/docs/PAPER-VALIDATION.md b/docs/PAPER-VALIDATION.mdindex 02539ca..97b08e4 100644--- a/docs/PAPER-VALIDATION.md+++ b/docs/PAPER-VALIDATION.md@@ -28,6 +28,7 @@ memory from a process's RSS (§7.1) and points to versioned results (§11.5, `do| 2.2 | `lord-server` runs as the user | Check `serverUser` (configured) | Holds || 2.4 | `lord-netd` only takes `net-*` actions from uid 0 peers | Design; `net-test` covers the actions | Partly tested || 2.4 | `lord-fand` writes only fans its scan found and restores them on stop or crash | Test (`fan-test`, fake sysfs); Measured on the Pi 5 (§7.4) | Holds |+| 2.4 | (0.8.6, in development) With no default chosen, a file opens with the system's default or the first installed app that declares its type, shown as "Automatic" | Test (`defaults-test`, fake XDG tree); checked once in an isolated session on VM 116 (2026-10-29) | Holds || 2.4 | Display changes revert after 15 s without confirmation | Manual | Not automated || 3.6 | Passwords are checked by the root process, not the login screen | Design; `remote-sec-test` covers the parsers | Design |diff --git a/docs/SETTINGS.md b/docs/SETTINGS.mdindex 89efdf0..2b2579b 100644--- a/docs/SETTINGS.md+++ b/docs/SETTINGS.md@@ -343,10 +343,52 @@ and the Linux apps whose `.desktop` `MimeType` covers the category (terminals: ``/usr/local/share/applications`, `/usr/share/applications`, `defaults.list`), with the user's`[Removed Associations]` applied. File types come from shared-mime-info's `globs2` (highestweight, longest pattern, case-sensitive patterns first).+- **Automatic default (0.8.6, in development).** When the user never chose an app for a type,+ `apps_default_for()` (`server/src/apps.c`) still finds one, using only apps the launcher itself+ would run (a `.desktop` in `/usr/share/applications` or `~/.local/share/applications` that+ `apps_list` lists: not `Hidden`/`NoDisplay`/`Terminal`, `TryExec` found, `OnlyShowIn`/`NotShowIn`+ honoured, a `MimeType`, and an `Exec` with `%f`/`%F`/`%u`/`%U` naming a program that exists).+ The order:+ 1. `[Default Applications]` of the files above, file by file and entry by entry, skipping entries+ that are not installed: the user's own files first (an *explicit* choice; there a+ `lordos-<app>.desktop` counts too, and the theme opens it), then what the system marks as+ default (`/etc/xdg/mimeapps.list`, `/usr/local/share/applications/mimeapps.list`,+ `/usr/share/applications/mimeapps.list`, `defaults.list`);+ 2. their `[Added Associations]`, in the same file order;+ 3. the installed apps whose `MimeType` declares the type, in `mimeinfo.cache` order+ (`~/.local/share/applications`, then `/usr/share/applications`), then the rest sorted by+ desktop id (strcmp), so the choice is the same on every run.++ `[Removed Associations]` of a file apply to it and to every file after it (and to steps 2–3).+ No MIME subclasses or aliases are followed (`text/html` does not match an app that only lists+ `application/xhtml+xml`). No app → nothing opens, as before. No path or argument was added:+ the folders are the launcher's, the file still goes through `launchWith`'s checks.+- **The JS side.** `lord.mime.resolve(mime)` returns `{ id, explicit, source }` (`source`:+ `user`, `system` for a system default or added association, `declared` for the first app that+ declares the type) or `null`; `lord.mime.unset(mime)` removes the user's line for that type+ from `[Default Applications]` and `[Added Associations]` of `~/.config/mimeapps.list` (as+ GLib's reset does; `[Removed Associations]` and every other line are kept). `lord.mime.get`+ still returns the first `[Default Applications]` entry without checking it is installed.+- **What Settings shows.** A category the user never chose shows **Automatic (<app>)**: the+ system's default if there is one, else LordOS's own app for the category (Photos, Player, PDF+ Viewer, Text Editor, Mail), else the first installed app that declares the type (the web+ browser on a fresh account). Choosing an app writes it as before; an explicit choice can go+ back with **Automatic**, which calls `lord.mime.unset` for every type of the category. The+ terminal is unchanged (`~/.config/xdg-terminals.list`).- **Files** lists the default app first in "Open With", marked "(default)", and double-click opens- it. **`lord.apps.launchWith('', path)`** opens a file with the default Linux app for its type- (the same rules as `launchWith`: a real path in the home or `/media/$USER`, one argument, no- shell); it returns false when the default is a LordOS app, which the theme opens itself.+ it (`defaultOpenerId`: the user's choice or the system's default if installed, else the+ category's LordOS app, else the first declaring app; on a fresh account an `.html` file now+ opens in the installed browser instead of the Text Editor). **`lord.apps.launchWith('', path)`**+ opens a file with the default Linux app for its type, the automatic one included (the same+ rules as `launchWith`: a real path in the home or `/media/$USER`, one argument, no shell); it+ returns false when the default is a LordOS app, which the theme opens itself, or when no+ installed app opens the type.+- Tests: `build/defaults-test` (`tests/defaults_test.c`, in `make -C server test`) builds a fake+ XDG tree (`defaults_set_root`, tests only) and checks the user's choice, the system lists and+ their order, the first declaring app (by id and by `mimeinfo.cache`), the skipped apps+ (Hidden, NoDisplay, Terminal, OnlyShowIn, a missing TryExec, an Exec without a file code or with+ a missing program), ids outside the launcher's folders, `[Removed]`/`[Added Associations]`,+ going back to automatic, and that `launchWith('')` really opens the chosen app.diff --git a/sdk/defaults.js b/sdk/defaults.jsindex 0539791..aa99a65 100644--- a/sdk/defaults.js+++ b/sdk/defaults.js@@ -5,7 +5,9 @@//// DEFAULT_CATEGORIES [{ id, mimes, natives }]// defaultFor(categoryId) 'lordos-photos.desktop' | 'org.gnome.Loupe.desktop' | null+// defaultInfo(categoryId) { id, auto } for Settings: auto when the user chose nothing// setDefaultFor(categoryId, id) writes every MIME type of the category+// resetDefaultFor(categoryId) back to automatic (removes the user's lines)// candidatesFor(categoryId, linux) [{ id, name, Icon, native }] that can be chosen// defaultOpenerId(mime) the default for one type (Files: "Open With", double click)import { getApp } from './windows.js';@@ -37,6 +39,38 @@ export function defaultFor(id) {return c.natives.find((n) => getApp(n)) ? NATIVE(c.natives.find((n) => getApp(n))) : null;}+// lord.mime.resolve: { id, explicit, source: 'user'|'system'|'declared' } or null. The app+// launchWith('') opens a file of that type with: the user's choice, else the system's default+// (mimeapps.list/defaults.list), else the first installed app that declares the type.+const resolve = (mime) => (api() && lord.mime.resolve ? lord.mime.resolve(mime) : null);++// What Settings shows for a category: { id, auto } or null. auto: the user chose nothing, and this+// is what opens these files (the system's default, else LordOS's own app, else the first installed+// app that declares the type), so the order is the same as defaultOpenerId's.+export function defaultInfo(id) {+ const c = cat(id);+ if (!c || !api()) return null;+ if (c.terminal) return { id: defaultFor(id), auto: false };+ const rs = c.mimes.map(resolve);+ const mine = rs.find((r) => r && r.explicit);+ if (mine) return { id: mine.id, auto: false };+ const sys = rs.find((r) => r && r.source === 'system');+ if (sys) return { id: sys.id, auto: true };+ const native = c.natives.find((n) => getApp(n));+ if (native) return { id: NATIVE(native), auto: true };+ const first = rs.find(Boolean);+ return first ? { id: first.id, auto: true } : null;+}++// Back to automatic: the user's lines for the category's types leave ~/.config/mimeapps.list.+export function resetDefaultFor(id) {+ const c = cat(id);+ if (!c || c.terminal || !api() || !lord.mime.unset) return false;+ let ok = true;+ for (const m of c.mimes) ok = lord.mime.unset(m) && ok;+ return ok;+}+export function setDefaultFor(id, desktopId) {const c = cat(id);if (!c || !api() || !desktopId) return false;@@ -68,8 +102,11 @@ export function candidatesFor(id, linuxApps = []) {export function defaultOpenerId(mime) {if (!api() || !mime) return null;- const d = lord.mime.get(mime);- if (d) return d;+ // the user's choice or the system's default, if that app is installed+ const r = resolve(mime);+ if (r && r.source !== 'declared') return r.id;const c = DEFAULT_CATEGORIES.find((x) => x.mimes.includes(mime) || (x.mimes[0] && mime.startsWith(`${x.mimes[0].split('/')[0]}/`) && x.id !== 'browser' && x.id !== 'mail'));- return c ? defaultFor(c.id) : null;+ const d = c ? defaultFor(c.id) : null;+ // then the category's (LordOS's own app), then the first installed app that declares the type+ return d || (r ? r.id : null);}diff --git a/sdk/index.js b/sdk/index.jsindex d399656..22d058f 100644--- a/sdk/index.js+++ b/sdk/index.js@@ -127,7 +127,7 @@ import { DisplayIdentify } from './displaysui.jsx';export { displayNumbers, snapDisplay, resolveDrop, placementOk as displayPlacementOk, SNAP_PREVIEW_PX } from './displaylayout.js';// Fans and cooling (lord-fand, docs/FANS.md): Settings → Cooling and Monitor → Coolingexport { useFan, fanStatus, fanHistory, fanCase, fanControl, refreshFan, coolingVariant, heatColor, CoolingArt, FanCurveChart, formatTemp, FAN_HISTORY } from './cooling.jsx';-export { DEFAULT_CATEGORIES, defaultFor, setDefaultFor, candidatesFor, defaultOpenerId, nativeOf } from './defaults.js';+export { DEFAULT_CATEGORIES, defaultFor, defaultInfo, setDefaultFor, resetDefaultFor, candidatesFor, defaultOpenerId, nativeOf } from './defaults.js';export { notifyPrefs, appNotifyPrefs, setAppNotifyPrefs, dndActive, NOTIFY_DEFAULTS } from './notify.js';// ---- installed themes ----diff --git a/server/Makefile b/server/Makefileindex 83772ec..d1ebd16 100644--- a/server/Makefile+++ b/server/Makefile@@ -316,6 +316,13 @@ build/apps-actions-test: tests/apps_actions_test.c $(LAUNCH_CLI_SRC) src/apps.h@mkdir -p build$(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/apps_actions_test.c $(LAUNCH_CLI_SRC)./$@ || { rm -f $@; exit 1; }+# tests/defaults_test.c: the default app for a MIME type (user choice, system default, first+# declaring app) and launchWith('') over a fake XDG tree+test: build/defaults-test+build/defaults-test: tests/defaults_test.c $(LAUNCH_CLI_SRC) src/apps.h $(wildcard src/sec/*.h src/fw/*.h src/hw/*.h)+ @mkdir -p build+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/defaults_test.c $(LAUNCH_CLI_SRC)+ ./$@ || { rm -f $@; exit 1; }# tests/notifyd_cli.c: the real notification server on a private bus, for tests/fwlinux/notify.shNOTIFYD_CLI_SRC := src/hw/notifyd.c src/sec/appid.c src/hw/jbuf.c src/vault/dbus.c src/sec/restrict.c src/fw/rules.c src/fw/fwmap.c src/sec/json.ctest: build/notifyd-cli build/notifyd-testdiff --git a/server/mk/settings.mk b/server/mk/settings.mkindex 59287bd..083a3c1 100644--- a/server/mk/settings.mk+++ b/server/mk/settings.mk@@ -5,7 +5,7 @@ HW_SRC := src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/psrc/hw/uevent.c src/hw/sysbus.c src/hw/bt.c src/hw/ppd.c src/hw/hw.c src/hw/hw_admin.c src/bench/boottest.c src/hw/defaults.c src/hw/notifyd.c src/hw/hwscan.c src/hw/brframe.c src/ui/js_hw.c \src/sysreport/sysreport.c src/sysreport/sysreport_out.c src/sysreport/ids.c src/sysreport/smbios.c src/sysreport/facts.c src/hw/rpifw.c \src/ui/js_fan.c src/fan/fancurve.c-HW_HDR := $(wildcard src/hw/*.h) $(wildcard src/sysreport/*.h) $(wildcard src/fan/*.h) src/ui/js_hw.h src/ui/js_fan.h src/kms.h src/vault/dbus.h+HW_HDR := $(wildcard src/hw/*.h) src/apps.h $(wildcard src/sysreport/*.h) $(wildcard src/fan/*.h) src/ui/js_hw.h src/ui/js_fan.h src/kms.h src/vault/dbus.hHW_OBJ := $(HW_SRC:src/%.c=build/obj/%.o)$(HW_OBJ): $(HW_HDR)build/lord-server: $(HW_OBJ)diff --git a/server/src/apps.c b/server/src/apps.cindex 99ba5e2..274731f 100644--- a/server/src/apps.c+++ b/server/src/apps.c@@ -20,6 +20,7 @@* folder it was opened with. A restriction set while the app runs applies at its next launch. */#include "apps.h"#include "hw/defaults.h"+#include "hw/mimeapps.h"#include "fsops.h"#include "sec/cgroup.h"#include "sec/restrict.h"@@ -304,10 +305,10 @@ static void find_icon(const char *name, char *out, size_t n) {* ("app-lordos-<id>.scope", cgroup_scope_name_ok: no '+', at most 62 characters, no "..") and* never one that reads as a .lpk package's scope ("lpk-...": that would be lpk:<rest>'s identity,* rules and restrictions). */-#define DESKTOP_ID_MAX 62+#define APP_ID_MAX 62static int valid_id(const char *id) {size_t n = strlen(id);- if (!n || n >= sizeof apps[0].id || n > DESKTOP_ID_MAX) return 0;+ if (!n || n >= sizeof apps[0].id || n > APP_ID_MAX) return 0;for (const char *p = id; *p; p++) if (!isalnum((unsigned char)*p) && !strchr("._-", *p)) return 0;return id[0] != '.' && id[0] != '-' && !strstr(id, "..") && strncmp(id, "lpk-", 4);}@@ -315,7 +316,7 @@ static int valid_id(const char *id) {static void app_dirs(char dirs[2][PATH_MAX]) {const char *home = getenv("HOME");snprintf(dirs[0], PATH_MAX, "%s/.local/share/applications", home ? home : "/nonexistent");- snprintf(dirs[1], PATH_MAX, "/usr/share/applications");+ snprintf(dirs[1], PATH_MAX, "%s/usr/share/applications", defaults_root()); /* root: "" outside tests */}static int cmp_name(const void *a, const void *b) {@@ -734,13 +735,99 @@ int apps_launch_with(const char *id, const char *path) {char real[PATH_MAX];struct stat st;if (!path || !realpath(path, real) || !fsops_allowed(real) || stat(real, &st) || !(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))) return -1;- /* id "" = the default app for the file's type (Settings → Default Apps, ~/.config/mimeapps.list);+ /* id "" = the default app for the file's type (apps_default_for: the user's choice in Settings →+ * Default Apps, else the system's default, else the first installed app that declares the type);* -1 if that is one of LordOS's own apps (the theme opens those) or there is none */- char def[160];- if (id && !id[0]) { if (defaults_app_for(real, def, sizeof def)) return -1; id = def; }+ char mime[MIME_MAX], def[DESKTOP_ID_MAX];+ if (id && !id[0]) {+ if (defaults_guess(real, mime, sizeof mime) || apps_default_for(mime, def, sizeof def) <= 0) return -1;+ if (!strncmp(def, "lordos-", 7)) return -1; /* one of ours: the theme opens it */+ def[strlen(def) - 8] = 0; /* without ".desktop" */+ id = def;+ }return launch(id, real, NULL);}+/* ---- the default app for a MIME type ---- */++/* Can the listed app with that desktop id ("x.desktop") open a file? The launcher's own rules: it+ * is listed (Type=Application, not Hidden/NoDisplay/terminal, TryExec found, OnlyShowIn/NotShowIn),+ * it declares MimeType (and this type when `declared`), and its Exec line takes a file (%f %F %u+ * %U) and names a program that exists. */+static int opens_files(const char *desktop_id, const char *mime, int declared) {+ size_t l = strlen(desktop_id);+ char id[160];+ if (!desktop_id_valid(desktop_id) || l - 8 >= sizeof id) return 0;+ memcpy(id, desktop_id, l - 8);+ id[l - 8] = 0;+ const DesktopApp *a = find_app(id);+ if (!a || !a->mime[0] || (declared && !list_has(a->mime, mime))) return 0;+ Entry *e = malloc(sizeof *e);+ char *buf = malloc(4096);+ char *argv[MAX_ARGS], prog[PATH_MAX];+ int used = 0;+ int ok = e && buf && !parse_desktop(a->file, cached_lang[0] ? cached_lang : "en", e) && e->is_app && !e->terminal &&+ !e->hidden && split_exec(e->exec, e, argv, buf, 4096, "/", &used) > 0 && used &&+ !find_program(argv[0], a->user, prog, sizeof prog);+ free(e);+ free(buf);+ return ok;+}++static int by_id(const void *a, const void *b) { return strcmp((const char *)a, (const char *)b); }++int apps_default_for(const char *mime, char *out, size_t n) {+ if (!mime_valid(mime) || n < DESKTOP_ID_MAX) return -1;+ DefaultsFiles f;+ defaults_load(&f);+ char id[DESKTOP_ID_MAX];+ int r = 0;+ /* 1. [Default Applications], file by file: the first entry that is installed (the user's own+ * files first; LordOS's own "lordos-<app>.desktop" counts only there, the theme opens it) */+ for (int i = 0; i < f.n && !r; i++)+ for (int k = 0; !r && mimeapps_entry(f.text[i], "Default Applications", mime, k, id, sizeof id) == 0; k++) {+ if (defaults_removed(&f, i, mime, id)) continue;+ if (f.user[i] && !strncmp(id, "lordos-", 7)) r = APPS_DEFAULT_USER;+ else if (opens_files(id, mime, 0)) r = f.user[i] ? APPS_DEFAULT_USER : APPS_DEFAULT_LISTED;+ }+ /* 2. [Added Associations], in the same file order */+ for (int i = 0; i < f.n && !r; i++)+ for (int k = 0; !r && mimeapps_entry(f.text[i], "Added Associations", mime, k, id, sizeof id) == 0; k++)+ if (!defaults_removed(&f, i, mime, id) && opens_files(id, mime, 0)) r = APPS_DEFAULT_LISTED;+ /* 3. the installed apps that declare the type: mimeinfo.cache order (the user's folder, then the+ * system's), then the rest sorted by desktop id */+ const char *dirs[2] = { NULL, NULL };+ char cache[2][PATH_MAX];+ const char *h = getenv("HOME");+ if (h && h[0] == '/') { snprintf(cache[0], PATH_MAX, "%s/.local/share/applications/mimeinfo.cache", h); dirs[0] = cache[0]; }+ snprintf(cache[1], PATH_MAX, "%s/usr/share/applications/mimeinfo.cache", defaults_root());+ dirs[1] = cache[1];+ for (int d = 0; d < 2 && !r; d++) {+ char *t = dirs[d] ? defaults_read(dirs[d]) : NULL;+ for (int k = 0; t && !r && mimeapps_entry(t, "MIME Cache", mime, k, id, sizeof id) == 0; k++)+ if (!defaults_removed(&f, f.n - 1, mime, id) && opens_files(id, mime, 1)) r = APPS_DEFAULT_DECLARED;+ free(t);+ }+ if (!r) {+ const DesktopApp *list;+ int na = apps_list(cached_lang[0] ? cached_lang : "en", &list);+ /* copies: opens_files() may reread the list and free this one */+ char (*ids)[sizeof list[0].id] = na > 0 ? malloc((size_t)na * sizeof *ids) : NULL;+ int m = 0;+ for (int i = 0; ids && i < na; i++) if (list_has(list[i].mime, mime)) memcpy(ids[m++], list[i].id, sizeof ids[0]);+ if (m) qsort(ids, (size_t)m, sizeof *ids, by_id);+ for (int i = 0; i < m && !r; i++) {+ snprintf(id, sizeof id, "%s.desktop", ids[i]);+ if (!defaults_removed(&f, f.n - 1, mime, id) && opens_files(id, mime, 1)) r = APPS_DEFAULT_DECLARED;+ }+ free(ids);+ }+ defaults_free(&f);+ if (!r) return 0;+ snprintf(out, n, "%s", id);+ return r;+}+/* action: the name of one of the entry's desktop actions (apps_launch_action), whose Exec line* replaces the main one; never together with a file. Everything else (the id, the listing filters,* the scope, the restrictions) is the same as a plain launch. */diff --git a/server/src/apps.h b/server/src/apps.hindex 3b9c9df..83a93b7 100644--- a/server/src/apps.h+++ b/server/src/apps.h@@ -3,6 +3,7 @@#define LORD_APPS_H#include <limits.h>+#include <stddef.h>typedef struct {char id[160]; /* "org.featherpad.FeatherPad" (.desktop name without the extension) */@@ -27,6 +28,21 @@ int apps_launch(const char *id);/* Same, but opening a file or folder (see apps.c: only apps with MimeType and paths in the* home folder or the user's mounts, as a single argument). */int apps_launch_with(const char *id, const char *path);+/* The app that opens files of a MIME type, as apps_launch_with(id = "") picks it: out gets its desktop+ * id ("firefox-esr.desktop", or the user's "lordos-<app>.desktop"). Order: [Default Applications] of+ * the mimeapps.list files (the user's first, then the system's: /etc/xdg,+ * /usr/local/share/applications, /usr/share/applications, then defaults.list), then their [Added+ * Associations], then the installed apps whose MimeType declares the type, in mimeinfo.cache order+ * (~/.local/share/applications, then /usr/share/applications) and then by desktop id. Only apps this+ * launcher lists and can open a file with count; [Removed Associations] are honoured.+ * Returns APPS_DEFAULT_USER (the user's own [Default Applications] choice: "explicit"),+ * APPS_DEFAULT_LISTED (a system default or an added association: "automatic") or+ * APPS_DEFAULT_DECLARED (the first installed app that declares the type: "automatic"), or 0 if no+ * app opens it; n must be at least 160 (DESKTOP_ID_MAX in hw/mimeapps.h). */+#define APPS_DEFAULT_USER 1+#define APPS_DEFAULT_LISTED 2+#define APPS_DEFAULT_DECLARED 3+int apps_default_for(const char *mime, char *out, size_t n);/* Desktop actions ("Actions=" + "[Desktop Action <name>]", e.g. a browser's "New Private Window"):* only those listed in Actions=, with a [A-Za-z0-9-] name, a Name and an Exec line. */#define APPS_MAX_ACTIONS 16diff --git a/server/src/hw/defaults.c b/server/src/hw/defaults.cindex 4feba26..87d965a 100644--- a/server/src/hw/defaults.c+++ b/server/src/hw/defaults.c@@ -37,29 +37,71 @@ static int write_atomic(const char *path, const char *text) {return 0;}-int defaults_lookup(const char *mime, char *id, size_t n) {- if (!mime_valid(mime)) return -1;- char paths[6][PATH_MAX];- int np = 0;+/* For tests only: a folder that stands for "/" when the system files are read (the fake XDG trees of+ * tests/defaults_test.c). Empty in lord-server: nothing else sets it. */+static char sysroot[256];+void defaults_set_root(const char *root) { snprintf(sysroot, sizeof sysroot, "%s", root && root[0] == '/' ? root : ""); }+const char *defaults_root(void) { return sysroot; }++char *defaults_read(const char *path) { return slurp(path); }++/* The mimeapps.list files in the specification's order ("MIME Applications Associations", "File+ * name and location"): the user's ($XDG_CONFIG_HOME, or ~/.config), the system configuration+ * (/etc/xdg), the user's data folder (~/.local/share/applications), then the system data folders+ * (/usr/local/share, /usr/share) and the deprecated /usr/share/applications/defaults.list. */+void defaults_load(DefaultsFiles *f) {+ memset(f, 0, sizeof *f);+ char paths[DEFAULTS_NFILES][PATH_MAX];+ int user[DEFAULTS_NFILES] = { 0 }, np = 0;const char *h = home(), *xdg = getenv("XDG_CONFIG_HOME");- if (xdg && xdg[0] == '/') snprintf(paths[np++], PATH_MAX, "%s/mimeapps.list", xdg);- else if (h) snprintf(paths[np++], PATH_MAX, "%s/.config/mimeapps.list", h);- snprintf(paths[np++], PATH_MAX, "/etc/xdg/mimeapps.list");- if (h) snprintf(paths[np++], PATH_MAX, "%s/.local/share/applications/mimeapps.list", h);- snprintf(paths[np++], PATH_MAX, "/usr/local/share/applications/mimeapps.list");- snprintf(paths[np++], PATH_MAX, "/usr/share/applications/mimeapps.list");- snprintf(paths[np++], PATH_MAX, "/usr/share/applications/defaults.list");- char *removed_in = NULL; /* the user's file: its Removed Associations apply below */+ if (xdg && xdg[0] == '/') { user[np] = 1; snprintf(paths[np++], PATH_MAX, "%s/mimeapps.list", xdg); }+ else if (h) { user[np] = 1; snprintf(paths[np++], PATH_MAX, "%s/.config/mimeapps.list", h); }+ snprintf(paths[np++], PATH_MAX, "%s/etc/xdg/mimeapps.list", sysroot);+ if (h) { user[np] = 1; snprintf(paths[np++], PATH_MAX, "%s/.local/share/applications/mimeapps.list", h); }+ snprintf(paths[np++], PATH_MAX, "%s/usr/local/share/applications/mimeapps.list", sysroot);+ snprintf(paths[np++], PATH_MAX, "%s/usr/share/applications/mimeapps.list", sysroot);+ snprintf(paths[np++], PATH_MAX, "%s/usr/share/applications/defaults.list", sysroot);for (int i = 0; i < np; i++) {- char *t = slurp(paths[i]);- if (!t) continue;- int found = mimeapps_default(t, mime, id, n) == 0 && !(removed_in && mimeapps_removed(removed_in, mime, id));- if (i == 0) removed_in = t;- else free(t);- if (found) { free(removed_in); return 0; }+ f->text[i] = slurp(paths[i]);+ f->user[i] = user[i];}- free(removed_in);- return -1;+ f->n = np;+}++void defaults_free(DefaultsFiles *f) {+ for (int i = 0; i < f->n; i++) free(f->text[i]);+ memset(f, 0, sizeof *f);+}++int defaults_removed(const DefaultsFiles *f, int upto, const char *mime, const char *id) {+ for (int i = 0; i <= upto && i < f->n; i++) if (mimeapps_removed(f->text[i], mime, id)) return 1;+ return 0;+}++int defaults_lookup(const char *mime, char *id, size_t n) {+ if (!mime_valid(mime)) return -1;+ DefaultsFiles f;+ defaults_load(&f);+ int r = -1;+ /* a file's Removed Associations apply to it and to the files after it */+ for (int i = 0; i < f.n && r; i++)+ if (mimeapps_default(f.text[i], mime, id, n) == 0 && !defaults_removed(&f, i, mime, id)) r = 0;+ defaults_free(&f);+ return r;+}++int defaults_unset(const char *mime) {+ const char *h = home();+ if (!h || !mime_valid(mime)) return -1;+ char path[PATH_MAX];+ snprintf(path, sizeof path, "%s/.config/mimeapps.list", h);+ char *old = slurp(path);+ if (!old) return 0; /* nothing chosen: already automatic */+ char *now = mimeapps_unset_default(old, mime);+ int r = !now ? -1 : !strcmp(now, old) ? 0 : write_atomic(path, now);+ free(old);+ free(now);+ return r;}int defaults_set(const char *mime, const char *id) {@@ -81,21 +123,15 @@ int defaults_set(const char *mime, const char *id) {int defaults_guess(const char *path, char *mime, size_t n) {static char *globs;static int tried;- if (!tried) { tried = 1; globs = slurp("/usr/share/mime/globs2"); }+ if (!tried) {+ char p[PATH_MAX];+ snprintf(p, sizeof p, "%s/usr/share/mime/globs2", sysroot);+ tried = 1;+ globs = slurp(p);+ }return globs ? mime_guess(globs, path, mime, n) : -1;}-int defaults_app_for(const char *path, char *id, size_t n) {- char mime[MIME_MAX], d[DESKTOP_ID_MAX];- if (defaults_guess(path, mime, sizeof mime) || defaults_lookup(mime, d, sizeof d)) return -1;- if (!strncmp(d, "lordos-", 7)) return -1; /* one of ours: the theme opens it */- size_t l = strlen(d) - 8; /* without ".desktop" */- if (l >= n) return -1;- memcpy(id, d, l);- id[l] = 0;- return 0;-}-int defaults_terminal(char *id, size_t n) {const char *h = home();if (!h) return -1;diff --git a/server/src/hw/defaults.h b/server/src/hw/defaults.hindex 0941c43..9952b54 100644--- a/server/src/hw/defaults.h+++ b/server/src/hw/defaults.h@@ -7,15 +7,31 @@#include <stddef.h>-/* Default app for a MIME type, following the spec's lookup order. 0 if found ("x.desktop"). */+/* The mimeapps.list files (and defaults.list) in the specification's order; text[i] is NULL when+ * that file is missing, user[i] says whether it is one of the user's own. */+#define DEFAULTS_NFILES 6+typedef struct { char *text[DEFAULTS_NFILES]; int user[DEFAULTS_NFILES]; int n; } DefaultsFiles;+void defaults_load(DefaultsFiles *f);+void defaults_free(DefaultsFiles *f);+/* Is id in [Removed Associations] for mime in any of the files 0..upto? */+int defaults_removed(const DefaultsFiles *f, int upto, const char *mime, const char *id);+/* A small text file (at most 256 KB, no symlink), malloc'd, or NULL. */+char *defaults_read(const char *path);++/* First [Default Applications] entry for a MIME type over those files, without checking that it is+ * installed (lord.mime.get). 0 if found ("x.desktop"). The full lookup, with installed apps and the+ * automatic choice, is apps_default_for() in apps.c. */int defaults_lookup(const char *mime, char *id, size_t n);/* Sets it in ~/.config/mimeapps.list (atomic write, other lines kept). 0 if written. */int defaults_set(const char *mime, const char *id);+/* Removes the user's choice for mime from ~/.config/mimeapps.list ([Default Applications] and+ * [Added Associations]; back to automatic). 0 if done or nothing was there. */+int defaults_unset(const char *mime);/* MIME type of a file name (globs2). 0 if known. */int defaults_guess(const char *path, char *mime, size_t n);-/* Linux app to open path with (its desktop id without ".desktop"): the default for its type,- * if that is a Linux app. 0 if there is one. */-int defaults_app_for(const char *path, char *id, size_t n);+/* Tests only: a folder read in place of "/" for the system files (fake XDG trees). */+void defaults_set_root(const char *root);+const char *defaults_root(void);/* Preferred terminal ("foot.desktop", "lordos-terminal.desktop"). */int defaults_terminal(char *id, size_t n);int defaults_set_terminal(const char *id);diff --git a/server/src/hw/mimeapps.c b/server/src/hw/mimeapps.cindex 2535e96..fb092d3 100644--- a/server/src/hw/mimeapps.c+++ b/server/src/hw/mimeapps.c@@ -85,9 +85,9 @@ static int find_value(const char *text, const char *grp, const char *mime, constreturn 0;}-int mimeapps_default(const char *text, const char *mime, char *out, size_t n) {+int mimeapps_entry(const char *text, const char *group, const char *mime, int idx, char *out, size_t n) {const char *v, *ve;- if (!text || !find_value(text, "Default Applications", mime, &v, &ve)) return -1;+ if (!text || !group || idx < 0 || !find_value(text, group, mime, &v, &ve)) return -1;for (const char *p = v; p < ve;) {const char *s = memchr(p, ';', (size_t)(ve - p));if (!s) s = ve;@@ -95,13 +95,17 @@ int mimeapps_default(const char *text, const char *mime, char *out, size_t n) {if (len && len < n) {memcpy(out, p, len);out[len] = 0;- if (desktop_id_valid(out)) return 0;+ if (desktop_id_valid(out) && idx-- == 0) return 0;}p = s + 1;}return -1;}+int mimeapps_default(const char *text, const char *mime, char *out, size_t n) {+ return mimeapps_entry(text, "Default Applications", mime, 0, out, n);+}+static int list_has(const char *v, const char *ve, const char *id) {size_t il = strlen(id);for (const char *p = v; p < ve;) {@@ -197,6 +201,34 @@ char *mimeapps_set_default(const char *text, const char *mime, const char *id) {return b;}+/* Copies `text` without mime's key line in group grp (every other line byte for byte). */+static char *drop_key(const char *text, const char *grp, const char *mime) {+ Buf b = { 0 };+ const char *cur = text ? text : "", *gn;+ size_t gl;+ int inside = 0;+ Line l;+ puts_(&b, "");+ while (next_line(&cur, &l)) {+ const char *v, *ve;+ if (group_of(&l, &gn, &gl)) inside = in_group(gn, gl, grp);+ else if (inside && key_is(&l, mime, &v, &ve)) continue;+ put(&b, l.p, (size_t)(l.end - l.p));+ if (*l.end == '\n') puts_(&b, "\n");+ }+ if (b.oom) { free(b.p); return NULL; }+ return b.p;+}++char *mimeapps_unset_default(const char *text, const char *mime) {+ if (!mime_valid(mime)) return NULL;+ char *a = drop_key(text, "Default Applications", mime);+ if (!a) return NULL;+ char *b = drop_key(a, "Added Associations", mime);+ free(a);+ return b;+}+/* ---- globs2 ---- */int mime_guess(const char *globs2, const char *name, char *out, size_t n) {diff --git a/server/src/hw/mimeapps.h b/server/src/hw/mimeapps.hindex 53978d9..d046569 100644--- a/server/src/hw/mimeapps.h+++ b/server/src/hw/mimeapps.h@@ -19,6 +19,9 @@ int desktop_id_valid(const char *id);/* First application in [Default Applications] for mime (the "mime=a.desktop;b.desktop;" list).* 0 if found (out gets the id). */int mimeapps_default(const char *text, const char *mime, char *out, size_t n);+/* The idx-th valid desktop id (0 = first) of mime's list in group: "Default Applications" or+ * "Added Associations" of a mimeapps.list, "MIME Cache" of a mimeinfo.cache. 0 if there is one. */+int mimeapps_entry(const char *text, const char *group, const char *mime, int idx, char *out, size_t n);/* Is id listed in [Removed Associations] for mime? */int mimeapps_removed(const char *text, const char *mime, const char *id);/* New text with id as the default for mime: the [Default Applications] line is replaced (or@@ -26,6 +29,11 @@ int mimeapps_removed(const char *text, const char *mime, const char *id);* Every other line is kept byte for byte. Returns a malloc'd string, or NULL. */char *mimeapps_set_default(const char *text, const char *mime, const char *id);+/* New text without mime's lines in [Default Applications] and [Added Associations]: back to the+ * automatic choice, as GLib's reset does ([Removed Associations] is kept). Every other line is kept+ * byte for byte. Returns a malloc'd string, or NULL. */+char *mimeapps_unset_default(const char *text, const char *mime);+/* MIME type of a file name from a globs2 text ("weight:type:glob[:flags]"): highest weight,* then longest pattern; case-insensitive unless the "cs" flag is set. 0 if found. */int mime_guess(const char *globs2, const char *name, char *out, size_t n);diff --git a/server/src/ui/js_hw.c b/server/src/ui/js_hw.cindex 0d753cb..6a0d84b 100644--- a/server/src/ui/js_hw.c+++ b/server/src/ui/js_hw.c@@ -16,6 +16,8 @@* lord.bt.state() / power(on) / discover(on) / pair(path) / connect(path) / disconnect(path)* / forget(path) / answer(id, accept, value)* lord.mime.get(mime) / set(mime, id) / guess(path) / terminal() / setTerminal(id)+ * lord.mime.resolve(mime) { id, explicit, source }: the app launchWith('') uses+ * lord.mime.unset(mime) back to the automatic choice* lord.timedate.refresh() answer as __lordHw('timedate', …)* lord.notifyd.closed(id, reason) / action(id, key) back to the Linux app that notified* lord.hwinfo.scan() read-only hardware facts for the Store's suggestions@@ -54,6 +56,7 @@#include "js_fan.h"#include "../hw/brframe.h"#include "../hw/bt.h"+#include "../apps.h"#include "../hw/defaults.h"#include "../hw/display.h"#include "../hw/hw.h"@@ -318,6 +321,29 @@ static JSValue f_mime_set(JSContext *c, JSValueConst t, int argc, JSValueConst *return JS_NewBool(c, mime_valid(mime) && desktop_id_valid(id) && defaults_set(mime, id) == 0);}+/* lord.mime.resolve(mime) → { id: 'x.desktop', explicit, source: 'user'|'system'|'declared' } or+ * null: the app launchWith('', …) uses (apps_default_for); explicit only for the user's own choice. */+static JSValue f_mime_resolve(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t;+ char mime[MIME_MAX], id[DESKTOP_ID_MAX];+ if (!argc || arg_str(c, argv[0], mime, sizeof mime) || !mime_valid(mime)) return JS_NULL;+ int r = apps_default_for(mime, id, sizeof id);+ if (r <= 0) return JS_NULL;+ JSValue o = JS_NewObject(c);+ JS_SetPropertyStr(c, o, "id", JS_NewString(c, id));+ JS_SetPropertyStr(c, o, "explicit", JS_NewBool(c, r == APPS_DEFAULT_USER));+ JS_SetPropertyStr(c, o, "source", JS_NewString(c, r == APPS_DEFAULT_USER ? "user" : r == APPS_DEFAULT_LISTED ? "system" : "declared"));+ return o;+}++/* lord.mime.unset(mime): the user's choice for that type is removed (back to automatic). */+static JSValue f_mime_unset(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t;+ char mime[MIME_MAX];+ if (!argc || arg_str(c, argv[0], mime, sizeof mime)) return JS_FALSE;+ return JS_NewBool(c, mime_valid(mime) && defaults_unset(mime) == 0);+}+static JSValue f_mime_guess(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {(void)t;char path[1024], mime[MIME_MAX];@@ -341,6 +367,8 @@ static JSValue f_mime_set_terminal(JSContext *c, JSValueConst t, int argc, JSValstatic const JSCFunctionListEntry mime_funcs[] = {JS_CFUNC_DEF("get", 1, f_mime_get),JS_CFUNC_DEF("set", 2, f_mime_set),+ JS_CFUNC_DEF("resolve", 1, f_mime_resolve),+ JS_CFUNC_DEF("unset", 1, f_mime_unset),JS_CFUNC_DEF("guess", 1, f_mime_guess),JS_CFUNC_DEF("terminal", 0, f_mime_terminal),JS_CFUNC_DEF("setTerminal", 1, f_mime_set_terminal),diff --git a/server/tests/defaults_test.c b/server/tests/defaults_test.cnew file mode 100644index 0000000..ba16410--- /dev/null+++ b/server/tests/defaults_test.c@@ -0,0 +1,233 @@+/* defaults_test.c — the default app for a MIME type (apps_default_for in src/apps.c, the files in+ * src/hw/defaults.c) and lord.apps.launchWith('', path) on top of it, over a fake XDG tree: a+ * temporary folder stands for "/" (defaults_set_root) with its own /usr/share/applications,+ * /etc/xdg and /usr/share/mime/globs2, and a temporary HOME.+ *+ * Covers: no app → nothing (the old behaviour); the first installed app that declares the type+ * (by desktop id, then mimeinfo.cache order); Hidden, NoDisplay, Terminal, a missing TryExec, an Exec+ * without a file code or with a missing program skipped; the system's mimeapps.list/defaults.list+ * (in the specification's order, an uninstalled entry skipped); the user's choice wins, also as+ * "lordos-<app>.desktop"; [Removed Associations]; going back to automatic; ids and paths outside+ * the launcher's folders ignored. The launched app copies the file it was given to a marker. */+#include "apps.h"+#include "fsops.h"+#include "fw/rules.h"+#include "hw/defaults.h"+#include "hw/mimeapps.h"+#include "sec/broker.h"+#include "sec/perms.h"+#include "sec/restrict.h"++#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/stat.h>+#include <time.h>+#include <unistd.h>++void brokersrv_revoke(const char *app, const char *perm) { (void)app; (void)perm; }+PermState perm_get(const char *app_id, Perm p) { (void)app_id; (void)p; return PERM_ASK; }++static int n, bad;+#define CHECK(name, cond) do { n++; if (!(cond)) { bad++; printf("✗ %s\n", name); } } while (0)++static char root[64], home[128], sysapps[256], userapps[256];++static void put(const char *path, const char *text) {+ FILE *f = fopen(path, "w");+ if (!f) { perror(path); exit(1); }+ fputs(text, f);+ fclose(f);+}++/* apps_list() rereads a folder when its mtime changes; the kernel's timestamps move in ticks of a few+ * ms, so a file added in the tick of the last scan would not be seen: wait one out first. */+static void tick(void) {+ struct timespec ts = { 0, 30 * 1000 * 1000 };+ nanosleep(&ts, NULL);+}++/* A system (or user) .desktop whose Exec copies the opened file to $HOME/opened-<id>. */+static void app(int user, const char *id, const char *mime, const char *extra, const char *exec) {+ char path[512], text[1024], ex[512];+ tick();+ if (!exec) { snprintf(ex, sizeof ex, "/bin/cp %%f %s/opened-%s", home, id); exec = ex; }+ snprintf(path, sizeof path, "%s/%s.desktop", user ? userapps : sysapps, id);+ snprintf(text, sizeof text, "[Desktop Entry]\nType=Application\nName=%s\nExec=%s\n%s%s%s%s", id, exec,+ mime ? "MimeType=" : "", mime ? mime : "", mime ? "\n" : "", extra ? extra : "");+ put(path, text);+}++static void rm_app(int user, const char *id) {+ char path[512];+ snprintf(path, sizeof path, "%s/%s.desktop", user ? userapps : sysapps, id);+ tick();+ unlink(path);+}++static void sysfile(const char *rel, const char *text) {+ char path[512];+ snprintf(path, sizeof path, "%s%s", root, rel);+ if (text) put(path, text); else unlink(path);+}++static void userlist(const char *text) {+ char path[512];+ snprintf(path, sizeof path, "%s/.config/mimeapps.list", home);+ if (text) put(path, text); else unlink(path);+}++static int is(const char *mime, const char *want, int kind) {+ char id[DESKTOP_ID_MAX] = "";+ int r = apps_default_for(mime, id, sizeof id);+ if (want ? r != kind || strcmp(id, want) : r != 0) {+ printf(" %s: got %d '%s', want %d '%s'\n", mime, r, id, kind, want ? want : "");+ return 0;+ }+ return 1;+}++static int opened(const char *id) {+ char path[512];+ snprintf(path, sizeof path, "%s/opened-%s", home, id);+ for (int i = 0; i < 100; i++) {+ if (!access(path, F_OK)) return 1;+ struct timespec ts = { 0, 20 * 1000 * 1000 };+ nanosleep(&ts, NULL);+ }+ return 0;+}++int main(void) {+ snprintf(root, sizeof root, "/tmp/lord-defaults-XXXXXX");+ if (!mkdtemp(root)) { perror("mkdtemp"); return 1; }+ snprintf(home, sizeof home, "%s/home", root);+ const char *dirs[] = { "/usr", "/usr/share", "/usr/share/applications", "/usr/share/mime", "/usr/local", "/usr/local/share",+ "/usr/local/share/applications", "/etc", "/etc/xdg", "/opt", "/home", "/home/.config", "/home/.local",+ "/home/.local/share", "/home/.local/share/applications", NULL };+ char path[512];+ for (int i = 0; dirs[i]; i++) { snprintf(path, sizeof path, "%s%s", root, dirs[i]); mkdir(path, 0700); }+ snprintf(sysapps, sizeof sysapps, "%s/usr/share/applications", root);+ snprintf(userapps, sizeof userapps, "%s/.local/share/applications", home);+ setenv("HOME", home, 1);+ unsetenv("XDG_CONFIG_HOME");+ unsetenv("LORDOS_SESSIOND");+ defaults_set_root(root);+ char real[512];+ if (!realpath(home, real)) { perror(home); return 1; }+ fsops_init(real, "nobody-here"); /* the roots launchWith accepts */+ sysfile("/usr/share/mime/globs2", "50:text/html:*.html\n50:text/plain:*.txt\n50:image/png:*.png\n");+ restrict_set_store(fw_store_new());+ char page[256];+ snprintf(page, sizeof page, "%s/page.html", home);+ put(page, "<p>hi</p>\n");++ /* the pure parts */+ char id[DESKTOP_ID_MAX];+ const char *list = "[Default Applications]\ntext/html=a.desktop;../bad.desktop;b.desktop;\n[Added Associations]\ntext/html=c.desktop;\n";+ CHECK("entry 0", mimeapps_entry(list, "Default Applications", "text/html", 0, id, sizeof id) == 0 && !strcmp(id, "a.desktop"));+ CHECK("entry 1 skips an invalid id", mimeapps_entry(list, "Default Applications", "text/html", 1, id, sizeof id) == 0 && !strcmp(id, "b.desktop"));+ CHECK("no entry 2", mimeapps_entry(list, "Default Applications", "text/html", 2, id, sizeof id) != 0);+ CHECK("added group", mimeapps_entry(list, "Added Associations", "text/html", 0, id, sizeof id) == 0 && !strcmp(id, "c.desktop"));+ char *u = mimeapps_unset_default("# mine\n[Default Applications]\ntext/plain=x.desktop;\ntext/html=a.desktop;\n\n"+ "[Added Associations]\ntext/html=a.desktop;z.desktop;\nimage/png=p.desktop;\n"+ "[Removed Associations]\ntext/html=r.desktop;\n", "text/html");+ CHECK("unset drops both keys, keeps every other line",+ u && !strcmp(u, "# mine\n[Default Applications]\ntext/plain=x.desktop;\n\n[Added Associations]\nimage/png=p.desktop;\n"+ "[Removed Associations]\ntext/html=r.desktop;\n"));+ free(u);+ u = mimeapps_unset_default("[Default Applications]\ntext/html=a.desktop;", "text/html"); /* no final newline */+ CHECK("unset without a final newline", u && !strcmp(u, "[Default Applications]\n"));+ free(u);+ CHECK("unset refuses a bad type", mimeapps_unset_default("", "text/html\n[x]") == NULL);++ /* 1. nothing installed opens it: nothing (the old behaviour) */+ CHECK("no app: none", is("text/html", NULL, 0));+ CHECK("no app: launchWith('') refuses", apps_launch_with("", page) != 0);++ /* 2. the apps that can't be used are skipped */+ app(0, "aa-hidden", "text/html;", "Hidden=true\n", NULL);+ app(0, "ab-nodisplay", "text/html;", "NoDisplay=true\n", NULL);+ app(0, "ac-terminal", "text/html;", "Terminal=true\n", NULL);+ app(0, "ad-tryexec", "text/html;", "TryExec=/nonexistent/lord-browser\n", NULL);+ app(0, "ae-nofile", "text/html;", NULL, "/bin/cp /etc/hostname /tmp/lord-defaults-never");+ app(0, "af-noprog", "text/html;", NULL, "/nonexistent/lord-browser %u");+ app(0, "ag-other", "text/plain;", NULL, NULL);+ app(0, "ah-onlyshow", "text/html;", "OnlyShowIn=GNOME;\n", NULL);+ CHECK("unusable apps: none", is("text/html", NULL, 0));+ snprintf(path, sizeof path, "%s/opt/applications", root);+ mkdir(path, 0700);+ snprintf(path, sizeof path, "%s/opt/applications/outside.desktop", root);+ put(path, "[Desktop Entry]\nType=Application\nName=Outside\nExec=/bin/cp %f /tmp/x\nMimeType=text/html;\n");+ sysfile("/usr/share/applications/mimeinfo.cache", "[MIME Cache]\ntext/html=ghost.desktop;outside.desktop;aa-hidden.desktop;\n");+ sysfile("/usr/share/applications/defaults.list", "[Default Applications]\ntext/html=outside.desktop;../../opt/applications/outside.desktop;\n");+ CHECK("ids outside the launcher's folders: none", is("text/html", NULL, 0));++ /* 3. the first installed app that declares the type: by desktop id without a cache entry */+ app(0, "zeta-browser", "text/html;x-scheme-handler/https;", NULL, NULL);+ app(0, "beta-browser", "text/html;", NULL, NULL);+ CHECK("first declaring app, by id", is("text/html", "beta-browser.desktop", APPS_DEFAULT_DECLARED));+ CHECK("it declares only what it declares", is("image/png", NULL, 0));+ CHECK("launchWith('') opens it", apps_launch_with("", page) == 0 && opened("beta-browser"));+ CHECK("a path outside home is refused", apps_launch_with("", "/etc/hostname") != 0);+ /* mimeinfo.cache order comes first */+ sysfile("/usr/share/applications/mimeinfo.cache", "[MIME Cache]\ntext/html=ghost.desktop;zeta-browser.desktop;beta-browser.desktop;\n");+ CHECK("mimeinfo.cache order", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_DECLARED));+ /* the user's own folder: its cache is read first; a user app shadows a system one of the same id */+ app(1, "user-browser", "text/html;", NULL, NULL);+ snprintf(path, sizeof path, "%s/mimeinfo.cache", userapps);+ put(path, "[MIME Cache]\ntext/html=user-browser.desktop;\n");+ CHECK("the user's mimeinfo.cache first", is("text/html", "user-browser.desktop", APPS_DEFAULT_DECLARED));+ unlink(path);+ rm_app(1, "user-browser");++ /* 4. what the system marks as default */+ sysfile("/usr/share/applications/defaults.list", "[Default Applications]\ntext/html=beta-browser.desktop;\n");+ CHECK("defaults.list", is("text/html", "beta-browser.desktop", APPS_DEFAULT_LISTED));+ sysfile("/usr/share/applications/mimeapps.list", "[Default Applications]\ntext/html=ghost.desktop;aa-hidden.desktop;zeta-browser.desktop;\n");+ CHECK("mimeapps.list before defaults.list, uninstalled entries skipped", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_LISTED));+ app(0, "mail-only", "x-scheme-handler/mailto;", NULL, NULL);+ sysfile("/etc/xdg/mimeapps.list", "[Default Applications]\ntext/html=mail-only.desktop;\n");+ CHECK("/etc/xdg first; a default need not declare the type", is("text/html", "mail-only.desktop", APPS_DEFAULT_LISTED));+ sysfile("/etc/xdg/mimeapps.list", "[Default Applications]\ntext/html=lordos-photos.desktop;\n");+ CHECK("a system lordos- entry is not installed: skipped", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_LISTED));+ sysfile("/etc/xdg/mimeapps.list", NULL);++ /* 5. the user's choice wins */+ userlist("[Default Applications]\ntext/html=beta-browser.desktop;\n");+ CHECK("the user's choice", is("text/html", "beta-browser.desktop", APPS_DEFAULT_USER));+ CHECK("lord.mime.get sees it", defaults_lookup("text/html", id, sizeof id) == 0 && !strcmp(id, "beta-browser.desktop"));+ userlist("[Default Applications]\ntext/html=lordos-editor.desktop;\n");+ CHECK("the user's lordos- choice", is("text/html", "lordos-editor.desktop", APPS_DEFAULT_USER));+ CHECK("launchWith('') leaves it to the theme", apps_launch_with("", page) != 0);+ userlist("[Default Applications]\ntext/html=ghost.desktop;\n");+ CHECK("an uninstalled user choice falls through", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_LISTED));+ userlist("[Removed Associations]\ntext/html=zeta-browser.desktop;\n");+ CHECK("the user's Removed Associations apply to the system's lists", is("text/html", "beta-browser.desktop", APPS_DEFAULT_LISTED));+ userlist("[Added Associations]\ntext/html=mail-only.desktop;\n");+ CHECK("Added Associations after every default", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_LISTED));+ sysfile("/usr/share/applications/mimeapps.list", NULL);+ sysfile("/usr/share/applications/defaults.list", NULL);+ CHECK("Added Associations before the declaring apps", is("text/html", "mail-only.desktop", APPS_DEFAULT_LISTED));++ /* 6. choosing and going back to automatic */+ userlist("# kept\n[Default Applications]\ntext/plain=ag-other.desktop;\n");+ CHECK("set", defaults_set("text/html", "beta-browser.desktop") == 0);+ CHECK("set: explicit", is("text/html", "beta-browser.desktop", APPS_DEFAULT_USER));+ CHECK("unset", defaults_unset("text/html") == 0);+ CHECK("unset: automatic again", is("text/html", "zeta-browser.desktop", APPS_DEFAULT_DECLARED));+ CHECK("unset kept the other lines", defaults_lookup("text/plain", id, sizeof id) == 0 && !strcmp(id, "ag-other.desktop"));+ char *t = defaults_read(strcat(strcpy(path, home), "/.config/mimeapps.list"));+ CHECK("unset kept the comment", t && strstr(t, "# kept\n") && !strstr(t, "text/html"));+ free(t);+ userlist(NULL);+ CHECK("unset with no file", defaults_unset("text/html") == 0);+ CHECK("unset refuses a bad type", defaults_unset("../x") != 0);+ CHECK("launchWith('') opens the automatic app", apps_launch_with("", page) == 0 && opened("zeta-browser"));++ char cmd[600];+ snprintf(cmd, sizeof cmd, "rm -rf '%s'", root);+ if (system(cmd)) {}+ printf(bad ? "defaults: %d of %d failed\n" : "defaults: %d/%d ok\n", bad ? bad : n, n);+ return bad ? 1 : 0;+}diff --git a/web/content/paper/paper.en.md b/web/content/paper/paper.en.mdindex d56c930..ef366d0 100644--- a/web/content/paper/paper.en.md+++ b/web/content/paper/paper.en.md@@ -88,7 +88,7 @@ LordOS speaks to several Debian services over their own protocols with its own c- **Network (`lord-netd`).** The network belongs to the system, not to a session. `lord-sessiond` starts `lord-netd` at boot with a fixed path and no arguments, so the machine has an address before anyone logs in. It runs only the closed `net-*` actions: its own DHCP client and netlink code, Wi-Fi through Debian's `wpa_supplicant`, WireGuard through LordOS's own netlink code, OpenVPN, IPsec/IKEv2 through strongSwan's `charon` driven over VICI with LordOS's own client, and optionally OpenConnect, PPTP and Fortinet-compatible tunnels. It talks only to the sessions' root helpers, over a socket that accepts only uid 0.- **Fans (`lord-fand`).** A root service that reads the CPU temperature every 2 s and writes fan duty from a profile, from early boot. It drives only fans its own scan found: the Raspberry Pi 5 fan header and allow-listed motherboard controllers. Laptop, GPU and unknown fans are never written. On stop, or after a crash, it restores the original kernel settings. It runs no programs, has no network, no capabilities and no device nodes.-- **Hardware settings.** Displays (modes from KMS with EDID names, a 15-second "keep these settings?" revert, per-display persistence, rotation, Night Light), Bluetooth through BlueZ, battery and power profiles, idle and lid handling, date and time, notifications for Linux apps and default apps. Changes arrive as kernel uevents and D-Bus signals; nothing polls. On a Raspberry Pi 5, Settings → Board firmware shows and updates the bootloader in the board's EEPROM through two closed admin actions (0.8.4.1).+- **Hardware settings.** Displays (modes from KMS with EDID names, a 15-second "keep these settings?" revert, per-display persistence, rotation, Night Light), Bluetooth through BlueZ, battery and power profiles, idle and lid handling, date and time, notifications for Linux apps and default apps (in 0.8.6, in development: when you haven't chosen one, a file opens with the system's default or the first installed app that declares its type, shown as "Automatic"). Changes arrive as kernel uevents and D-Bus signals; nothing polls. On a Raspberry Pi 5, Settings → Board firmware shows and updates the bootloader in the board's EEPROM through two closed admin actions (0.8.4.1).- **Updates.** Installed systems update in place from LordOS's signed APT repository on lordos.org, from Store → Updates or with `apt`; changes that are more than new files run as numbered, idempotent migrations (0.8.1). The Store's package engine follows apt's priorities (`/etc/apt/preferences.d`, 0.8.5), so on the Raspberry Pi image "Update all" chooses the same versions as `apt` and the pinned kernel stays blocked, and it accepts sources written as `Architectures: amd64,arm64` as apt does. The update from 0.8.4.1 or 0.8.4 to 0.8.5 runs no migration; it was tested with the release package built as 0.8.5~rc2 on a VMware machine on 0.8.4.1 and a Raspberry Pi 5 on 0.8.4, both with `apt`, then a restart.### Source filesdiff --git a/web/content/paper/paper.es.md b/web/content/paper/paper.es.mdindex e2e4703..24b750f 100644--- a/web/content/paper/paper.es.md+++ b/web/content/paper/paper.es.md@@ -88,7 +88,7 @@ LordOS habla con varios servicios de Debian por sus propios protocolos, con clie- **Red (`lord-netd`).** La red pertenece al sistema, no a una sesión. `lord-sessiond` arranca `lord-netd` al iniciar, con una ruta fija y sin argumentos, así la máquina tiene dirección antes de que alguien inicie sesión. Solo ejecuta las acciones cerradas `net-*`: su propio cliente DHCP y código netlink, Wi-Fi a través del `wpa_supplicant` de Debian, WireGuard con el código netlink propio de LordOS, OpenVPN, IPsec/IKEv2 a través del `charon` de strongSwan manejado por VICI con un cliente propio de LordOS y, opcionalmente, túneles OpenConnect, PPTP y compatibles con Fortinet. Habla solo con los ayudantes root de las sesiones, por un socket que acepta únicamente uid 0.- **Ventiladores (`lord-fand`).** Un servicio root que lee la temperatura de la CPU cada 2 s y escribe el ciclo de trabajo de los ventiladores según un perfil, desde temprano en el arranque. Maneja solo los ventiladores que encontró su propio escaneo: el conector de ventilador de la Raspberry Pi 5 y controladores de placa madre de una lista permitida. Nunca escribe ventiladores de notebooks, GPU ni desconocidos. Al detenerse, o después de un fallo, restaura la configuración original del kernel. No ejecuta programas, no tiene red, ni capacidades, ni nodos de dispositivo.-- **Configuración de hardware.** Pantallas (modos desde KMS con nombres EDID, una reversión de 15 segundos con "¿mantener esta configuración?", persistencia por pantalla, rotación, Luz nocturna), Bluetooth a través de BlueZ, batería y perfiles de energía, inactividad y tapa, fecha y hora, notificaciones para apps de Linux y apps predeterminadas. Los cambios llegan como uevents del kernel y señales de D-Bus; nada consulta en bucle. En una Raspberry Pi 5, Ajustes → Firmware de la placa muestra y actualiza el cargador de arranque que está en la EEPROM de la placa mediante dos acciones de administración cerradas (0.8.4.1).+- **Configuración de hardware.** Pantallas (modos desde KMS con nombres EDID, una reversión de 15 segundos con "¿mantener esta configuración?", persistencia por pantalla, rotación, Luz nocturna), Bluetooth a través de BlueZ, batería y perfiles de energía, inactividad y tapa, fecha y hora, notificaciones para apps de Linux y apps predeterminadas (en la 0.8.6, en desarrollo: si no elegiste una, el archivo se abre con la predeterminada del sistema o con la primera app instalada que declara su tipo, que se muestra como "Automática"). Los cambios llegan como uevents del kernel y señales de D-Bus; nada consulta en bucle. En una Raspberry Pi 5, Ajustes → Firmware de la placa muestra y actualiza el cargador de arranque que está en la EEPROM de la placa mediante dos acciones de administración cerradas (0.8.4.1).- **Actualizaciones.** Los sistemas instalados se actualizan en el lugar desde el repositorio APT firmado de LordOS en lordos.org, desde Tienda → Actualizaciones o con `apt`; los cambios que son más que archivos nuevos se ejecutan como migraciones numeradas e idempotentes (0.8.1). El motor de paquetes de la Tienda respeta las prioridades de apt (`/etc/apt/preferences.d`, 0.8.5), así que en la imagen para Raspberry Pi "Actualizar todo" elige las mismas versiones que `apt` y el kernel fijado sigue bloqueado, y acepta fuentes escritas como `Architectures: amd64,arm64`, como apt. La actualización de la 0.8.4.1 o la 0.8.4 a la 0.8.5 no ejecuta ninguna migración; se probó con el paquete del release compilado como 0.8.5~rc2 en una máquina VMware con la 0.8.4.1 y en una Raspberry Pi 5 con la 0.8.4, las dos con `apt` y después un reinicio.### Archivos fuentediff --git a/web/content/paper/paper.pt.md b/web/content/paper/paper.pt.mdindex 94ef9d6..807c561 100644--- a/web/content/paper/paper.pt.md+++ b/web/content/paper/paper.pt.md@@ -88,7 +88,7 @@ O LordOS conversa com vários serviços do Debian pelos protocolos deles, com cl- **Rede (`lord-netd`).** A rede pertence ao sistema, não a uma sessão. O `lord-sessiond` inicia o `lord-netd` no boot, com caminho fixo e sem argumentos, para que a máquina tenha endereço antes de alguém fazer login. Ele roda só as ações fechadas `net-*`: seu próprio cliente DHCP e código netlink, Wi-Fi pelo `wpa_supplicant` do Debian, WireGuard pelo código netlink próprio do LordOS, OpenVPN, IPsec/IKEv2 pelo `charon` do strongSwan controlado via VICI com cliente próprio do LordOS e, opcionalmente, túneis OpenConnect, PPTP e compatíveis com Fortinet. Ele só fala com os ajudantes root das sessões, por um socket que aceita apenas uid 0.- **Ventoinhas (`lord-fand`).** Um serviço root que lê a temperatura da CPU a cada 2 s e escreve o ciclo das ventoinhas a partir de um perfil, desde o início do boot. Ele só controla ventoinhas que a própria varredura encontrou: o conector de ventoinha do Raspberry Pi 5 e controladores de placa-mãe de uma lista permitida. Ventoinhas de notebook, de GPU e desconhecidas nunca são escritas. Ao parar, ou depois de uma falha, ele restaura as configurações originais do kernel. Não roda programas, não tem rede, nem capacidades, nem nós de dispositivo.-- **Configurações de hardware.** Telas (modos vindos do KMS com nomes do EDID, reversão de 15 segundos com "manter estas configurações?", persistência por tela, rotação, Luz Noturna), Bluetooth pelo BlueZ, bateria e perfis de energia, ociosidade e tampa, data e hora, notificações dos apps Linux e apps padrão. As mudanças chegam como uevents do kernel e sinais D-Bus; nada fica consultando em loop. Num Raspberry Pi 5, Ajustes → Firmware da placa mostra e atualiza o bootloader que fica na EEPROM da placa por meio de duas ações administrativas fechadas (0.8.4.1).+- **Configurações de hardware.** Telas (modos vindos do KMS com nomes do EDID, reversão de 15 segundos com "manter estas configurações?", persistência por tela, rotação, Luz Noturna), Bluetooth pelo BlueZ, bateria e perfis de energia, ociosidade e tampa, data e hora, notificações dos apps Linux e apps padrão (na 0.8.6, em desenvolvimento: se você não escolheu um, o arquivo abre com o padrão do sistema ou com o primeiro app instalado que declara o seu tipo, mostrado como "Automático"). As mudanças chegam como uevents do kernel e sinais D-Bus; nada fica consultando em loop. Num Raspberry Pi 5, Ajustes → Firmware da placa mostra e atualiza o bootloader que fica na EEPROM da placa por meio de duas ações administrativas fechadas (0.8.4.1).- **Atualizações.** Os sistemas instalados se atualizam no lugar a partir do repositório APT assinado do LordOS em lordos.org, por Loja → Atualizações ou com o `apt`; mudanças que são mais do que arquivos novos rodam como migrações numeradas e idempotentes (0.8.1). O motor de pacotes da Loja segue as prioridades do apt (`/etc/apt/preferences.d`, 0.8.5), então na imagem do Raspberry Pi "Atualizar tudo" escolhe as mesmas versões que o `apt` e o kernel fixado continua bloqueado, e aceita fontes escritas como `Architectures: amd64,arm64`, como o apt. A atualização da 0.8.4.1 ou da 0.8.4 para a 0.8.5 não roda nenhuma migração; foi testada com o pacote do lançamento gerado como 0.8.5~rc2 numa máquina VMware com a 0.8.4.1 e num Raspberry Pi 5 com a 0.8.4, as duas com o `apt`, seguido de um reinício.### Arquivos-fonte