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

FR: Store client_id outside dotfiles #537

Closed
chrisgrieser opened this issue Aug 8, 2024 · 11 comments · Fixed by #548
Closed

FR: Store client_id outside dotfiles #537

chrisgrieser opened this issue Aug 8, 2024 · 11 comments · Fixed by #548
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chrisgrieser
Copy link

chrisgrieser commented Aug 8, 2024

Is your feature request related to a problem? Please describe.
I do version control and publish my .config directory in a GitHub repo, as quite a lot of people do. Thus, Due to the inclusion of the client_id, this results in having to gitignore the ~/.config/spotify_player/app.toml, as otherwise the id would be leaked.

Describe the solution you'd like
Save client_id outside the app.toml, so the remainder of the spotify-player-config can be stored in a public git repo without any trouble.

The client_id could then be read from an environment variable, which one could save in .zshenv.

Alternatively, support something like the password_cmd from spotifyd: https://docs.spotifyd.rs/config/File.html

# This is an alternative to the `password` field. Both
# can't be used simultaneously.
password_cmd = "command_that_writes_password_to_stdout"

Describe alternatives you've considered

  • gitignoring the app.toml and manually updating it all the time.
  • symlinking the app.toml into a private cloud storage.
@chrisgrieser chrisgrieser added the enhancement New feature or request label Aug 8, 2024
@aome510 aome510 added the good first issue Good for newcomers label Aug 8, 2024
@masroof-maindak
Copy link

@aome510 Hi, could you please assign this to me? I've never programmed in Rust before so I'd like to start simple and give this a shot.

@juliamertz
Copy link
Contributor

juliamertz commented Aug 10, 2024

@masroof-maindak I have already started work on this, though i can't test it out right now since authentication with spotify is broken. You can check it out here

Edit:
Authentication is working again for me, tested it on Linux and everything works fine. Only need someone on windows to confirm this is working for them as well.

@masroof-maindak
Copy link

@masroof-maindak I have already started work on this

Oh well, bummer. Thank you for your contribution regardless.

@chrisgrieser
Copy link
Author

chrisgrieser commented Jan 3, 2025

@juliamertz Sorry, I am just testing this now, since the authentication was previously broken.

I tried client_id_command = 'cat "/path/to/file"' (with the file containing nothing but the client_id) and it is unfortunately not working for me.

cat "/path/to/file" does output the correct client_id, and setting client_id = "..." also does work fine. I also tried client_id_command = 'cat "/path/to/file"' | tr -d "\n" just in case, but that also does not work.

I am on macOS 14.5 (i386), with spotify_player 0.20.4.

@juliamertz
Copy link
Contributor

@chrisgrieser Looks like your config isn't quite right, can you try putting this in your app.toml?

client_id_command = { command = "cat", args = ["/run/secrets/spotify_client_id"] }

@chrisgrieser
Copy link
Author

@juliamertz that is also not working for me.

btw, the docs on config options do not mention that client_id_command needs sub-keys, so there is no way to know that from a user perspective.

@juliamertz
Copy link
Contributor

@chrisgrieser That's weird, i'm using the exact same option and it's working fine for me.
Can you check the logs in ~/.cache/spotify-player/*.log and verify your configuration is being parsed correctly?

Also there's a bit on using commands here, though i agree this is a bit unclear

@masroof-maindak
Copy link

masroof-maindak commented Jan 4, 2025

@juliamertz same issue.

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

My app refuses to launch, and this is what I get: https://pastebin.com/Epz0mfxa

Comment it out and it works just fine.

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

@juliamertz
Copy link
Contributor

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

This won't actually parse so it'd be treated as a None value and default to client_id

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

I just tried it out with your setup and it looks like you need to specify the full path to the file.
Using ~ in place of /home/user also results in a panic for me

@masroof-maindak
Copy link

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

This won't actually parse so it'd be treated as a None value and default to client_id

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

I just tried it out with your setup and it looks like you need to specify the full path to the file. Using ~ in place of /home/user also results in a panic for me

Okay, so it boots fine now, and allows me to detect music from my phone, but no longer lists my machine as a 'device' so I can't play music on my own or switch from my phone to my machine.

This goes away once I comment out the client_id_command line.

2025-01-05_012959
image

D in either case does not list my machine as a device.

@chrisgrieser
Copy link
Author

@juliamertz I just experimented at bit, and it appears the issue is the trailing newline:

# does not work
client_id_command = { command = "echo", args = ["my-id"] }
# works
client_id_command = { command = "echo", args = ["-n", "my-id"] }

Since shell commands commonly add a newline to their output, this should be dealt with by spotify_player, imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants