SyncthingTray for Windows

Hey guys,

since I’m using syncthing under windows and the console windows does not fit my usage I created a small app called SyncthingTray. I know it would be better if it was written in GO instead of C# but I have no knowledge about GO and no time at the moment to learn it.

You can check out the source at https://github.com/iss0/SyncthingTray. A binary release is available at https://www.dropbox.com/s/8fvu374txz4v1n1/SyncthingTray.zip.

4 Likes

On the contrary, I think C# is exactly the right choice for Windows. This is awesome!

2 Likes

Thank you! :wink:

There is room for improvement, but for now it makes syncthing much more fun under windows for me.

I tried this out and have some comments/suggestions.

  • An installer would be great. It gets really sad if you start it without the Resources directory present, which I did at first. :wink:

  • I expected it to continue running down in the tray when I closed the window, but then realized I needed to minimize it instead. I’m not sure what the default Windows expectation would be here?

  • It’d be cool with the binary as a Github release, I’d rather link to https://github.com/iss0/SyncthingTray/releases/latest than a random Dropbox url.

  • As a future feature, it would be sweet if it would just download the Syncthing binary if I don’t already have it (i.e. a “Download Latest” button beside the “Set Syncthing Path” or something).

  • As a future feature, an “Open GUI” menu item when clicking the tray icon? It could either snarf the URL from the startup text, or peek into the config (whichever is easiest).

I love the initiative, I think it has the potential of making the Windows experience a lot smoother.

3 Likes

Thanks for your suggestions! I will take them into account, when I will open that solution the next time. Maybe this weekend I will find time for that. :wink:

Hi, why are there separate x86 and x64 releases? It is .NET and I don’t see any code that would need it.

You’re right, a x86 release would cut it for all systems. I will drop the x64 release in the future.

No need to be x86 specific. .NET can target multiple platforms (x86, x64, ARM) with single assembly. Just select “Any CPU” target platform. .NET framework will run it as needed.

1 Like

Thank you for that tool!

Would be great if it will be standard at syncthing.

About the name: if you might can add the keyword “systray”. Cause I didn´t find your tool when I am looking for that keyword.

Dropbox link semms to be dead.

Sombody might can give me instructions how to install on windows?

Cheers

  1. Download from https://github.com/iss0/SyncthingTray/releases
  2. extract (I used same folder as Syncthing) and run .exe
  3. select path, then check autostart and minimize

I’d rather prefer to use an app than a web gui, hope to see this going official

2 Likes

I really would love to see this go official as well - the tray is VERY useful although I have found a few minor issues with it:

  1. It doesn’t restart with Windows unless you first log-in as a user. With the tray installed it should be launching as a service so that it starts running even with a remote or automated reboot.
  2. It crashes occasionally when restarting Syncthing. To resolve you need to re-launch tray, stop and than restart the syncthing service.
  3. The tool-tips are a little too aggressive - when you come back after a few days you have a never ending stream of tray tips telling you about various connections - most of which is really old information.

Hi,

I just came across this thread a bit late as I just completed my own C# SyncThing launcher/monitor :frowning: . I posted the code at GitHub - bloones/SyncThingWin. Requires .Net framework 4.5.1. And an AnyCPU version of the binary can be found in Releases · bloones/SyncThingWin · GitHub

