Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pantheon Tweaks as an independent GTK app provided through Flatpak #187

Closed
ryonakano opened this issue Jan 4, 2024 · 8 comments · Fixed by #189
Closed

Pantheon Tweaks as an independent GTK app provided through Flatpak #187

ryonakano opened this issue Jan 4, 2024 · 8 comments · Fixed by #189
Assignees

Comments

@ryonakano
Copy link
Member

ryonakano commented Jan 4, 2024

@Philip-Scott What do you think about making Pantheon Tweaks an independent GTK app instead of Switchboard plugin, and providing it using Flatpak instead of PPA? Or should we keep as it is?

Problem

I think the current Tweaks have some problems:

  • Not easy and not recommended way to install.
    • Tweaks is provided through PPA and requires add-apt-repository command, which is not a recommended way to install apps by elementary team.
  • Depends on Switchboard heavily since Tweaks is its plugin.
    • We cannot port to GTK4 nor use Flatpak until Switchbnoard itself begins to use them.
    • Tweaks would die if elementary team drop plugin feature from Switchboard.
  • Difficult to support multiple elementary OS versions.
    • Some users report "can't install" issue like Install failure on latest eos 6 build #61 due to older dependency version, etc.
    • It's difficult to keep supporting multiple elementary OS major versions if there are API breaking changes.
  • Sometimes PPA management is required.

Fix

To resolve these issues above, I think we may want to:

  • Make Tweaks an independent app instead of a plugin of Switchboard.
    • which allows us to port to GTK4 anytime soon.
  • Provide Tweaks using Flatpak instead of .deb file / PPA.
    • Flatpak is recommended by elementary team and easy to install.
    • No need to consider differencies of host OS version.

I've created an experiment branch research/as-independent-app to confirm possibility of implementation. If possible, I'd like you to install and try this branch on elementary OS. I'll create a pull request from this branch with additional fix (e.g. README things) if you agree with changing to independent Flatpak app.

$ flatpak-builder build --user --install --force-clean --install-deps-from=appcenter com.github.pantheon-tweaks.pantheon-tweaks.yml
$ flatpak run com.github.pantheon_tweaks.pantheon-tweaks

image

@Philip-Scott
Copy link
Member

Hey good plan man, I think it's a good idea to future proof it and it would have the side effect to also make it portable across other OSs without having to depend on Switchboard :)

I was under the impressions that Flatpacks could not modify system settings though, but you got it working, was there a portal/permissions to allow that access?

After this time, I trust that you know what is best for this project, and I will support you in this decision :)

I'll setup a VM with elementary to give your branch a test spin, and when the time comes let me know and I can pull the plug to the PPA to avoid having broken builds

@ryonakano
Copy link
Member Author

ryonakano commented Jan 6, 2024

Thank you for your comment. I'll begin to work on porting Tweaks to the flatpacked GTK app.

it would have the side effect to also make it portable across other OSs without having to depend on Switchboard :)

Yes, you're right. Porting Tweaks into just a normal GTK app also means it can be launched and may break preferences on other desktop environments accidentally, but I think the following things should prevent that:

  • Do not show the Tweaks icon in the app launcher if not Pantheon. This can be fulfilled by setting OnlyShowIn=Pantheon in the .desktop file (and already done in the experiment branch).
  • Check if the current desktop environment is Pantheon on runtime in case a user tries to launch Tweaks from terminal, not from the app launcher. This is not implemented in the experiment branch yet (I forgot to consider 😵 ) but can be fulfilled just by cheking if GLib.Environment.get_variable ("XDG_CURRENT_DESKTOP") returns Pantheon. (FYI it returns ubuntu:GNOME on Ubuntu 23.10)

I was under the impressions that Flatpacks could not modify system settings though, but you got it working, was there a portal/permissions to allow that access?

