Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

feat: Automatically add support for Flatpak overrides #276

Closed
1 task done
ItsJamie9494 opened this issue Aug 26, 2022 · 3 comments
Closed
1 task done

feat: Automatically add support for Flatpak overrides #276

ItsJamie9494 opened this issue Aug 26, 2022 · 3 comments
Labels
enhancement New feature or request feature-request

Comments

@ItsJamie9494
Copy link

Feature description

Currently, in order to add an override, you have to manually use Flatseal, or run sudo. This, in my opinion, is a bad UX. There's a way to automatically add overrides to Flatpak by modifying a few files.

Adding Overrides to the User

The file located in ~/.local/share/flatpak/overrides/global is how Flatpak reads it's overrides.
If this file is blank or non-existent, it can be replaced by a file containing two lines:

[Context]
filesystems=xdg-config/gtk-3.0;xdg-config/gtk-4.0;

If the file exists with data, appending either the existing filesystems line (a semicolon-delimited list) or adding it will achieve the same effect

Adding Overrides to the Global

The procedure is the same as above, except the file is located at /var/lib/flatpak/overrides/global. This, of course, requires root permissions and changes settings for all users, and probably should not be used as much.

Proposal

During first start, Gradience could ask the user if they would like to automatically enable Flatpak support, adding these lines. Of course, Gradience should also have some way to remove these lines and "disable" Flatpak support.

Additional Context

If you're interested, Flatseal itself does this by checking the values of some environment variables. If these variables do not exist, Flatseal uses the paths I explained above.

You may view these functions at https://github.com/tchx84/Flatseal/blob/master/src/models/applications.js#L34-L60

Another important thing is that the format of the global file is a GLib KeyFile (https://docs.gtk.org/glib/struct.KeyFile.html, https://lazka.github.io/pgi-docs/#GLib-2.0/classes/KeyFile.html), and instead of parsing this file manually, you can use KeyFile functions instead. For example, GLib.KeyFile.get_string_list would return a List of all the values, instead of parsing manually and splitting the file. This is what Flatpak does in their source code

g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,
                            FLATPAK_METADATA_KEY_FILESYSTEMS, NULL, error);

Did you read the Code of Conduct?

@ItsJamie9494 ItsJamie9494 added enhancement New feature or request feature-request labels Aug 26, 2022
@GradienceBot
Copy link
Contributor

Welcome on Gradience. 🥳 We really appreciate your contribution. The core team will review your issue as soon as possible.

@0xMRTT
Copy link
Member

0xMRTT commented Aug 26, 2022

Thanks 👍 will add this soon

@daudix daudix added good first issue Good for newcomers and removed good first issue Good for newcomers labels Aug 26, 2022
0xMRTT added a commit that referenced this issue Sep 1, 2022
This PR adds a preferences window with options for setting overrides in Flatpak aplications.
These changes have, to some extent, features requested in issue #276.

### Changes
- Create new .blp file for preferences window,
- Make `self.settings` object accessible to other files,
- Create new item in `main-menu` menu: `Preferences`

~~I'm setting this PR as a draft for now, to check if everything works as expected~~

Ps. This time, I didn't forget to update `POTFILES` :P
@0xMRTT
Copy link
Member

0xMRTT commented Sep 4, 2022

Fixed 👍

@0xMRTT 0xMRTT closed this as completed Sep 4, 2022
@daudix daudix moved this to Done in Gradience Oct 27, 2022
@daudix daudix added this to Gradience Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feature-request
Projects
Status: Done
Development

No branches or pull requests

4 participants