Here is how it works and how I recommend to use it:

  1. Create a folder under Program Files (i called mine SyncThing) and copy both my executable (SyncThingTray.exe) and SyncThing.exe in it

  2. Execute SyncThingTray and you will be prompted to configure it on the first run. In the configuration option, you will be asked the following:

  • Current Configuration: If you already ran SyncThing, this should be the location of your current configuration of SyncThing and should already be populated. If you never run SyncThing, keep this blank. This field is used to copy your old configuration to the new location specified in the next field. If you don’t want your configuration to be copied to a new location, leave this field blank and fill the New Configuration field only! If this field is not blank, the directory provided must contain a config.xml file.
  • New Configuration: This is the path where syncthing will read/write configuration to. It is passed to syncthing using the -home parameters because syncthing will be run under a system account from the windows service. I used Program Files\SyncThing\Data for mine.
  • Syncthing Executable: This is the path to syncthing.exe
  • Click on Save and Install Service to save the configuration, install and start the service
  1. The windows service will be started with the computer and ran SyncThing.exe in the background. To monitor and act on the service, you should add SyncThingTray in your startup menu. SyncThingTray is intended to both run the windows service and the monitoring application all in one executable (Depending on the context it is run under). The following options are available in the system tray icon:
  • Double click or Show Console: Open a copy of the output console of syncthing which is running with an invisible console. This window can be closed and will not cause SyncThing to stop nor SyncThingTray.
  • Show Gui: Open a new window with the SyncThing interface accessed through an integrated web browser: This window can be open and closed multiple time (The Gui address is read from the config.xml file directly)
  • Start Service will start the service and is only available if the service is stopped
  • Stop Service: NOT RECOMMENDED: This will kill the syncthing processes! If you go in the SyncThing web interface and select shutdown, this will in fact stop syncthing and also stop the windows service (restarting Syncthing will however not cause the service to restart). Starting the windows service will restart syncthing.
  • Exit will close the monitor application keeping the service running

Hope this can be of any help

4 Likes

Nice. Can’t you send ctrl+c to Syncthing when the service is stopped? Or send a shutdown command via the API? Because the way it seems to be implemented now probably means Syncthing will be killed hard on every computer shutdown. My current NSSM + syncthing-tray based solution handles this better. Otherwise your tool might be something that could be bundled with Syncthing for Windows.

I think NSSM should be used to install the service, it provides command line usage.

Now to stop the service an API CALL should work great, this can also open the way for restarting syncthing remotely.

Thanks for this, just today I got asked by a user how to see the status and this is just it!

Would be that hard to incorporate the tray in the main project?

Hi Guys,

Well, I searched the net and could not find an way to send a CTRL-C command to the console input through the .Net console object. I am sure some Win API can be used, but it may cause different executable for different platform (XP, Windows 7 …)

Using NSSM will not solve the ctrl+c issue. If additional command line are needed, be aware that my solution has the following: install, uninstall, start and stop with no other arguments to manage the service: I could add additional options of specifying the account, start mode … as part of the install command as well as the syncthing path. If the syncthing team think that it would be beneficial to include this project for the windows users until syncthing.exe can be run as a service, then for sure improvement can be made and I can find a few minutes here and there to improve it.

Striker Two: I would be interested to know the API that can shutdown the syncthing as I can definitively use them to stop the syncthing nicely. I checked Iss0’s code, and he use the same process as I do to exit: Kill all syncthing processes! If you can give me pointer on the API shutdown, I will certainly incorporate it.

I also not a big fan of the current configuration window, no the documentation of this tool !!! Having to work on 2 big projects with tight deadlines, I don’t have a lot of time, but I am open for any idea anybody would have to improve it.

Ok, back to my day job and will look at some improvement that can be made tonight!

NSSM has all kinds of shutdown options (sending ctrl+c, sending WM_Close), see https://nssm.cc/usage So why do you think using NSSM would not improve things?

Also this looks promising (have not tested it yet): http://stanislavs.org/stopping-command-line-applications-programatically-with-ctrl-c-events-from-net/

Regarding the API, it looks like you only have to POST /rest/shutdown to Syncthing (https://forum.syncthing.net/t/the-rest-interface/85). Seems easy enough…

1 Like

My apologies: I responded way too quickly and without further research. This time I did and you are right on all points. I did implement the ctrl+c process successfully and modified the installation screen to provide more installation options (Well all the one from NSSM that made sense).

I also checked the API and they seem simple enough to be implemented in .Net. I will most certainly implement the shutdown and restart, and since I am at it, the upgrade one. That will be a good start. Most likely by this Sunday.

Sounds good! If you need any help, let me know.