[PR #103] [MERGED] Use configuration directory and store app state there #209

Closed
opened 2026-02-28 14:26:15 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/devgianlu/go-librespot/pull/103
Author: @aykevl
Created: 9/27/2024
Status: Merged
Merged: 9/29/2024
Merged by: @devgianlu

Base: masterHead: configdir


📝 Commits (3)

  • 316ee5a feat: read configuration from OS-specific config dir instead of CWD
  • 17629de feat: move credentials in common app state
  • 8b41648 feat: save generated device ID in app state

📊 Changes

1 file changed (+108 additions, -45 deletions)

View changed files

📝 cmd/daemon/main.go (+108 -45)

📄 Description

This implements the changes proposed in #100. It implements the following things:

  • The --config_path and --credentials_path flags are removed and replaced with a single --config_dir flag.
  • The default config dir is ~/.config/go-librespot (on Linux, on other OSes it will be different).
  • Credentials are stored in state.json instead of credentials.json, with a different format. There's some code to upgrade the old state to the new state, to make the transition easier.
  • The device ID (that was previously newly generated each time on startup if not explicitly set in the configuration) is now saved in state.json along with the credentials. This means that Spotify will consider the device the same, and keep settings like "Let others Jam on this speaker".

This needs a few configuration changes to continue working:

  • The simplest option to keep the previous behavior is by using --config_dir=.. This will keep reading the configuration from the current working directory, and stores the app state there.
  • To move the configuration to the new location, use:
    $ mkdir ~/.config/go-librespot
    $ mv credentials.json config.yml ~/.config/go-librespot/
    

I could let go-librespot do this automatically, but that feels possibly dangerous if it normally uses settings in a particular directory unless they exist in the current working directory. So to avoid surprises, this needs to be done by hand.

I have not tested credential types other than "interactive": zeroconf doesn't seem to work well on my network and I'm not sure how to set up spotify_token.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/devgianlu/go-librespot/pull/103 **Author:** [@aykevl](https://github.com/aykevl) **Created:** 9/27/2024 **Status:** ✅ Merged **Merged:** 9/29/2024 **Merged by:** [@devgianlu](https://github.com/devgianlu) **Base:** `master` ← **Head:** `configdir` --- ### 📝 Commits (3) - [`316ee5a`](https://github.com/devgianlu/go-librespot/commit/316ee5aa24be22540978f84ae68f482a0e787414) feat: read configuration from OS-specific config dir instead of CWD - [`17629de`](https://github.com/devgianlu/go-librespot/commit/17629dec0e440b35eb6999e0ddec56a1a2dcd41f) feat: move credentials in common app state - [`8b41648`](https://github.com/devgianlu/go-librespot/commit/8b416482ad46d1698713a0e412d8551ae79933b0) feat: save generated device ID in app state ### 📊 Changes **1 file changed** (+108 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `cmd/daemon/main.go` (+108 -45) </details> ### 📄 Description This implements the changes proposed in #100. It implements the following things: * The `--config_path` and `--credentials_path` flags are removed and replaced with a single `--config_dir` flag. * The default config dir is ~/.config/go-librespot (on Linux, on other OSes it will be different). * Credentials are stored in state.json instead of credentials.json, with a different format. There's some code to upgrade the old state to the new state, to make the transition easier. * The device ID (that was previously newly generated each time on startup if not explicitly set in the configuration) is now saved in state.json along with the credentials. This means that Spotify will consider the device the same, and keep settings like "Let others Jam on this speaker". This needs a few configuration changes to continue working: * The simplest option to keep the previous behavior is by using `--config_dir=.`. This will keep reading the configuration from the current working directory, and stores the app state there. * To move the configuration to the new location, use: ``` $ mkdir ~/.config/go-librespot $ mv credentials.json config.yml ~/.config/go-librespot/ ``` I _could_ let go-librespot do this automatically, but that feels possibly dangerous if it normally uses settings in a particular directory unless they exist in the current working directory. So to avoid surprises, this needs to be done by hand. I have not tested credential types other than "interactive": zeroconf doesn't seem to work well on my network and I'm not sure how to set up spotify_token. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:26:15 +03:00
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#209
No description provided.