0

I am a freelancer and my clients need screenshots of all the work I did. So I made a python script which takes screenshots every 7 minutes and this code gets executed automatically when system starts. It worked perfectly in Ubuntu. This is the code.

Now I switched to Fedora34. I have modified my script litte bit which captures screenshots and saves in folders according to date rather than putting all screenshots in one directory. This is my script for Fedora

#!/usr/bin/env python

import pyscreenshot
import time
from datetime import datetime
import os
from pathlib import Path


while True:
    # Get Current time
    now = datetime.now()

    # setting current datetime as image_filename
    image_filename = now.strftime("%b-%d-%Y|%H:%M:%S")

    # Getting month, year and date
    today_month_year = now.strftime("%b-%Y")
    today_date = now.strftime("%d")

    new_directory = os.path.join(r"ss/",
                                 str(today_month_year),
                                 str(today_date))
    
    # Create folders safely
    Path(new_directory).mkdir(parents=True, exist_ok=True)
    
    # To capture the screen
    image = pyscreenshot.grab()

    # To save the screenshot
    image.save(new_directory + "/" + str(image_filename)  + ".png")

    # Each screenshot Every 7 minutes
    time.sleep(420)

And fedora does not have Startup Applications app and gnome-tweaks > Startup Applications does not support custom scripts. So I searched at many sites and came to conclusion that I can create a service file. And I created a service file to start my script at startup with following code:

File: /etc/systemd/system/screenshots.service

[Service]
WorkingDirectory=/home/<uname>/path
ExecStart=/bin/sh -c 'cd /home/<uname>/path/ && source env/bin/activate && ./auto-ss.py'

Now when I run sudo systemctl start screenshots, it does not throw any error but running sudo systemctl status screenshots throws following error:

pyscreenshot.err.FailedBackendError: All backends failed!

According to this answer

PyScreenshot is for taking screenshots of desktop applications. Since your application is running on a server, there's nothing to take a screenshot of. If you intended to take a screenshot of the user's browser, you would use frontend tooling, which runs in the browser, not a server-side tool.

If this is the problem, how can I run my python app as frontend. And if its some other problem, how can I overcome it?

Can anyone help me. I am stuck on this since very long :( . Well, thanks in advance :)

ajinzrathod
  • 925
  • 10
  • 28

1 Answers1

0

If it works on Ubuntu and doesn't work for Fedora, the sure way to fix it is to mimic Ubuntu on Fedora (i.e. via desktop environments). Ubuntu uses gnome. So, your best bet is to use gnome on Fedora too.

Please have a look at these links:

What is the recommended way to install Gnome on Fedora 30 Server?

Install Gnome 3 in Fedora 22 KDE Spin

Fedora 32: Gnome Desktop

Joshua
  • 551
  • 4
  • 13