Remove popup and sound when taking a screenshot in gnome extension

When a screenshot is taken in the gnome extension via the captureScreenshot function, a window pops up and the typical sound of taking a photo is played.

extension.js:

import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Screenshot from 'resource:///org/gnome/shell/ui/screenshot.js';
import Shell from 'gi://Shell';

export default class ExampleExtension extends Extension {
async enable() {
    const shooter = new Shell.Screenshot();
    const [content] = await shooter.screenshot_stage_to_content();
    const texture = content.get_texture();
    await Screenshot.captureScreenshot(texture, null, 1, null);
}

disable() {
}
}

pop-up window:
server-installatio-packages-on-win10dev

How to take a screenshot quietly, without pop-ups and sounds? How this is done, for example, when an external application takes a screenshot via the dbus API data/org.gnome.Shell.Screenshot.xml · main · GNOME / xdg-desktop-portal-gnome · GitLab. In this case, the screenshot is simply quietly added to the disk and that’s it.

Ubuntu 24.04, GNOME 46, wayland

You have been asking this stuff for a while, now, and you have explained very little about what you want to achieve.

Random applications taking screenshots of the contents of the screen without the user getting any feedback is a quite scary security violation, so it’s unsurprising that the OS is fighting back against it.

Why are you taking screenshot? Why are you trying to associate them with the currently focused applixarion? What kind of application and scenario are you actually implementing?

I described in detail here Getting screenshots and title/application name of a window in ubuntu 22.04 wayland

There is an application that records user activity in the current session, including screenshots. And it should do it quietly, that is, no pop-ups, etc.

on x11 everything works without problems, but on wayland it doesn’t, so I’m trying to transfer this functionality to the gnome extension
@ebassi

There are privacy issues in X11 that allow this kind of ugly things to work.

Wayland architecture is much better in terms of user privacy, and such spywares should not work anymore, as per design. So the behavior you described is expected.
If there was a way to circumvent this, then that would be a bug.

1 Like

But shouldn’t privileged components (like the gnome extension) have the rights to do this? This is not a random application, but part of the gnome shell, if I understand correctly

Is there anyway to disable these notifications? Hearing the characteristic sound of a screenshot every time will be annoying
@gwillems

Maybe you need to use other functions from js/ui/screenshot.js, not captureScreenshot, so that the picture is taken quietly?