azymohliad / watchmate

PineTime smart watch companion app for Linux phone and desktop
GNU General Public License v3.0
136 stars 4 forks source link

Run in background doesn't work for Flatpak on Phosh #50

Closed darkdragon-001 closed 8 months ago

darkdragon-001 commented 8 months ago

This should be possible to support since xdg-drsktop-portal 1.16.0.

azymohliad commented 8 months ago

Hi, thanks for the report. Can you share some more details about your system? Which DE/WM do you use (to understand what's your xdg-desktop-portal backend)?

Also, how exactly does it not work? Does the "Run in background" switch turns back off when you try to turn it on? Or does the switch stays on, but the app then just doesn't keep running in the background when you close the window? Do you have any errors in the output if you run it form the terminal?

It does perform the background portal request when you toggle the switch, so it implements what's needed for a sandboxed app to run in the background. It also works well for me in GNOME 45, so I'm guessing the background request might be handled differently by your xdg-desktop-portal backend.

darkdragon-001 commented 8 months ago

Thanks for the info. I am running on Pinephone with Mobian using Phosh. The switch turns back off when I try to turn it on. Maybe it's not implemented there?

azymohliad commented 8 months ago

Ok, interesting, thanks. I'm not sure. When you have time, could you please try the following?

  1. Run it form the terminal, and see if you have "Background portal request failed" error in the output.
    flatpak run io.gitlab.azymohliad.WatchMate
  2. Manually grant the background permission, check if everything works then:
    flatpak permission-set background background io.gitlab.azymohliad.WatchMate yes
  3. If no, manually override the background setting, see if it can run in the background after that:
    flatpak enter io.gitlab.azymohliad.WatchMate gsettings --schemadir /app/share/glib-2.0/schemas set io.gitlab.azymohliad.WatchMate run-in-background true
darkdragon-001 commented 8 months ago
  1. Run it form the terminal, and see if you have "Background portal request failed" error in the output.
flatpak run io.gitlab.azymohliad.WatchMate
[Error watchmate::ui::settings_page] Background portal request failed: ZBus Error: org.freedesktop.DBus.Error.UnknownMethod: No such interface "org.freedesktop.portal.Background" on object at path /org/freedesktop/portal/desktop
  1. Manually grant the background permission, check if everything works then:
flatpak permission-set background background io.gitlab.azymohliad.WatchMate yes

Same problem.

I also checked in Flatseal and the toggle is greyed out there as well.

  1. If no, manually override the background setting, see if it can run in the background after that:
flatpak enter io.gitlab.azymohliad.WatchMate gsettings --schemadir /app/share/glib-2.0/schemas set io.gitlab.azymohliad.WatchMate run-in-background true

I could run this while the app was running, but when I closed the window, the process stopped. Don't know how the run in background should work or what Phosh is doing when one swipes a window up to close.

Thanks for your help anyways. Probably I just have to wait for Phosh to implement the necessary functionality. Feel free to close if you don't have any further ideas.

azymohliad commented 8 months ago

Ok, so the portal isn't implemented on Phosh (yet?). Still, I think Watchmate should actually allow to toggle the setting if the portal isn't implemented, because the permission might not be needed then. And I just realized, the 3rd step I suggested doesn't actually toggle it properly at runtime. Could you please try if this build helps? If yes, I'll release v0.5.1 with the fix soon, probably tomorrow

azymohliad commented 8 months ago

Ouch, sorry, i'm dumb. I just built it for x86, completely forgot we're talking about the PinePhone. I'll cross-compile it on Flathub CI later today.

I'd test it myself as well, but I just discovered my PinePhone doesn't show any signs of life, after a few months of lying in the drawer (it seems to charge, but doesn't turn on)

azymohliad commented 8 months ago

Didn't manage it yesterday, but here's the Flathub CI build that enables the background mode setting even if background portal is not implemented:

flatpak install --user https://dl.flathub.org/build-repo/62591/io.gitlab.azymohliad.WatchMate.flatpakref

If you could try it whenever you have time, I'd be grateful!

darkdragon-001 commented 8 months ago

Seems to work (I can activate the setting, when I close the window the process continues and when I run it again then the window reappears and the second process finishes immediately as it only triggers the window on the first process)! Thanks a lot!

azymohliad commented 8 months ago

Nice, thank you for your help! I'll release it later today

azymohliad commented 8 months ago

I released v0.5.1, it should be on Flathub in a few hours