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

compatible with "snap" firefox? #81

Open
jhnc opened this issue Sep 15, 2022 · 9 comments
Open

compatible with "snap" firefox? #81

jhnc opened this issue Sep 15, 2022 · 9 comments

Comments

@jhnc
Copy link

jhnc commented Sep 15, 2022

When updating from Ubuntu 20.04 to 22.04, firefox changes from traditional package to a "snap" package.

textern's make native-install USER=1 option assumes that installation should be to ~/.local and ~/.mozilla/.... However, with "snap", the paths are different (and I guess much more).

I see many reports of other software breaking that needs to interact with "snap" or "flatpak" programs.

Is it expected that textern works with "snap" firefox? If so, what is the installation procedure?

@jlebon
Copy link
Owner

jlebon commented Sep 27, 2022

I don't have a system to test this, but if you or someone finds out the right path to use, I'd be happy to accept a patch with possible tweaks to the Makefile and appropriate docs.

@FelixJacobi
Copy link

FelixJacobi commented Oct 18, 2022

Not, it is not, as Native Messaging does not work due the Snap sandbox (Firefox is not allowed to start any executable outside of its sandbox), so it cannot access the editor executable on your system. It would work, if you would install the editor and Textern into the Snap image, which is not possible in practice.

There is an issue in Bugzilla tracking the missing support: 1661935 - Snap does not support NativeMessaging

@FelixJacobi
Copy link

FelixJacobi commented Nov 2, 2022

Update: With the recent update of the Firefox snap, it should work now 🎉 .

To make it work:

  • The Firefox snap does not use ~/.mozilla anymore, the settings directory is now located in ~/snap/firefox/common/.mozilla.
  • I would recommend creating a symlink on the old location:
mkdir -p ~/snap/firefox/common/.mozilla/native-messaging-hosts
mkdir -p ~/snap/firefox/common/.mozilla/firefox
mkdir -p ~/.mozilla
cd ~/.mozilla
ln -s ../snap/firefox/common/.mozilla/firefox
ln -s ../snap/firefox/common/.mozilla/native-messaging-hosts

Run make native-install USER=1 again, restart Firefox and the next time when you press the keyboard shortcut to launch the editor, you should get a permission prompt from your desktop environment to allow Firefox to run the external executable for native messaging.

@jhnc
Copy link
Author

jhnc commented Nov 18, 2022

Thanks! I got it to work with 107.0-2/2088 using @FelixJacobi 's instructions.
I had to manually create ~/snap/firefox/common/.mozilla/native-messaging-hosts/.

I use xfce4-terminal which seems to need the --disable-server option.

Is it expected that empty directories accumulate in /run/user/$(id -u)/textern/ ?

@FelixJacobi
Copy link

I had to manually create ~/snap/firefox/common/.mozilla/native-messaging-hosts/.

Thanks, missed that. I've updated my comment to include these.

@jlebon
Copy link
Owner

jlebon commented Nov 26, 2022

Instead of creating the symlinks, does it work if you do

$ make native-install USER=1 MOZILLA_NATIVE=$HOME/.mozilla/native-messaging-hosts

?

@FelixJacobi
Copy link

Instead of creating the symlinks, does it work if you do

$ make native-install USER=1 MOZILLA_NATIVE=$HOME/.mozilla/native-messaging-hosts

?

Yeah, could work also. I created the symlink, as there are some other applications utilizing native messaging and assuming that native-messaging-hosts is located in ~/.mozilla.

@jlebon
Copy link
Owner

jlebon commented Nov 26, 2022

Ack makes sense. Would appreciate a patch to add instructions for Firefox snaps if anyone is interested (maybe at the same level as https://github.com/jlebon/textern#firejail). Extra points to also cover snaps of editors if it requires any special knowledge (maybe at the same level as https://github.com/jlebon/textern#flatpak). :)

@chubin
Copy link

chubin commented Jan 5, 2023

I have the same problem, probably (or maybe something else, I am not sure).
But I am using Ubuntu with firefox running from /snap/.

What I did:

  1. Installed the extension.
  2. Installed textern using
make native-install USER=1 MOZILLA_NATIVE=$HOME/.mozilla/native-messaging-hosts

Installed and configured my editor (gvim).

After that, I tried to call it with ctrl-shift-d, but nothing happened.
After pressing the key combination again, I received the message "this buffer is being edited" (or similar).

I tried to set touch /tmp/111 instead of gvim, but without success.
The same message (and by the way, I don't know how to cancel this "editing" state).
The file (/tmp/111) was not created.

I also checked the process textern, and I didn't find it among the running processes.

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

No branches or pull requests

4 participants