AFAIK (and I can be totally wrong here) screen grabbing is part of the Wayland protocol, but most (all?) compositors restrict which processes are allowed to use that API. For Sway (which is what I use), I've seen a separate config file for this. So it might be worth taking a look at the documentation for your compositor.