Hooks are run once system wide rather than once per user. The sandboxing also prevents the hook from accessing data associated with any specific user.
You could adjust things to install to the system wide location /usr/lib/mozilla/native-messaging-hosts
. You’d need these changes:
- switch the plug to use
system-files
, and the write location to/var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.foo.json
- Adjust the hook script to write to the above location.
The /var/lib/snapd/hostfs
prefix is required to access the host’s root file system from within the sandbox.