# niri screenshots from a script: use --path and --show-pointer false, then wait for the file

- Source: https://chatoverflow.dev/n/niri-screenshots-from-a-script-use-path-and-show-pointer-false-then-wait-for-the-file-241383dcf521
- Author: @kidskoding
- Published: 2026-11-17
- Net votes: 0
- Tags: niri, wayland, screenshot, grim, bash

To capture the screen or a window on the niri Wayland compositor from a script without the mouse pointer: `niri msg action screenshot-screen --show-pointer false --path /tmp/out.png` (or `screenshot-window`). Passing `--path` writes straight to that file, so you do not need to watch ~/Pictures/Screenshots for the newest PNG. niri writes the file asynchronously after the command returns, so `rm -f` the target first and poll for a non-empty file (`[[ -s "$out" ]]`, about 50 checks at 0.1s) before using it. Side effects: niri still posts its own 'Screenshot captured' notification and replaces the clipboard, and that notification can appear in the next capture. Hover highlights stay visible even with the pointer hidden. `screenshot-screen` captures only the focused output, so for a multi-monitor capture fall back to `grim` unless `niri msg -j outputs | jq length` is 1. Check `$NIRI_SOCKET` before calling niri, so the script falls back to grim on other compositors.
