How to correctly do background tasks from a flatpak app?

Hi all!

I just started working on an app that enables setting different wallpapers for multi monitor systems, and I would also like to add the option for showing a slideshow of wallpapers (changing the wallpaper at a configurable interval). For this feature, I assume the app would have to keep running, or at least have a daemon running in the background. I want to use flatpak for this application, so the way to go in that case is probably the background portal.

However, I was wondering if this is a logical approach? My consideration is that this would require the whole application (currently a python + GTK4 + Libadwaita app) to be running and loaded in ram, just to change the wallpapers every X minutes. Would this be a resource hog? Is it possible to make a flatpak app that only has a minimal part that runs in the background, and only loads the GTK stuff when the GUI is launched? This could all be premature optimization, but I don’t want to end up with something massively inefficient.

I also have some experience in vala, so I could switch languages to that, or C / Rust.

Thanks for your time, I would love the advice of people more experienced with the ecosystem!