[GH-ISSUE #100] Proposal: move configuration to config directory #69

Closed
opened 2026-02-28 14:25:06 +03:00 by kerem · 5 comments
Owner

Originally created by @aykevl on GitHub (Sep 22, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/100

Right now, go-librespot reads configuration and credentials from the current working directory (unless specified otherwise). I propose we use the following scheme instead:

  • Configuration is read from ~/.config/go-librespot/config.yml. The file is the same as it currently is.
  • Credentials are stored in a new state file, in ~/.config/go-librespot/state.json. The file looks like this:
    {
      "credentials": {
        "username": "...",
        "data": "..."
      },
      "device_id": "..."
    }
    
  • The config directory is configurable with a flag, defaulting to UserConfigDir() + "/go-librespot" so it also uses the appropriate directory on other OSes.

There are a few reasons why I think this is a good idea:

  • I think the current directory is a bad place to store configuration. Maybe it's fine on a headless system, but at least the way I use go-librespot is on a regular user account (with config directory available).
  • More state needs to be saved, such as ZeroConfig credentials. I also have an issue that Spotify keeps defaulting to "Let others Jam on this speaker" which I suspect is because the device ID is regenerated each time.

@devgianlu if you agree with this scheme I'd like to implement this (but asking here first before I put a lot of work into it).

Originally created by @aykevl on GitHub (Sep 22, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/100 Right now, go-librespot reads configuration and credentials from the current working directory (unless specified otherwise). I propose we use the following scheme instead: * Configuration is read from ~/.config/go-librespot/config.yml. The file is the same as it currently is. * Credentials are stored in a new state file, in ~/.config/go-librespot/state.json. The file looks like this: ```json { "credentials": { "username": "...", "data": "..." }, "device_id": "..." } ``` * The config directory is configurable with a flag, defaulting to `UserConfigDir() + "/go-librespot"` so it also uses the appropriate directory on other OSes. There are a few reasons why I think this is a good idea: * I think the current directory is a bad place to store configuration. Maybe it's fine on a headless system, but at least the way I use go-librespot is on a regular user account (with config directory available). * More state needs to be saved, such as [ZeroConfig credentials](https://github.com/devgianlu/go-librespot/issues/81). I also have an issue that Spotify keeps defaulting to "Let others Jam on this speaker" which I suspect is because the device ID is regenerated each time. @devgianlu if you agree with this scheme I'd like to implement this (but asking here first before I put a lot of work into it).
kerem 2026-02-28 14:25:06 +03:00
Author
Owner

@Willyarma commented on GitHub (Sep 22, 2024):

Its more useful to me the way it is for my application, is there a way we can have both? perhaps with a command line option?

<!-- gh-comment-id:2366958751 --> @Willyarma commented on GitHub (Sep 22, 2024): Its more useful to me the way it is for my application, is there a way we can have both? perhaps with a command line option?
Author
Owner

@aykevl commented on GitHub (Sep 23, 2024):

@Willyarma yes, if there's a flag to set the config directory then you can set it to use the current working directory.

<!-- gh-comment-id:2367706904 --> @aykevl commented on GitHub (Sep 23, 2024): @Willyarma yes, if there's a flag to set the config directory then you can set it to use the current working directory.
Author
Owner

@Willyarma commented on GitHub (Sep 23, 2024):

I already made a request in #80 for command line options. Its loosly related to this.
I was thinking about creating the config file dynamically on the fly then realised if I launch all instances in parallel then that wont work. A command line path / filename for different config files would though.

Edit: Looks like it was already done, sorry I didnt realise.

<!-- gh-comment-id:2367775451 --> @Willyarma commented on GitHub (Sep 23, 2024): I already made a request in #80 for command line options. Its loosly related to this. I was thinking about creating the config file dynamically on the fly then realised if I launch all instances in parallel then that wont work. A command line path / filename for different config files would though. Edit: Looks like it was already done, sorry I didnt realise.
Author
Owner

@devgianlu commented on GitHub (Sep 23, 2024):

@aykevl This sounds like a great idea, especially in tackling #81. I have recently refactored the configuration code to use koanf so it's a little bit nicer, but this is even better.

<!-- gh-comment-id:2367834440 --> @devgianlu commented on GitHub (Sep 23, 2024): @aykevl This sounds like a great idea, especially in tackling #81. I have recently refactored the configuration code to use `koanf` so it's a little bit nicer, but this is even better.
Author
Owner

@aykevl commented on GitHub (Sep 29, 2024):

Proposal is implemented in #103 so closing.

<!-- gh-comment-id:2381350546 --> @aykevl commented on GitHub (Sep 29, 2024): Proposal is implemented in #103 so closing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#69
No description provided.