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

Support installation in Flatpaks. #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gebner
Copy link

@gebner gebner commented Nov 14, 2023

Running the current installer doesn't work for the Flatpak version of Firefox no matter whether you run it inside the sandbox or outside on the host. The .mozilla and .local directories are different in the sandbox, running the script outside the sandbox simply has no effect whatsoever. Running it inside the sandbox doesn't work either, the .local directory is wiped on restart and the HOME environment variable is unset. (There are installation instructions in the main Tridactyl readme that claim to work for the Flatpak version, but they simply don't.)

This PR makes it possible to successfully install the native messenger in the Flatpak version of Firefox:

curl -fsSl https://raw.githubusercontent.com/gebner/native_messenger/flatpak/installers/install.sh | bash

(You can also run the installer inside the sandbox, using flatpak enter org.mozilla.firefox bash. This didn't work either.)

There are two challenges here:

  • The .local directory inside the sandbox is not persisted, i.e., it gets wiped every time you restart Firefox. Therefore the PR installs the native binary in ~/.mozilla/native-messaging-hosts/ instead of ~/.local/share.
  • The .mozilla directory inside the sandbox is bind-mounted from ~/.var/app/org.mozilla.firefox/.mozilla/ on the host, so the installer needs to know about both the host and sandbox paths. The PR changes the installer to put the native messenger in both the ~/.mozilla and all ~/.var/app/*/.mozilla directories it can find.

This is required in the Flatpak version of Firefox, which wipes
`~/.local` every time Firefox is restarted, and only `~/.mozilla` is
persisted.
Copy link
Member

@bovine3dom bovine3dom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for figuring this out, people have been struggling with Flatpak for ages. Please see the few comments I have made :)

Do you know if this will fix it for the Snap packages too? If not, would it be easy to adapt it?

Comment on lines -94 to -97

echo
echo "Successfully installed Tridactyl native messenger!"
echo "Run ':native' in Firefox to check."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this message is confusing, but I'd rather we improved it rather than removed it totally.

E.g. Tridactyl native messenger installed; run :native in Tridactyl to check that it works

# `~/.mozilla/native-messaging-hosts` as well, because everything outside
# of `~/.mozilla` is wiped when restarted.
native_binary_name="tridactyl_native_main"
native_file="$manifest_home_on_host/$native_binary_name"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're supposed to put anything except the JSON manifests in this folder but it probably doesn't matter.

Is there a good reason for abandoning the old $XDG_DATA_HOME/.local/share directory on non-flatpak installations?

I can guarantee that some people will have ill-advised scripts that are rely on the location of the executable, e.g. :! ls ../../.. - I would prefer it if we could refrain from breaking them


manifest_file="$manifest_home/tridactyl.json"
native_file="$XDG_DATA_HOME/native_main"
for flatpak_dir in ~/.var/app/*/.mozilla; do
Copy link
Member

@bovine3dom bovine3dom Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit nervous about running this on OSX - could you set a flag around line 36 to skip it on them?

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

Successfully merging this pull request may close these issues.

None yet

2 participants