Yes I was also wondering that. There does not seem to a portal exists here, but dconf-editor which also read/write system GSettings is available on Flathub and they do the following things to fulfill that:

  • Create a wrapper script to launch the app
    • Create a symlink to the system's GSettings file in the sandboxed directory before launching the app and append it to XDG_DATA_DIRS environment variable
    • FYI GLib.Settings uses XDG_DATA_DIRS by default according to the example code on Valadoc
  • Patch dconf
    • The patched code is opening "user-db" of dconf located in ~/.config/dconf/user using g_get_user_config_dir (). However, this function returns the path in the sandbox on Flatpak app.
    • So this patch makes sure to use the host's path instead if sandboxed.

I'll setup a VM with elementary to give your branch a test spin, and when the time comes let me know and I can pull the plug to the PPA to avoid having broken builds

Thank you. Regarding to the PPA, maybe we need to modify debian packaging to install the new flatpaked Tweaks app instead of the Plug like elementary did here in case if a user still attempts a PPA installation. I'll also implement this too.

@ryonakano
Copy link
Member Author

@Philip-Scott One thing I'd like to confirm, do we submit the flatpaked Tweaks to AppCenter or keep it self-hosted?

I read elementary-tweaks/elementary-tweaks#48 (comment) and you're right. Tweaks still read/write system preferences even if it is sandboxed, thus might break system. (also I'm not sure if it's accepted to AppCenter since we need some file access permissions)

Looks like we can create a repo on GitHub according to the doc in case of self-hosted.

@Philip-Scott
Copy link
Member

Philip-Scott commented Jan 6, 2024

Yeah.... I don't think this will ever be accepted on AppCenter 😅 Danielle has always been pretty opposed to tweaks as it can lead to things breaking. I think just hosting on Flathub can be more than enough :)

One thing that would be cool however is if we could get this to be installed on a clean elementary OS install without a user needing to open the terminal at all! Steam-deck-utilities and Emudeck do this by getting the user to download a .desktop file that when executed, downloads and runs a bash script. Just something to consider ;)

I don't know if things could break for existing users if we were to update the PPA to download and install the flatpak... Maybe we can just pause it for now to make things easier and avoid any edge cases 🤔 What do you think?

@ryonakano
Copy link
Member Author

Yeah.... I don't think this will ever be accepted on AppCenter 😅 Danielle has always been pretty opposed to tweaks as it can lead to things breaking. I think just hosting on Flathub can be more than enough :)

You're right. We can submit to Flathub instead.

One thing that would be cool however is if we could get this to be installed on a clean elementary OS install without a user needing to open the terminal at all! Steam-deck-utilities and Emudeck do this by getting the user to download a .desktop file that when executed, downloads and runs a bash script. Just something to consider ;)

elementary OS comes with a tool named Sideload that can install Flatpak apps, so it should work. Flathub provides .flatpakref file for each app, so users just download it, open it in the file manager, and then Sideload is shown like the below screenshot. Installing Flatpak app from .flatpakref also registers Flathub as an app remote, so users can retrieve updates after that time.

VirtualBox_elementary OS_07_01_2024_08_39_26

I don't know if things could break for existing users if we were to update the PPA to download and install the flatpak... Maybe we can just pause it for now to make things easier and avoid any edge cases 🤔 What do you think?

Indeed, just pausing the PPA would lessen risks of "it won't work" issue happening and our tasks. Before pausing PPA, maybe we may want to let users know about the migration to an independent app through the plug? For example, adding a infobar about migration like this, ship that change as the last update, then pause the PPA.

@ryonakano ryonakano mentioned this issue Jan 7, 2024
@ryonakano
Copy link
Member Author

Before pausing PPA, maybe we may want to let users know about the migration to an independent app through the plug? For example, adding a infobar about migration like this, ship that change as the last update, then pause the PPA.

@Philip-Scott I added the infobar to the Tweaks, triggers builds on Launchpad, and it succeeded.

Could you pause the PPA? I guess changing "Build schedule" to "Build on request" in the following page should work.

https://code.launchpad.net/~philip.scott/+recipe/pantheon-tweaks-git

@Philip-Scott
Copy link
Member

PPA has been paused!

image

@ryonakano
Copy link
Member Author

@Philip-Scott Letting you know that Pantheon Tweaks is now on Flathub:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants