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

Conf dir #21

Closed
Closed

Conversation

dubo-dubon-duponey
Copy link
Contributor

Fix #20

New flag -c allows one to point to a base directory where configuration will live.

If unspecified, pwd will be used, which should match the previous behavior.

This is just a quick suggestion at this point, but I thought I would send it over early for feedback / modifications.

@dubo-dubon-duponey
Copy link
Contributor Author

Rebased.

main.go Outdated
flag.StringVar(&config.Config.DeviceName, "n", "goplay", "Specify device name")
flag.StringVar(&ifName, "i", "eth0", "Specify interface")
flag.Int64Var(&delay, "delay", 0, "Specify hardware delay in ms")
flag.StringVar(&config.Config.PulseSink, "sink", config.Config.PulseSink, "Specify Pulse Audio Sink - Linux only")
flag.Parse() // after declaring flags we need to call it

config.Config.Load()
config.Config.Load(configurationBaseDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If configuration load returns an error, it should panic (no cwd directory, nothing will work)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

Signed-off-by: dubo-dubon-duponey <dubodubonduponey+github@pm.me>
@dubo-dubon-duponey
Copy link
Contributor Author

@AlbanSeurat controller filestorage will also write in the "goplay" location, so, that should be patched as well I guess.

Data is not configuration though, so, I was thinking about separating these:

  • add a new entry in the config file (storage_path or something in the line)
  • use that config value to point FileStorage to the right location
  • there could also be a new flag allowing control of that on the command line

Let me know your thoughts.

Signed-off-by: dubo-dubon-duponey <dubodubonduponey+github@pm.me>
@dubo-dubon-duponey
Copy link
Contributor Author

Ok, done:

  • -c allows to point to a base directory for config (default to cwd)
  • -d allows to point to a base directory for data (defaults to config location)

Also modified main so that certain values passed on the command line do override stored config (sink and data location).

This is a bit more extensive than I thought, sorry about that.
If this is not desirable I can just keep it in my fork (I need it in all cases).

Copy link
Member

@AlbanSeurat AlbanSeurat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have kept both config and “data” directory in the same place.
I do not know your use case but it could just be “accessory data directory”

// Load the possibly existing config
err := config.Config.Load(configurationBaseDir)
if err != nil {
panic(err)
Copy link
Member

@AlbanSeurat AlbanSeurat Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use log.panicf to have a meaningful message

}
if flagsConfig.PulseSink != "" {
config.Config.PulseSink = flagsConfig.PulseSink
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It start to be a good case to create a new file with all config related code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to give it a go if you are interested and refactor this proper.

Question though: are you attached to the idea that the config path must contain the DeviceName? IMHO this is problematic for a number of reasons (filesystem reserved chars vs. mDNS type, duplication of DeviceName in the path, on the command-line, and inside the config file)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all attached, the whole focus for me now is to have good sound and audio sync.

I am happy with a better configuration/usability if you want to help

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed what matters most is good sound and audio sync :) - keep it coming!

Happy to help with the rest (build, packaging, UX) and then just feel free to pick whatever makes sense for you and the project.

Thanks again for doing this project - very much appreciated :)

@dubo-dubon-duponey
Copy link
Contributor Author

Putting this on pause for now, pending more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: ability to have configuration in a user specified directory
2 participants