theironrobin / siglo

GTK app to sync InfiniTime watch with PinePhone
Mozilla Public License 2.0
153 stars 23 forks source link

Subprocess and systemctl issues in Flatpak #80

Open Torbuntu opened 3 years ago

Torbuntu commented 3 years ago

Version: 0.9.0 Install: Flathub's flatpak OS: Fedora Mobile Remix

When selecting a device in siglo and the Keep paired toggle is active, Siglo throws an errors in the console:

Traceback (most recent call last):
  File "/app/share/siglo/siglo/window.py", line 209, in on_watches_listbox_row_activated
    subprocess.Popen(["systemctl", "--user", "start", "siglo"])
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1706, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'systemctl'

I'm thinking that this means flatpak can't make calls directly to systemcl.

I did quickly find this article: https://gabmus.org/posts/making-a-dbus-daemon/ which lays out how to setup a daemon in a flatpak using python. Hopefully something in there can be of use?

Let me know if I can help collect any other information.

theironrobin commented 3 years ago

@jwillikers i just want to run systemctl in a subprocess. is this a quick fix to get it working on flatpak?

jwillikers commented 3 years ago

@alexr4535 Not without subverting the sandbox by allowing arbitrary code execution on the host. There's an existing Flatpak issue, flatpak/flatpak#2787, regarding this kind of thing, but a solution for Systemd isn't available yet. I know GTK/GNOME exposes functions for running in the background, which should integrate nicely with Flatpak, like this comment mentions. I think there's way that GTK Flatpaks like GNOME Boxes, Geary, and NewsFlash accomplish this which integrates with the Background portal. I can look more into this when I get time.

theironrobin commented 3 years ago

Thanks, I've added a warning to the readme that SMS notifications are broken currently in the flatpak version

jwillikers commented 3 years ago

The graphical apps that I mentioned seem to run in the background by hiding their main window when it is closed instead of exiting the application. This combined with the background portal should be enough run continually in the background, granted this doesn't provide service management in case of a crash. A Systemd user unit could be provided to users to manually install / enable for running the Flatpak'd Siglo app as a Systemd service until this is possible in Flatpak itself.

WhyNotHugo commented 2 years ago

When selecting a device in siglo and the Keep paired toggle is active,

Thanks for mentioning this, I was at a dead end and hadn't realised that turning the toggle off fixed it.

WhyNotHugo commented 2 years ago

Siglo tries to run systemctl, but that's not installed its package/image. There's two potential fixes for this: