gnome-shell-extension-syncthing icon indicating copy to clipboard operation
gnome-shell-extension-syncthing copied to clipboard

Syncthing Icon does not work with Ubuntu snap version of syncthing

Open trevor87 opened this issue 6 years ago • 18 comments

Hi!

Thanks for your useful extension, I used it quite a lot so far!

Now I switched to the snap version of syncthing on ubuntu since it is always updated to the current released version and I noticed that it does not work with Syncthing Icon anymore.. What would have to be done to adapt the current version of the extension to the snap version? Would it be sufficient to just change the paths for the config folder and the binary?

Greetings Trevor

trevor87 avatar Jun 30 '18 10:06 trevor87

Not sure, since I have zero experience with snaps, so far.

What exactly does "does not work .. anymore" mean? Are there any errors? What is the output of journalctl -b /usr/bin/gnome-shell | grep syncthing?

Furthermore, I am not sure whether systemctl can access the runtime information of the syncthing process. It may be sandboxed. The extension currently uses systemctl --user is-active syncthing.service to check for the activity of syncthing. You should check what a similar systemctl --user status syncthing.service outputs.

jaystrictor avatar Jun 30 '18 16:06 jaystrictor

Thanks for your quick response! By "does not work" I mean: Syncthing is running but the tray icon shows that it is not. Also if syncthing is not running I can not start it using the icon.


Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/sax.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/exchange.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/question.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/filewatcher.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/schemas/org.gnome.shell.extensions.syncthing.gschema.xml
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/syncthing-logo-symbolic.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/stylesheet.css
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/syncthing-logo.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/webviewer.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/database.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/prefs.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/extension.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/pause.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/icons/exclamation-triangle.svg
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/README.md
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/convenience.js
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:   inflating: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/schemas/gschemas.compiled
Jun 30 20:52:56 Linux org.gnome.Shell.desktop[2213]:  extracting: /home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/metadata.json
Jun 30 20:52:56 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://localhost:8384': 403 Forbidden
Jun 30 20:52:57 Linux gnome-shell[2213]: JS WARNING: [/home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/sax.js 118]: reference to undefined property "position"
Jun 30 20:52:57 Linux gnome-shell[2213]: JS WARNING: [/home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/sax.js 358]: reference to undefined property "c"
Jun 30 20:52:57 Linux gnome-shell[2213]: JS WARNING: [/home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/sax.js 951]: reference to undefined property "ns"
Jun 30 20:52:57 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:52:59 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:03 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:11 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:21 Linux org.gnome.Shell.desktop[2213]: Failed to start syncthing.service: Unit syncthing.service not found.
Jun 30 20:53:21 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:22 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:24 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:28 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:36 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:46 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:53:56 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:06 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:16 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:26 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:36 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:46 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:54:56 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:55:06 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden
Jun 30 20:55:16 Linux gnome-shell[2213]: Failed to connect to syncthing daemon at URI 'http://127.0.0.1:8384': 403 Forbidden

It is weird that it cannot connect since I can connect without problems using firefox..

trevor87 avatar Jun 30 '18 18:06 trevor87

This could be a duplicate of #16 / #21. Trusting a TLS certificate by user interaction is not supported by the Gnome javascript interpreter, so currently the extension does not work when using TLS. Check whether you are using TLS and consider deactivating it.

jaystrictor avatar Jun 30 '18 20:06 jaystrictor

By TLS do you mean using the GUI over https? I have this disabled and connect without https.

Does the extension rely on the config directory? If so, I would have to change the path somehow, because with the snap the config dir is in /home/trevor/snap/syncthing/common/syncthing

trevor87 avatar Jul 01 '18 09:07 trevor87

By TLS do you mean using the GUI over https? I have this disabled and connect without https.

Yes, I meant https. So this is not the problem, ok.

Does the extension rely on the config directory?

Yes, the config path ~/.config/syncthing/config.xml is pretty much hardcoded for the extension.

To change the Web Interface URI, start gnome-shell-extension-prefs and change the settings for Syncthing Icon: Turn off Automatic Configuration and specify the correct URI (the one that works with Firefox). Does this solve your problem?

jaystrictor avatar Jul 01 '18 14:07 jaystrictor

Unfortunately entering the URL manually doesn't fix it (it was the same URL anyway). I also created a softlink from ~/.config/syncthing/ to ~/snap/syncthing/common/syncthing but that didn't help either.

