Skip to content

portal: external source picker (SHOJIWM_PORTAL_PICKER) - #238

Open
sachahjkl wants to merge 3 commits into
bea4dev:mainfrom
sachahjkl:feat/portal-external-picker
Open

sachahjkl wants to merge 3 commits into
bea4dev:mainfrom
sachahjkl:feat/portal-external-picker

Conversation

@sachahjkl

Copy link
Copy Markdown
Contributor

The ScreenCast portal shows its own picker window (iced). A desktop built on ShojiWM may want the choice to look like the rest of its UI, so this lets it provide the picker as a command.

When SHOJIWM_PORTAL_PICKER is set (read once at startup), each SelectSources runs that command through sh -c instead of opening the iced window:

  • The portal writes one JSON object on the command's stdin, then closes it:
    {"app_id": "org.example.App", "prefer": "window",
     "sources": [
       {"id": "DP-1", "kind": "output", "name": "DP-1", "description": "...", "x": 0, "y": 0, "width": 2560, "height": 1440, "refresh_mhz": 144000},
       {"id": "<ext_foreign_toplevel identifier>", "kind": "window", "title": "...", "app_id": "..."}
     ]}
    prefer is window when only windows are asked for.
  • The command prints the chosen source's id on its first stdout line and exits 0.
  • A non-zero exit, empty output or unknown id cancels. If the session is closed while the command runs, the command is killed (kill_on_drop).

Without the variable nothing changes. The requesting app id is now passed to PickerHandle::pick; the iced path does not use it. The variable and the protocol are documented in the installation page (English only; I did not touch the Japanese translation).

Tests: four unit tests in external_picker.rs run real sh commands: a choice read from the request, a failed exit, an unknown id, and a cancelled session that must stop a running picker (bounded by a timeout). I use it with a desktop's own dialog (shojiwm-desktop) that speaks this protocol; I have tested that dialog against the same JSON, but not yet through a full ScreenCast session from a browser.

sachahjkl added a commit to sachahjkl/ShojiWM that referenced this pull request Nov 12, 2026
@sachahjkl
sachahjkl force-pushed the feat/portal-external-picker branch from a3ff38f to 97ce7d4 Compare November 16, 2026 22:10
When SHOJIWM_PORTAL_PICKER is set, the ScreenCast portal runs that command
instead of the built-in iced picker: it writes the sources as one JSON object
on the command's stdin and reads the chosen source id from its stdout. A
non-zero exit, empty output or unknown id cancels; a closed session kills the
command. A desktop built on ShojiWM can then show a chooser in its own look.
@sachahjkl
sachahjkl force-pushed the feat/portal-external-picker branch from 97ce7d4 to e5b53d7 Compare November 21, 2026 16:29

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