Skip to content

feat(better-files): Linux support for Open in, default app and file manager - #39

Open
nocstah wants to merge 1 commit into
munza:mainfrom
nocstah:better-files-linux
Open

nocstah wants to merge 1 commit into
munza:mainfrom
nocstah:better-files-linux

Conversation

@nocstah

@nocstah nocstah commented Nov 19, 2026

Copy link
Copy Markdown

What's wrong on Linux

window().platform is "linux" there, and everything that isn't Windows takes the macOS commands:

  • mdfind isn't installed, so Open in never offers an editor.
  • Open in default app, Show in Finder and the folder menu's Open in Finder run open, which isn't installed either. They show for a local space and fail when clicked.

What this changes

All of it goes through files/shell.js, like the Windows support in #32. The macOS and Windows commands are unchanged, and their byte-for-byte tests still pass.

  • Editors. Each built-in editor gets bins, its commands on Linux: zeditor/zed (Arch ships both, Zed's own installer zed), code/code-oss, cursor, windsurf, subl. One sh run looks them up on PATH, first found wins, and prints the same name\0path\0 pairs as the Windows probe, so findEditors stays as it is. Only an absolute path counts, and only plain command names are passed. The path it found is run with the file. An extra editor in settings.editors with bins is looked up too.
  • Open in default app: gio open, which returns once the app has started. Without gio, xdg-open runs under setsid -f. On a desktop xdg-open doesn't know (Hyprland, Sway…) it runs the app in the foreground until it closes, which would outlast exec's 30-second timeout.
  • Show in file manager: org.freedesktop.FileManager1.ShowItems over dbus-send, which Nautilus, Dolphin, Nemo and others answer. The file:// URI encodes every part, since dbus-send splits an array at commas. If no file manager answers, the folder opens instead.
  • Labels say Show in file manager and Open in file manager on Linux.
  • README and RECIPE describe the Linux behaviour.

Testing

  • node --test better-files/tests/*.test.cjs: 121 pass, 10 of them new. The new tests run the Linux scripts for real against stand-in programs on a PATH of their own, so they also pass on macOS. The setsid one skips where setsid is missing.
  • node --test site/tests/*.test.cjs passes.
  • herdr-app check passes.
  • In Herdr Desktop 0.1.16 on Arch Linux (Hyprland, Nautilus), the installed mod found Zed at /usr/bin/zeditor. Against the real session bus, dbus-send accepts the ShowItems arguments, and Nautilus provides ShowItems(as, s).

Notes

  • mod.schema.json describes editors as an array of strings (macOS app IDs), while the README and code use objects (bundle, exe, now bins). I left the schema as it is.
  • I haven't bumped mod.json's version, so you can choose it.

🤖 Generated with Claude Code

…anager

On Linux, `window().platform` is "linux", which fell through to the macOS
commands: `mdfind` isn't there, so Open in never offered an editor, and
Open in default app, Show in Finder and the folder menu ran `open`, which
isn't there either, and failed.

- Editors: each built-in editor gets `bins`, its commands on Linux
  (`zeditor`/`zed`, `code`/`code-oss`, `cursor`, `windsurf`, `subl`).
  One `sh` run looks them up on PATH, first found wins, and emits the
  same name\0path\0 pairs as the Windows probe; the path is run with the
  file. Extra editors with `bins` are looked up too.
- Open in default app: `gio open`, which returns once the app starts.
  Without gio, `xdg-open` under `setsid -f`, since on desktops it doesn't
  know (Hyprland, Sway) it runs the app in the foreground until it closes.
- Show in file manager: org.freedesktop.FileManager1.ShowItems over
  `dbus-send` (Nautilus, Dolphin, Nemo and others), with the URI
  percent-encoded so a comma can't split the array; with no file manager
  answering, the folder opens instead.
- Labels say "file manager" on Linux. macOS and Windows commands are
  unchanged, and their byte-for-byte tests still pass.

Tests run the Linux scripts for real against stand-in programs on a PATH
of their own, so they pass on macOS too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant