diff --git a/README.md b/README.md index 21084ec..039f34c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PLWL — Portable Linux Wine Launcher -A portable launcher for Windows games and applications on Linux — and for native Linux apps, run with their own isolated home (bubblewrap when available). +A portable launcher for Windows games and applications on Linux — and for native Linux apps, run with their own home and a chosen isolation level (bubblewrap when available). ## Portable layout @@ -44,21 +44,30 @@ The entry point is found automatically in the picked folder: an ELF binary or `. A native app runs with its **own home folder**: `HOME`, `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_CACHE_HOME` and `XDG_STATE_HOME` point into `files/wineprefixes//linux_pfx/`, so config, cache and state land there instead of in your `~`. The prefix select in the app's config picks which one; **Open data folder** takes you to it. `linux_pfx` is machine-local — a LAN sync never pushes it and never deletes it. -When **bubblewrap** is installed *and* usable (PLWL probes it with a real run, not `which bwrap` — Ubuntu's AppArmor profile kills it even when it is installed), the app also gets its own namespaces: `/` is mounted read-only, so only **its home folder and its own app folder stay writable** — anything else fails with `EROFS`. The app folder is included on purpose: portable apps keep their logs and data next to themselves (Prism Launcher refuses to start otherwise). System trees are never handed out writable, not even when the app itself lives in one. Screens, audio (X11/Wayland, PulseAudio/PipeWire), gamepads and networking keep working. `XDG_RUNTIME_DIR` stays the host's, so the session bus is shared — the sandbox is not airtight, and the UI says so rather than pretending. +When **bubblewrap** is installed *and* usable (PLWL probes it with a real run, not `which bwrap` — Ubuntu's AppArmor profile kills it even when it is installed), the two sandboxed levels also give the app its own namespaces: `/` is mounted read-only, so only **its home folder and its own app folder stay writable** — anything else fails with `EROFS`. Relaxed adds exactly one mount on top of that profile (the writable host filesystem described below); everything else on this page is the same at both levels. The app folder is included on purpose: portable apps keep their logs and data next to themselves (Prism Launcher refuses to start otherwise). System trees are never handed out writable, not even when the app itself lives in one. Screens, audio (X11/Wayland, PulseAudio/PipeWire), gamepads and networking keep working. `XDG_RUNTIME_DIR` stays the host's, so the session bus is shared — the sandbox is not airtight, and the UI says so rather than pretending. The redirected home starts with a **copy of your desktop preferences** — `kdeglobals`, the GTK 3/4 settings and `user-dirs.dirs` — so the app keeps your theme instead of falling back to its built-in light look. The copy keeps following your host as long as the app has not changed it: a theme change arrives on the next launch, and the moment the app writes its own version, PLWL never touches it again. Your own **fonts, icons, themes and colour schemes are not copied but mounted read-only** inside the sandbox and added to `XDG_DATA_DIRS`, so they follow the host live and nothing can be written back to your `~`. +**Anything the app wants to open is opened by your own desktop.** A **link** goes to the host's xdg-desktop-portal, so it lands in the browser you actually chose instead of one resolved in here, where the default association and its `.desktop` file are behind the redirected home — that used to mean a system browser you never picked, or nothing at all. Both routes reach the portal: `xdg-open` itself (what Qt, Prism and Electron call) and GIO's in-process resolution (`gtk_show_uri`). A **folder or a document** (Prism's *Open Pack Folder*, a text file, a drop) takes the other route: the app leaves the target in its own home, PLWL picks it up, translates the path back out of the sandbox and opens it with your `xdg-open` — so it arrives in your file manager, and a scheme nothing handles gets your desktop's own *Choose an application* dialog rather than a guess. On a machine without a portal nothing is changed — a link then behaves exactly as it did before. A KDE-native app that resolves the link in-process through KIO (Dolphin, Kate) is the one path still left out: it asks KDE's own handler database, which has no answer in here (measured: `kde-open` opens nothing and reports success). + Every prefix in the **Wine prefixes** tab has a **Reset Linux config** button: it deletes the desktop preferences PLWL copied in (and the hashes that track them), so the next app start seeds a clean copy from your system — the way back when an app has hijacked a seeded file with its own theme. App data in `linux_pfx` is never touched, and an app running from that prefix blocks the reset. Imported trees get **normalised permissions**: every file gets the owner's `rwx` and an `x` mirrored from its `r`, because sources come from archives, FAT sticks or read-only backups where those bits are simply not there. Some apps draw their window icon themselves, which Wayland does not allow — Minecraft (LWJGL 3.4+) is the known case: its taskbar icon turns into the generic Wayland one. The per-app **Force X11 (XWayland)** switch moves the app *and the programs it launches* back to X11, where the icon works again. -Per app you choose the **Isolation** policy: *Automatic* (bwrap when it works, plain run when it does not), *Off*, or *Required* (refuse to start instead of running unsandboxed). The backend actually used is always visible: a badge on the library card, a `[plwl] isolation: …` line in the app log, and a status card in Settings with **Check again**. When bwrap is missing, PLWL says so once instead of quietly launching without it. +Per app you choose the **Isolation** level — what the app gets besides its own home folder: + +- **None** — a plain run. The app sees your real filesystem exactly as any other program of yours does: what a shortcut hands it works, including into an app that is already running. +- **Relaxed** — the sandbox *plus* your whole filesystem mounted writable at `/tmp/plwl-fs-root`. A document handed over behaves natively — it opens where the app was told it is, it can be saved, and it also reaches an app that is already running, because the mount is there from the first second of every run. The price is real and the UI says it: at this level the app can change anything your user can. +- **Isolated** — the sandbox without that mount. The system stays read-only, and a document handed over is **copied** first, into `plwl-handoff` inside the app's own home folder; the app works on that copy (so the original cannot be touched), and a copy big enough to be noticed shows a progress popup in the launcher. +- **Automatic** (default) — Relaxed where bubblewrap works, None where it does not. + +An explicit Relaxed or Isolated on a machine without a working bubblewrap **refuses to start** instead of quietly dropping the promise; Automatic is the one level allowed to weaken itself. What the app really ran as is always visible: a badge on the library card, a `[plwl] isolation: …` line in the app log, and a status card in Settings with **Check again**. When bwrap is missing, PLWL says so once instead of quietly launching without it. ## "Open with PLWL" -The desktop entry registers `.exe/.msi/.bat/.cmd/.lnk` in file managers. Opening one shows a popup to pick the **Wine/Proton build** and **prefix** for that run (defaults preselected, nothing imported). A second instance hands the path to the running one. App shortcuts work as **Open With** targets too: the app receives the file as the Windows path it would get on Windows — `C:\...` inside its prefix, `Z:\...` otherwise. A file handed to an already running app goes to that instance instead of a second tracked run. +The desktop entry registers `.exe/.msi/.bat/.cmd/.lnk` in file managers. Opening one shows a popup to pick the **Wine/Proton build** and **prefix** for that run (defaults preselected, nothing imported). A second instance hands the path to the running one. App shortcuts work as **Open With** targets too: the app receives the file as the Windows path it would get on Windows — `C:\...` inside its prefix, `Z:\...` otherwise. A file handed to an already running app goes to that instance instead of a second tracked run. A **Linux app shortcut** is an Open With target the same way, and what the app is handed depends on its isolation level: at **None** the plain absolute path, at **Relaxed** the same file through the writable host mount (`/tmp/plwl-fs-root/…`) — which is also the only shape an app that is *already running* can resolve, since a mount cannot be added to a live sandbox — and at **Isolated** a copy in `plwl-handoff` inside the app's own home folder, so the original stays untouched. ## LAN syncing diff --git a/development.md b/development.md index f464a91..b29d792 100644 --- a/development.md +++ b/development.md @@ -15,11 +15,16 @@ src/ main process (Node/Electron backend) lansync.js LAN sync handlers (identity, devices, re-roll, sync + progress) runner.js spawns wine/proton (env, prefix, playtime, logs) and owns spawnTracked() - the log/playtime/exit tail every run shares - linuxrunner.js native Linux apps: redirected HOME/XDG, bwrap or plain run + linuxrunner.js native Linux apps: redirected HOME/XDG, the isolation level + (none/relaxed/isolated/auto) and the handed-document path + openrelay.js the launcher side of the hand-off: the request folder an app + leaves what it wants opened in, watched while it runs linuxapp.js native app detection (ELF/AppImage/.desktop) + icon lookup sandbox.js bubblewrap probe (functional, cached) + buildBwrapArgs + (+ FS_ROOT, the one mount the relaxed level adds) library.js apps registry (apps.json) + settings + playtime files, plus - the "which prefix does this app use" / in-use guards + the "which prefix does this app use" / in-use guards and + the isolation-mode gate on the way in wines.js wine/proton build scan, registry, portable symlink healing prefixes.js prefix registry (files/wineprefixes) symlinks.js relative symlink rewiring + executable-bit restoration @@ -67,12 +72,13 @@ Renderer never touches Node/Electron directly — everything goes through the `w - Registries (apps.json, wines.json, prefixes.json) are rewritten whole via writeJson(); playtime lives in its own tiny file so the registry is not rewritten while a game runs. - Deleting user data needs a confirm modal; best-effort cleanup is try/catch-and-ignore with a comment saying why it is safe to ignore. - Windows apps run through runGame()/buildEnv() — never spawn wine directly elsewhere (prefix handling, Proton env and playtime live there). -- Native Linux apps run through linuxrunner.runLinuxGame()/buildLinuxEnv() the same way: HOME and the XDG folders are redirected into `{prefix}/linux_pfx/`, and bwrap (when the probe says it works) forces the same layout with mounts. Never spawn a native app elsewhere. `game.kind` is absent on old entries — that means Windows; `game.isolation` is `auto` (bwrap when usable, plain run otherwise), `off` or `require` (refuse to start instead of quietly weakening). The chosen backend always lands in the log and the UI (a silent downgrade is the failure mode to avoid). -- Under bwrap ONLY two things stay writable: the redirected home and the app's own folder (`writableAppDir`: inside files/apps, or the folder the app was imported from — never `/usr`, `/etc`, `/bin`… and never files/wines). Portable apps write logs and data next to themselves and a read-only app folder makes them refuse to start (Prism Launcher: "couldn't create a log file - Read-only file system"). Everything else is `EROFS` by design. +- Native Linux apps run through linuxrunner.runLinuxGame()/buildLinuxEnv() the same way: HOME and the XDG folders are redirected into `{prefix}/linux_pfx/`, and bwrap (when the probe says it works) forces the same layout with mounts. Never spawn a native app elsewhere. `game.kind` is absent on old entries — that means Windows; `game.isolation` is one of four levels, resolved by linuxrunner.resolveLevel: `none` (plain run), `relaxed` (bwrap + the whole host filesystem mounted writable at sandbox.FS_ROOT) and `isolated` (bwrap with the stock read-only profile), with `auto` (default) meaning relaxed where bwrap works and none where it does not. Only `auto` may weaken itself — an explicit relaxed/isolated answers `sandbox-required` instead ("no silent downgrade"), and library.js maps the values launcher 0.5.x wrote (`off` → none, `require` → isolated) both when reading the registry and when a patch is saved. The level always lands in the log and the UI. resolveLevel awaits the probe when nothing has measured yet: a shortcut boots HEADLESS, so no renderer ran `sandbox:status` — without that wait `auto` would read an empty cache and quietly pick `none` (and an explicit level would refuse a machine that can sandbox perfectly well). +- Under bwrap ONLY two things stay writable: the redirected home and the app's own folder (`writableAppDir`: inside files/apps, or the folder the app was imported from — never `/usr`, `/etc`, `/bin`… and never files/wines). Portable apps write logs and data next to themselves and a read-only app folder makes them refuse to start (Prism Launcher: "couldn't create a log file - Read-only file system"). Everything else is `EROFS` by design — at the isolated level. Relaxed is the deliberate exception and says so in the UI: `FS_ROOT` is the same filesystem, mounted writable, so "everything else" is only unreachable through the real paths. - Two pipes feed one log in spawnTracked: neither may end the stream (pipe(ws, { end: false }), closed when both sources drained, at the latest LOG_DRAIN_MS after the exit) and the write stream carries an error listener. Ending it at `exit` while a pipe still had data killed the whole launcher with ERR_STREAM_WRITE_AFTER_END. - A prefix or wine build a running app uses cannot be renamed/deleted (wine holds files open there): the guards sit next to the handlers in src/ipc/, use the games service's running list plus library.js helpers (prefixNameForGame/gamesUsingPrefix/is*InUse) and answer `{ ok:false, error:'inUse'|'hasApps', apps:[names] }` for the toast. -- Long operations stream progress through the single import:progress slot as `{ phase: 'count'|'copy'|'remove', files, bytes, totalFiles, totalBytes }` (runWithProgress for deletes/imports). Emit 'count' (a treeSize walk) first, copy/remove through the fsutil helpers. +- Long operations stream progress through the single import:progress slot as `{ phase: 'count'|'copy'|'remove', files, bytes, totalFiles, totalBytes }` (runWithProgress for deletes/imports). Emit 'count' (a treeSize walk) first, copy/remove through the fsutil helpers. An isolated hand-off has its own slot, handoff:progress (`{ phase: 'copy'|'done'|'error', name, bytes, totalBytes, notice }`), because it can start before the window exists: main.js gets the event first and, when `notice` is set (a copy above linuxrunner.STAGE_NOTICE_BYTES), puts the launcher window up so the renderer's popup can be seen; below that the copy is over before a window could paint. Copies of one file go through fsutil.copyFileProgress (streamed, throttled by progressGate, `.part` + rename). - CSS: reuse the existing variables/classes (.button, .field-label, .custom-select, form-card); spacing comes from --button-margin and flex gaps, not per-element magic numbers. +- The blanket `transform: translateZ(0)` (crisper small glyphs) makes every element its own stacking context, so a select's own z-index cannot escape the wrapper it sits in: a list opened inside `.linux-only`, `.win-only` or an override row was painted UNDER the field label and textarea that follow it (measuring with `elementsFromPoint` over the open list returned the label). CustomSelect lifts the chain instead of the host — `lift()` adds `.select-lift` to every STATIC ancestor while the list is open, and `close()`/`closeAll()` take it off again; positioned ancestors are skipped, so the fixed modal overlay keeps stacking over every view on its own. ### Native Linux apps @@ -83,7 +89,12 @@ Renderer never touches Node/Electron directly — everything goes through the `w - SESSION_MANAGER is dropped in the sandbox: the session socket sits in the private `/tmp`, so the pointer led nowhere (Qt: "Could not open network socket"). - Imports normalise permissions (fsutil.chmodTree): owner `rwx`, `x` mirrored from `r` (0644 → 0755). Sources are archives, FAT sticks and read-only backups. - **Reset Linux config** on every prefix row removes exactly what PLWL seeded (DESKTOP_SEEDS, the pulse cookie, `home/.Xauthority`, `.seeded.json`) plus the folders that existed only for the seed, so the next start seeds clean. syncDesktopConfig can only follow a copy it can still prove is its own; the reset does not argue. App data (`data/`, `cache/`, `state/`, `config//`, the rest of `home/`) is never touched, and a running app from that prefix blocks it (the usual `inUse` guard). -- The user's real `~` is deliberately invisible in the sandbox (HOME is bound straight to `{prefix}/linux_pfx/home`), so absolute paths an app wrote into its config before the import (Prism's instance `JavaPath`) do not resolve — that is what `isolation: 'off'` is for. +- With HOME bound straight to `{prefix}/linux_pfx/home`, the user's real `~` is invisible to the app — one reason absolute paths an app wrote into its config before the import (Prism's instance `JavaPath`) do not resolve. `relaxed` does not change that shadowing, but it does make the real filesystem reachable through `FS_ROOT`/home/… — and `none` gives the app the real paths outright, which is what those two levels are for. +- A clicked link belongs to the host desktop, so it leaves through `org.freedesktop.portal.OpenURI`: the `xdg-open` BINARY is replaced inside the sandbox (a written shim `--ro-bind` over `/usr/bin/xdg-open`) and Qt execs it (measured — `QGenericUnixServices` picks `xdg-open` first, and reaches the portal itself only under `/.flatpak-info`/`SNAP`, which a bwrap profile does not have); Electron does the same. GIO resolves an URI IN-PROCESS, which no shim can reach: for that the prefix seeds `home/.plwl/open-url` (launcher-written, like the shim) plus a desktop entry and a `mimeapps.list` naming it the default for `x-scheme-handler/http|https`, `text/html`, `x-scheme-handler/file` and `inode/directory`. Without the seed GIO falls back to the host's `/usr/share` list — measured: it offered `brave-origin.desktop`, and `gio open` answered "The specified location is not supported". Measured end to end (both backends): the portal launches the host's `helium.desktop` with the exact URI. `GIO_USE_PORTALS=1` was measured and REJECTED: it opened NOTHING and still reported success (GIO's portal path wants a sandbox marker this launcher does not fake). A KDE-native app resolving the link in-process through KIO (`kde-open`) stays uncovered — KDE ignores the seeded list (measured). +- The portal is not told about a FOLDER or a document, which is what "Open Pack Folder" or a drop asks for: it cannot see a path from in here and answers `Response` 2 for `file://` (measured, while https answered 0). The shim leaves those in `home/.plwl/open-request` (written as `.part` and renamed, so nothing ever reads half a request) — a live bind of the app's home, so it reaches an app that is ALREADY running — and the launcher opens it out here with the host's own `xdg-open` (openrelay.js: `createOpenRelay` watches that folder for exactly as long as the app runs, consumes each request once, and quits watching on exit). The target is rewritten on the way out — the private `$HOME` back to `{prefix}/linux_pfx/home`, `FS_ROOT` back to `/` at relaxed — so the host opens the REAL folder and never a path that only exists inside. Nothing in the sandbox can start a host program itself: measured, the host's own `xdg-open` run in there ends in `kde-open`, which exits 0 and opens no window at all. A scheme nothing on the host claims ends in the desktop's own "choose an application" dialog, which is the point of handing it out instead of guessing. +- The portal's `Response` is NOT read back: it is a signal addressed to the caller's own bus connection, so a separate `gdbus monitor` never receives it (measured: 15 calls, 15 timeouts, while the portal did open what it was given) and the readback only cost the app 3 s per click before giving up. Only whether the call went out is trusted, so a machine without a portal needs no special case any more: the call fails, and the request file is what still lands. (0.5.x had the host's own script parked inside the sandbox as the shim's fallback; measured, that route opens nothing.) +- A file handed over (a shortcut's `--file %f`, a drop on it) is the one path the sandbox cannot see by itself: a file out of the user's home is buried under the prefix home, one out of `/tmp` sits behind the private tmpfs, and the rest of the machine is read-only. Per-file `--bind` (what 0.5.0 did) is the wrong tool: a mount cannot be added to a namespace that is ALREADY running, so a hand-off into a running app could never be served that way. `handedPathFor` instead names the document in the one shape the chosen level can reach, and the app is told nothing else: `none` → the real path; `relaxed` → `FS_ROOT` + the real path; `isolated` → a copy in `{prefix}/linux_pfx/home/plwl-handoff/`, which is a live bind of the app's home, so it reaches a running app too (measured end to end in test/linux-e2e.js: both levels hand a document to a sandbox that is already up). Copies are one per name and refreshed on every open (the folder cannot grow), written through a `.part` name and renamed so nothing ever reads a half-written document, and the app's edits stay in the copy — that IS the level's promise. A handed path that is gone fails the hand-off instead of launching an app with no document. +- `FS_ROOT` (`/tmp/plwl-fs-root`) is where relaxed mounts the host filesystem, and it has to live under the private `/tmp`: bubblewrap creates the mount point itself, and the root of a read-only root cannot be written to (measured on 0.12.0: `Can't create file /PLWL_FS_ROOT: Read-only file system`, for a `--dir` before the `--ro-bind / /` too). Measured also: through it the real `~` reads, a write lands on the real file, and a file created AFTER a sandboxed run started is visible inside it — that last one is what makes a hand-off into a running app possible at all. - Not built: a private or overlay `/etc` (`buildBwrapArgs` accepts `etcRoot`, nothing sets it; `--ro-bind / /` leaves `/etc` read-only, which is all we promise today), `--tmpfs /home` against OTHER users' homes (`hideHome` is plumbed, no UI) and `dataMode` — app data always lands in `{prefix}/linux_pfx`. - Measured, not assumed (Debian 13, kernel 6.12, `bwrap` 0.12.0): the functional probe passes here, no firejail/proot/fuse-overlayfs on the box, `/etc` is 16 MB and its `machine-id` is read-only even on the host. @@ -129,11 +140,13 @@ node test/lansync-pending-links.test.js # links to files created later, startup node test/lansync-consent.test.js # accept / decline / timeout gate node test/lansync-token.test.js # long-sync token expiry (sliding TTL) node test/bench-sync.js # timing: cold vs cached sync -node test/linux-sandbox.test.js # bwrap argv profile + auto/off/require choice +node test/linux-sandbox.test.js # bwrap argv profile + the four levels, handed paths, mode migration node test/linux-env.test.js # redirected HOME/XDG_* for both backends node test/linux-import.test.js # ELF/AppImage/.desktop detection + icons +node test/linux-links.test.js # link opening: shim binds + mime seed +node test/linux-open.test.js # what an app opens: the script + the launcher relay node test/linux-sync.test.js # linux_pfx stays out of a sync -node test/linux-e2e.js # REAL run: plain + bwrap (/etc read-only, home in prefix) +node test/linux-e2e.js # REAL runs: plain, relaxed (+ its mount), isolated, hand-off into a running app npm start # click through the flow you touched # Repairing / testing a real instance (test/ scripts are gitignored helpers): diff --git a/files/translations/en-us.json b/files/translations/en-us.json index bac6a51..f3a5598 100644 --- a/files/translations/en-us.json +++ b/files/translations/en-us.json @@ -93,10 +93,15 @@ "config.openData": "Open data folder", "config.linuxKindValue": "Linux", "config.isolation": "Isolation", - "config.isolation.auto": "Automatic (strongest available)", - "config.isolation.off": "Off (plain run)", - "config.isolation.require": "Required (refuse to run without bwrap)", - "config.isolation.bwrap": "bwrap {0} (strong)", + "config.isolation.auto": "Automatic", + "config.isolation.none": "None", + "config.isolation.relaxed": "Relaxed", + "config.isolation.isolated": "Isolated", + "config.isolationHint.auto": "Relaxed where bubblewrap works; on a machine without it the app runs without isolation.", + "config.isolationHint.none": "No sandbox: the app sees, and may change, everything your user can.", + "config.isolationHint.relaxed": "The whole disk is mounted writable as /tmp/plwl-fs-root.", + "config.isolationHint.isolated": "The system is read-only.", + "config.isolation.bwrap": "bwrap {0} (available)", "config.isolation.env": "no sandbox: {0}", "config.forceX11": "Force X11 (XWayland)", "config.forceX11Hint": "Runs the app through XWayland instead of Wayland. Useful when a window cannot carry its own icon or misbehaves on Wayland.", @@ -109,7 +114,7 @@ "config.overrides.remove": "Remove", "config.overrides.hint": "Wine module names, e.g. dinput8. native,builtin (the default) loads a DLL shipped with the game and falls back to Wine's builtin; disabled blocks the module.", "sandbox.title": "Linux app isolation", - "sandbox.hint": "Native apps always run with a redirected home folder. With bubblewrap they get their own namespaces too: only their home folder and their own app folder stay writable, the rest of the system is read-only.", + "sandbox.hint": "Native apps always run with a redirected home folder, so their config and cache stay in the prefix. The isolation level says what else they get: None is no sandbox at all, Relaxed mounts the whole disk writable, Isolated writes nothing outside the app's own folders and copies an opened file into its home folder.", "sandbox.status": "Status", "sandbox.check": "Check again", "sandbox.rechecked": "Isolation checked again", @@ -118,13 +123,17 @@ "sandbox.reason.timeout": "not responding", "sandbox.reason.failed": "not working", "sandbox.warnTitle": "No sandbox for Linux apps", - "sandbox.warnBody": "bubblewrap is {0}. Linux apps will run with only a redirected home folder - they can still read the rest of your system, and write to anything your user can.", + "sandbox.warnBody": "bubblewrap is {0}. Apps left on Automatic run as plain programs (None), while apps set to Relaxed or Isolated refuse to start instead of pretending the sandbox is there.", "sandbox.dismiss": "Got it", - "sandbox.badgeStrong": "bwrap", - "sandbox.badgeWeak": "no sandbox", - "sandbox.badgeOff": "isolation off", - "sandbox.badgeRequired": "bwrap required", + "sandbox.badgeNone": "No isolation", + "sandbox.badgeRelaxed": "Relaxed", + "sandbox.badgeIsolated": "Isolated", + "sandbox.badgeRequired": "Bwrap required", + "handoff.copying": "Copying into the app: {0}", + "handoff.copyNote": "{0} / {1} - the app works on a copy inside its own home folder (plwl-handoff); edits in the copy never come back.", + "handoff.failed": "Could not copy {0} into the app: {1}", "sandbox.required": "This app needs a working bubblewrap sandbox: {0}", + "sandbox.linkOpener": "PLWL link opener", "config.save": "Save changes", "config.shortcut": "Create shortcut", "config.shortcutCreated": "Shortcut for {0} created (menu + desktop)", diff --git a/files/translations/pl.json b/files/translations/pl.json index 470e7c4..6447804 100644 --- a/files/translations/pl.json +++ b/files/translations/pl.json @@ -93,10 +93,15 @@ "config.openData": "Otwórz folder danych", "config.linuxKindValue": "Linux", "config.isolation": "Izolacja", - "config.isolation.auto": "Automatyczna (najmocniejsza dostępna)", - "config.isolation.off": "Wyłączona (zwykłe uruchomienie)", - "config.isolation.require": "Wymagana (odmów bez bwrap)", - "config.isolation.bwrap": "bwrap {0} (mocna)", + "config.isolation.auto": "Automatyczna", + "config.isolation.none": "None", + "config.isolation.relaxed": "Relaxed", + "config.isolation.isolated": "Isolated", + "config.isolationHint.auto": "Relaxed, gdy bubblewrap działa; na maszynie bez bwrap aplikacja uruchamia bez izolacji.", + "config.isolationHint.none": "Bez sandboxa: aplikacja widzi i może zmienić wszystko, do czego ma prawo Twój użytkownik.", + "config.isolationHint.relaxed": "Cały dysk podmontowany zapisywalnie jako /tmp/plwl-fs-root.", + "config.isolationHint.isolated": "System tylko do odczytu.", + "config.isolation.bwrap": "bwrap {0} (dostępny)", "config.isolation.env": "brak sandboxa: {0}", "config.forceX11": "Wymuś X11 (XWayland)", "config.forceX11Hint": "Uruchamia aplikację przez XWayland zamiast Waylanda. Przydatne, gdy okno nie potrafi mieć własnej ikony albo źle działa na Waylandzie.", @@ -109,7 +114,7 @@ "config.overrides.remove": "Usuń", "config.overrides.hint": "Nazwy modułów Wine, np. dinput8. native,builtin (domyślne) wczytuje DLL dołączony do gry, a gdy go nie ma — wbudowany Wine; disabled blokuje moduł.", "sandbox.title": "Izolacja aplikacji Linux", - "sandbox.hint": "Natywne aplikacje zawsze działają z przekierowanym folderem domowym. Z bubblewrap dostają dodatkowo własne przestrzenie nazw: zapisywać można tylko w swoim folderze domowym i w swoim folderze aplikacji, reszta systemu jest tylko do odczytu.", + "sandbox.hint": "Natywne aplikacje zawsze działają z przekierowanym folderem domowym - ich config i cache zostają w prefiksie. Poziom izolacji mówi, co jeszcze dostają: None to brak sandboxa, Relaxed daje cały dysk zapisywalny, a Isolated nie pozwala zapisać niczego poza folderem aplikacji i kopiuje otwierane pliki do jej folderu domowego.", "sandbox.status": "Status", "sandbox.check": "Sprawdź ponownie", "sandbox.rechecked": "Sprawdzono izolację ponownie", @@ -118,13 +123,17 @@ "sandbox.reason.timeout": "nie odpowiada", "sandbox.reason.failed": "nie działa", "sandbox.warnTitle": "Brak sandboxa dla aplikacji Linux", - "sandbox.warnBody": "bubblewrap {0}. Aplikacje linuksowe będą działać tylko z przekierowanym folderem domowym - nadal mogą czytać resztę systemu i pisać wszędzie, gdzie pozwala Twój użytkownik.", + "sandbox.warnBody": "bubblewrap {0}. Aplikacje ustawione na Automatyczną uruchomią się jak zwykłe programy (None), a te ustawione jawnie na Relaxed albo Isolated odmówią startu, zamiast udawać, że sandbox działa.", "sandbox.dismiss": "Rozumiem", - "sandbox.badgeStrong": "bwrap", - "sandbox.badgeWeak": "bez sandboxa", - "sandbox.badgeOff": "izolacja wyłączona", - "sandbox.badgeRequired": "wymaga bwrap", + "sandbox.badgeNone": "Bez izolacji", + "sandbox.badgeRelaxed": "Relaxed", + "sandbox.badgeIsolated": "Isolated", + "sandbox.badgeRequired": "Wymaga bwrap", + "handoff.copying": "Kopiowanie do aplikacji: {0}", + "handoff.copyNote": "{0} / {1} - aplikacja pracuje na kopii w swoim folderze domowym (plwl-handoff); zmiany w kopii nie wracają do oryginału.", + "handoff.failed": "Nie udało się skopiować {0} do aplikacji: {1}", "sandbox.required": "Ta aplikacja wymaga działającego sandboxa bubblewrap: {0}", + "sandbox.linkOpener": "PLWL - otwieranie linków", "config.save": "Zapisz zmiany", "config.shortcut": "Utwórz skrót", "config.shortcutCreated": "Skrót dla {0} utworzony (menu + pulpit)", diff --git a/renderer/app.js b/renderer/app.js index 108108c..a49e8eb 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -335,11 +335,24 @@ class CustomSelect { if (this.disabled) return const wasOpen = this.host.classList.contains('open') CustomSelect.closeAll() - if (!wasOpen) this.host.classList.add('open') + if (!wasOpen) { + this.host.classList.add('open') + this.lift() + } + } + + // the transform on every element (see style.css) makes each one its own + // stacking context, so an ancestor wrapper would still paint the open list + // under the rows that follow it; positioned ancestors already stack right + lift() { + for (let el = this.host.parentElement; el && el !== document.body; el = el.parentElement) { + if (getComputedStyle(el).position === 'static') el.classList.add('select-lift') + } } close() { this.host.classList.remove('open') + CustomSelect.unlift() } setValue(v) { @@ -358,6 +371,11 @@ class CustomSelect { static closeAll() { qsa('.custom-select.open').forEach(el => el.classList.remove('open')) + CustomSelect.unlift() + } + + static unlift() { + qsa('.select-lift').forEach(el => el.classList.remove('select-lift')) } } @@ -434,12 +452,21 @@ function isolationStatusText(status) { return t('config.isolation.env', t('sandbox.reason.' + (status.reason || 'failed'))) } -function isolationBadge(game) { +// The badge names the level the app would really run at, not the policy: +// automatic is a choice, and what it resolves to depends on this machine. +function isolationLevel(game) { const policy = (game && game.isolation) || 'auto' - if (policy === 'off') return `${t('sandbox.badgeOff')}` - if (sandboxStrong()) return `${t('sandbox.badgeStrong')}` - if (policy === 'require') return `${t('sandbox.badgeRequired')}` - return `${t('sandbox.badgeWeak')}` + if (policy === 'none') return 'none' + if (policy === 'auto') return sandboxStrong() ? 'relaxed' : 'none' + return sandboxStrong() ? policy : 'unavailable' +} + +function isolationBadge(game) { + const level = isolationLevel(game) + if (level === 'none') return `${t('sandbox.badgeNone')}` + if (level === 'unavailable') return `${t('sandbox.badgeRequired')}` + if (level === 'isolated') return `${t('sandbox.badgeIsolated')}` + return `${t('sandbox.badgeRelaxed')}` } // Portable apps show files/-relative paths; external apps keep absolute ones. @@ -936,6 +963,36 @@ function wireOpenWith() { window.plwl.openwithTake().then(handleOpenWith) } +// --- isolated hand-off ------------------------------------------------------- + +// A document handed to an isolated app is copied in first. Only copies big +// enough to be noticed arrive here (main decides, and puts a window up so this +// popup can be seen at all). +function wireHandoffProgress() { + window.plwl.onHandoffProgress(data => { + if (!data || !data.notice) return + if (data.phase === 'copy') return showHandoffCopy(data) + if (data.phase !== 'done' && data.phase !== 'error') return + // only ever close our own modal: another one may have opened over it + if (qs('#modal').querySelector('#ho-progress')) closeModal() + if (data.phase === 'error') toast(t('handoff.failed', data.name, data.error || ''), 'error') + }) +} + +function showHandoffCopy(data) { + const modal = qs('#modal').querySelector('#ho-progress') + ? qs('#modal') + : showModal(` +

