Gnome-Screenshot

 import subprocess


def take_screenshot(filename="screenshot.png", delay=0):

    try:

        # Construct the command to take a screenshot with gnome-screenshot

        command = ["gnome-screenshot", "--file", filename]


        if delay > 0:

            command.extend(["--delay", str(delay)])


        # Run the command

        subprocess.run(command)

        print(f"Screenshot saved as {filename}")

    except Exception as e:

        print(f"Error occurred: {e}")


if __name__ == "__main__":

    take_screenshot()


Comments