trevor87 avatar Jul 01 '18 15:07 trevor87

When you enter the URI manually, you also have to copy the API key from your config file to the corresponding field in the Syncthing Icon configuration box. I forgot to mention that, sorry.

jaystrictor avatar Jul 01 '18 15:07 jaystrictor

OK we're definitely getting closer! Now I can at least see the shared folders in the dropdown menu. But still it doesn't show that syncthing is running, even though it is and I cannot connect to the web interface from the extensions dropdown menu.

These are the remaining errors:

Jul 01 17:49:19 Linux gnome-shell[7013]: JS WARNING: [/home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/extension.js 203]: reference to undefined property "state"
Jul 01 17:49:19 Linux gnome-shell[7013]: JS WARNING: [/home/trevor/.local/share/gnome-shell/extensions/[email protected]@posteo.de/extension.js 91]: reference to undefined property "state"
Jul 01 17:49:30 Linux org.gnome.Shell.desktop[7013]: Failed to start syncthing.service: Unit syncthing.service not found.
Jul 01 17:49:33 Linux org.gnome.Shell.desktop[7013]: Failed to start syncthing.service: Unit syncthing.service not found.

trevor87 avatar Jul 01 '18 15:07 trevor87

The Syncthing Icon extension starts and stops Syncthing via systemd as a systemd user service. The above logging messages just say that there is no such systemd user service.

How do you start and stop Syncthing via snap?

jaystrictor avatar Jul 05 '18 06:07 jaystrictor

I startup syncthing on system startup using the command:

syncthing -no-browser -home="/home/trevor/snap/syncthing/common/syncthing"

trevor87 avatar Jul 16 '18 14:07 trevor87

Generally, you should start syncthing via the systemd user session as stated in the Requirements section of the README.md. Then the On/Off button should work and you should be able to connect to the web interface.

Having said that, I guess it should be possible to rewrite the extension such that it also supports other technologies like flatpak and snap. I will look into it.

jaystrictor avatar Jul 21 '18 19:07 jaystrictor

There is an open issue in the syncthing bug tracker on how to manage a syncthing snap user service. I hope this will be resolved soon.

jaystrictor avatar Aug 04 '18 16:08 jaystrictor

Hi! I just got the extension to work using snap + system.d.

I created a file called ~/.config/systemd/user/syncthing.service with the following contents:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)

[Service]
ExecStart=/snap/bin/syncthing -no-browser -no-restart -logflags=0 -home="/home/trevor/snap/syncthing/common/syncthing"
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=default.target

and then used the commands:

systemctl --user enable syncthing.service
systemctl --user start syncthing.service

in case that does not work straight away try systemctl --user daemon-reload

Also make sure that no other instance of syncthing is running, else you got weird errors.

To debug use: journalctl -e --user-unit=syncthing.service

Hope this helps anybody!

trevor87 avatar Oct 07 '18 17:10 trevor87

Hi, @trevor87 thanks for a great solution :]

I've modified my file a little bit because I didn't understand some of the lines in yours. Mine looks like this (notice that path to syncthing folder doeasn't start with /):

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)

[Service]
ExecStart=/snap/bin/syncthing -no-browser -home="snap/syncthing/common/syncthing"
Restart=on-failure

[Install]
WantedBy=multi-user.target

I've also found a useful command to check service status:

systemctl --user status syncthing.service

qkiel avatar Oct 26 '18 17:10 qkiel

Happy to hear that it helped! :] Thanks for sharing!

I didn't understand all lines either, I just took the official user systemd file from the syncthing project on github and modified it a bit.

trevor87 avatar Oct 26 '18 19:10 trevor87

The latest commit should now support reading the config file from $HOME/snap/syncthing/common/syncthing and parsing it automatically. Thus the extension now connects to syncthing automatically if started via the snap package.

However to start the syncthing snap package you still need to manually install the user unit as explained above.

jaystrictor avatar Nov 11 '18 17:11 jaystrictor

I run the syncthing instance via systemd, I can start and stop the service with the icon, web inrterface and sync work but the icon has a waring with no message Capture du 2019-10-17 14-46-51

Did I miss something ?

lalop avatar Oct 17 '19 12:10 lalop

@lalop Perhaps a different issue. I updated the issue template. Could you file a new bug report for that?

jaystrictor avatar Oct 17 '19 19:10 jaystrictor