dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
875 stars 45 forks source link

Create a Portable Version #371

Closed starfishpatkhoo closed 4 months ago

starfishpatkhoo commented 5 months ago

Just a asking for an enhancement - if it would be possible to create a portable version.

It would be nice if on startup, the executable would search for the the config files located next to the executable, or in a predefined folder next to the executable, before searching $HOME, %AppData% and friends..

^_^

dweymouth commented 5 months ago

I'm guessing the portable mode should also not save the password? Because saving it in the system keyring is not portable and saving it in plaintext isn't secure. Also, should the image cache be in a directory called "cache" right next to the executable in portable mode?

starfishpatkhoo commented 5 months ago

I'm guessing the portable mode should also not save the password? Because saving it in the system keyring is not portable and saving it in plaintext isn't secure. Also, should the image cache be in a directory called "cache" right next to the executable in portable mode?

Yep.. basically on a USB drive out of the box.. ^_^

Plaintext passwords is fine I feel.. People who want it portable should not be asking too much for security. This ain't a configuration method for NSA certification.. But yeah, if people wanted such a thing (insecure, messy, no cleanups, or etc etc..), They take responsibility and then they can do so if they wish.. ^_^

Maybe a "portable" folder next to the executable, if it exists and the file "config.toml" exists inside, then everything else is thrown in there too..

./supersonic
./portable
./portable/config.toml
./portable/themes
./portable/cache
./portable/server_name.password

Or something like that.. nothing too fancy, nothing too complex.. ^_^

accforgithubtest commented 4 months ago

Would love to see a portable version as well

dweymouth commented 4 months ago

This shouldn't be too hard to add, but I'm not too familiar with how portable apps are usually setup. How will it know if it should be running in portable mode? Would it make sense to have a single directory next to the EXe where it stores everything (eg supersonic_portable)? Would it run in portable mode if and only if it sees that directory exists? (In which you need to manually create it before running Supersonic for the first time to avoid it storing config in the system dirs?

accforgithubtest commented 4 months ago

Just looking at few other portable softwares for linux distros, it looks like a common practice for the application files to be in places like

  1. Similar to firefox - create a hidden folder in the users home directory - ~/.supersonic/
  2. Similar to DBeaver, telegram and many others - create a folder in local/share - ~/.local/share/supersonic/

I am no expert in this subject, however the reason to have it as a dotfile / dotfolder is to allow for the user settings to be persisted/preserved even if the portable version is moved / replaced with a updated version of the software. This also allows for sharing the settings across systems using git, etc.

So I would suggest to pick a somewhat standard approach of dotfiles in users home directory or ~/.local/share/. So my opinion would be to have it in ~/.local/share/supersonic/.

Irrespective of where the user runs the application from, check for the existing settings files in that location, and if its there use them, else assume fresh install and create new settings files / force user to enter the details to save in that location.

starfishpatkhoo commented 4 months ago

This shouldn't be too hard to add, but I'm not too familiar with how portable apps are usually setup. How will it know if it should be running in portable mode? Would it make sense to have a single directory next to the EXe where it stores everything (eg supersonic_portable)? Would it run in portable mode if and only if it sees that directory exists? (In which you need to manually create it before running Supersonic for the first time to avoid it storing config in the system dirs?

Yes, a supersonic_portable folder next to the executable is good. Everything in there, and in "portable mode" if that folder exists.

Yes, user is responsible for creating that folder. And yes, no encrypted strings/text files/etc - user is responsible for security.

Putting things in $HOME is not really "portable mode" because there are situations that $HOME is inaccessible. The idea again is that if "portable mode" is used on a USB drive, nothing touches the main root/FS/drive etc and you can... portably... bring that USB around to different machines and it works the way you have it set up. Like a roaming profile, but without the network mounted folder... On a USB stick you carry in your pocket. 😄

dweymouth commented 4 months ago

The way that this will be implemented is that the app will run in portable mode if a directory supersonic_portable exists next to the executable. It will automatically enter portable mode in this case and save its config and cache inside that directory. It will not save the password and you will need to input it on launch since it is not possible to do so securely.

starfishpatkhoo commented 3 months ago

Works Perfect, Thank You! ^_^

Just wanted to add a note, in case other people come here:

dweymouth commented 3 months ago

However, in config.toml, the theme file will be saved as a full path. So depending on your situation, it may or may not break. If you're on Linux, you should probably manually set the path according to your mount point via ID instead. Not to sure what the equivalent would be on Windows - I guess if your USB is usually mounted in the same drive letter, it should work just fine...

I would consider this a bug .. I'll open an issue to track this. Theme files should be saved with relative paths in config.toml so that it will continue to work in portable mode even if the absolute path changes

dweymouth commented 3 months ago

https://github.com/dweymouth/supersonic/issues/404

dweymouth commented 3 months ago

@starfishpatkhoo Sorry but I can't reproduce #404 here - can you double-check that the theme files are indeed referenced in the config.toml by full file paths? In mine it's only the filename itself and looking at the code I don't see where the full file path would be coming from

starfishpatkhoo commented 3 months ago

@starfishpatkhoo Sorry but I can't reproduce #404 here - can you double-check that the theme files are indeed referenced in the config.toml by full file paths? In mine it's only the filename itself and looking at the code I don't see where the full file path would be coming from

So sorry for the late reply!

I figured it out though..

Basically if you just put the file name in the config.toml:

ThemeFile = 'breeze.toml'

It works just fine. But what I happened to do after that was go to settings, and choose like Nord or something, and then the UI would switch and the config.toml would end up with the full path to J:\Apps\Supersonic\supersonic_portable\config\themes\nord.toml

So it only happens when saving the config file after changing it in settings...

I think it is a small matter. I only happened to be testing different themes, and I think once most people have chosen their theme, they will just put it into the config.toml and it just works... ^_^

PS. This is in 0.11.0 ...