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 for environment variables for data/config folders #243

Closed
1 of 6 tasks
jintaxi opened this issue Apr 2, 2024 · 3 comments
Closed
1 of 6 tasks

Support for environment variables for data/config folders #243

jintaxi opened this issue Apr 2, 2024 · 3 comments

Comments

@jintaxi
Copy link

jintaxi commented Apr 2, 2024

Relevant components

  • Standalone tray application (based on Qt Widgets)
  • Plasmoid/applet for Plasma desktop
  • Dolphin integration
  • Command line tool (syncthingctl)
  • Integrated Syncthing instance (libsyncthing)
  • Backend libraries

Is your feature request specific to a certain platform/environment? Please specify.
Both for Windows and Linux.

Is your feature request related to a problem? Please describe.
In the Syncthing Tray -> Settings -> Startup -> Syncthing launcher -> Config directory/Data directory support for environment variables is needed. Such as %LocalAppData% in Windows.

Describe the solution you'd like
When writing something like %LocalAppData%/Syncthing, the program interprets it not as %LocalAppData%/Syncthing to a folder in the local directory, but actually follows the path specified in the environment variable.

Describe alternatives you've considered
I write the full path to the AppData/local folder, which makes it difficult to port the program (for example, for a USB stick), or leave it in the program folder (./data).

@Martchus
Copy link
Owner

Martchus commented Apr 2, 2024

Another alternative would be to use the environment variables mentioned by syncthing serve --help and not set anything in the settings dialog. At least I think the integrated Syncthing instance allows that as well.

However, I guess I can add support for those substituions (or would accept a PR adding this feature). I suppose under Windows it would go though all environment variables and substitues %NAME_OF_VARIABLE% with the value of that variable. Under Linux it would substitue ${NAME_OF_VARIABLE}. Implementing further syntax and escaping is probably not needed.

Copy link

stale bot commented Jun 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 2, 2024
Martchus added a commit that referenced this issue Jun 2, 2024
@Martchus Martchus removed the stale label Jun 2, 2024
@Martchus
Copy link
Owner

Martchus commented Jun 2, 2024

Closing as this is now implemented. The implementation uses https://pkg.go.dev/os#ExpandEnv under the hood so the syntax is $VAR or ${VAR} and I suppose that also counts under Windows.

EDIT: I've just tested it under Windows and it works (but only with $, so e.g. $AppData/libsyncthing-test will put files under %AppData%/libsyncthing-test).

@Martchus Martchus closed this as completed Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants