Skip to content

fix(screen-toolkit): reliable region captures on niri; add shareLast - #1135

Closed
void314 wants to merge 1 commit into
noctalia-dev:mainfrom
void314:fix/screen-toolkit-niri-region-and-sharelast
Closed

void314 wants to merge 1 commit into
noctalia-dev:mainfrom
void314:fix/screen-toolkit-niri-region-and-sharelast

Conversation

@void314

@void314 void314 commented Oct 24, 2026

Copy link
Copy Markdown

Problem

Three flows broken on Noctalia 5.3.0 + niri:

  1. All region tools (ocr/qr/palette/lens/measure/annotate) — region-file polls the shell's screenshot dir for ~5 s, but with [shell.screenshot] confirm_region enabled the file only lands after the user confirms the dialog, so the pipeline gives up (exit 11) and leaves a plain screenshot behind ("the tool just takes a screenshot").
  2. annotate-fullscreen / annotate-window — the fallback screenshot dir was ~/Pictures/Screenshots, while the v5 shell default is ~/Pictures (screenshot_*.png), so pickup never found the fresh capture.
  3. Annotate while a session is already open — noctalia msg annotate was retried three times against the a screenshot overlay is already active error and surfaced the generic capture-failed toast.

Changes

  • region-file: on niri (NIRI_SOCKET set + slurp + grim available) select the region directly with slurp+grim into /tmp — no confirm-dialog dependency, no pickup race, no stray -region files among the user's screenshots. Other compositors keep the shell-stack path unchanged. Both binaries were already plugin dependencies (region recording uses slurp).
  • shell_dir fallback: ~/Pictures (the actual v5 default) instead of ~/Pictures/Screenshots. An explicit [shell.screenshot] directory still wins, as before.
  • edit: exit 14 on the first "already active" error instead of retrying; the service maps it to a clear already-running notice (reuses the existing panel.running string — no new translations).
  • New shareLast IPC command: share the newest shell screenshot when it is ≤5 min old, otherwise capture a region interactively and share that — what standalone share scripts typically do; useful as a single keybind. Backed by a new newest-shot [maxage-min] shell-capture action. Registered in CAPTURE_STARTS so it discards a pending unsaved recording like other capture tools.

Testing

Noctalia 5.3.0 on niri (plugin API 13 floor unchanged — no new host APIs):

  • annotateFullscreen / annotateWindow via IPC → editor opens, capture picked up.
  • Recording end-to-end (recordFullscreenMp4 → recordStop → recordSave) with wl-screenrec 0.3.2 → valid MP4 in the video dir.
  • shareLast end-to-end → X02 upload, URL in clipboard (uguu fallback path also exercised by the script's own tests).
  • niri region-file fast path exercised with a stubbed slurp geometry (300×200 → correct PNG); the live path reuses the same slurp -f '%x,%y %wx%h' invocation the region recorder already ships.

Region tools (ocr/qr/palette/lens/measure/annotate) polled the shell's
screenshot dir for ~5s, but with [shell.screenshot] confirm_region the
file only lands after the user confirms the dialog, so pipelines gave up
(exit 11) leaving a plain screenshot behind. On niri (NIRI_SOCKET set,
slurp+grim present) region-file now selects directly with slurp+grim
into /tmp: no dialog dependency, no pickup race, no stray -region files.
Other compositors keep the shell-stack path.

The fallback screenshot dir was ~/Pictures/Screenshots while the v5
shell default is ~/Pictures (screenshot_*.png), so fullscreen/window
pickup never found the fresh capture; fix the default.

Annotate while a session is already open now exits 14 at the first
'a screenshot overlay is already active' instead of retrying thrice and
showing the generic failure; the service maps it to a clear notice.

New shareLast command shares the newest shell screenshot (<=5 min) or
falls back to an interactive region capture, mirroring typical
standalone share scripts; backed by a newest-shot [maxage] script
action. Version 1.5.5, README updated.
@github-actions
github-actions Bot marked this pull request as draft October 24, 2026 06:02
@github-actions

Copy link
Copy Markdown
Contributor

This pull request was converted to a draft because its description is missing required
parts of the pull request template.

Missing:

  • the template marker line <!-- noctalia-pr-template:v1 -->
  • the ## Plugin heading
  • the ## What it does heading
  • the ## External dependencies heading
  • the ## Screenshots / Videos heading
  • the ## Checklist heading
  • the ## Code review attestation heading
  • the - **Id:** field
  • the - **Noctalia version tested against:** field
  • the - **Plugin API level:** field
  • the checklist entry: New plugin
  • the checklist entry: Update to an existing plugin (version bumped in plugin.toml)
  • the checklist entry: Tested on Niri
  • the checklist entry: Tested on Hyprland
  • the checklist entry: Tested on Sway
  • the checklist entry: Tested on another compositor:
  • the checklist entry: The directory name matches the part of id after the / in plugin.toml exactly.
  • the checklist entry: It ships plugin.toml, README.md, thumbnail.webp, and translations/en.json.
  • the checklist entry: README.md follows the README template, documents every entry id and dependency, and includes exact panel IPC commands and launcher prefixes where applicable.
  • the checklist entry: thumbnail.webp is present and relevant; for a new plugin I created it with the thumbnail generator, and for an update I regenerated it with the generator if the visual identity or user-facing appearance changed.
  • the checklist entry: version follows semver and is bumped in this PR; plugin_api is the oldest API level this plugin requires.
  • the checklist entry: Every non-English translation in this PR uses a locale supported by Noctalia core, and I can read, write, and understand that language well enough to review and maintain it (no unreviewed machine/LLM translations).
  • the checklist entry: I did not edit catalog.toml; CI generates it.
  • the checklist entry: This PR touches exactly one plugin directory.
  • the checklist entry: The code is readable and not obfuscated, minified, or generated.
  • the checklist entry: It does not download and execute remote code.
  • the checklist entry: Every network call, filesystem write, and spawned process is something the description above accounts for.
  • the checklist entry: I have the right to publish this code under the license declared in plugin.toml.
  • exactly one checked plugin type: New plugin or Update to an existing plugin
  • at least one checked compositor testing entry

Add the items above to the description, keeping their exact wording, then mark the pull
request ready for review. Draft pull requests may leave boxes unchecked. Before a pull
request is ready for review, exactly one plugin type, at least one tested compositor, and
every item under Checklist and Code review attestation must be checked.

Sections that only offer context may be deleted; nothing else about this pull request was
changed.

@github-actions

Copy link
Copy Markdown
Contributor

CC @Ahmed5Emad: this pull request was automatically moved to draft until you have had a chance to look at it. It will be marked ready for review automatically once you reply here.

@void314 void314 closed this Oct 24, 2026
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