${t('handoff.copying', data.name)}

+
+

+ `) + renderProgressBar(modal.querySelector('#ho-progress'), data.bytes, data.totalBytes) + const pct = modal.querySelector('.progress-pct') + pct.textContent = data.totalBytes ? Math.round(((data.bytes || 0) / data.totalBytes) * 100) + '%' : '' + modal.querySelector('#ho-status').textContent = t('handoff.copyNote', formatBytes(data.bytes), formatBytes(data.totalBytes)) +} + // Import step 2: register the app in place, nothing is copied. async function doPrefixImport(prefix, srcDir) { const name = srcDir.split('/').filter(Boolean).pop() @@ -1314,14 +1371,24 @@ async function openGameConfig(id) { const isolationOptions = () => [ { value: 'auto', label: t('config.isolation.auto') }, - { value: 'off', label: t('config.isolation.off') }, - { value: 'require', label: t('config.isolation.require') } + { value: 'none', label: t('config.isolation.none') }, + { value: 'relaxed', label: t('config.isolation.relaxed') }, + { value: 'isolated', label: t('config.isolation.isolated') } ] +// The level names are one word each - what they mean has to be spelled out +// right under the select, because the price of relaxed is not visible anywhere +// else in the UI. +function renderIsolationHint(value) { + qs('#gc-isolation-hint').textContent = t(`config.isolationHint.${value || 'auto'}`) +} + function renderIsolationOptions(selected) { const opts = isolationOptions() - if (!selects['gc-isolation']) selects['gc-isolation'] = new CustomSelect(qs('#gc-isolation'), opts, selected) - else selects['gc-isolation'].update(opts, selected) + if (!selects['gc-isolation']) { + selects['gc-isolation'] = new CustomSelect(qs('#gc-isolation'), opts, selected, renderIsolationHint) + } else selects['gc-isolation'].update(opts, selected) + renderIsolationHint(selected) } async function createAppShortcut() { @@ -2096,6 +2163,7 @@ async function boot() { wireEvents() wireRealtime() wireOpenWith() + wireHandoffProgress() wireLanSync() qs('#loading').remove() qs('#main').style.display = 'flex' diff --git a/renderer/index.html b/renderer/index.html index cb4bea1..4f521cc 100644 --- a/renderer/index.html +++ b/renderer/index.html @@ -206,6 +206,7 @@